[flang-commits] [flang] [Flang][OpenMP] Fix type in getBaseObject causing crashes in certain scenarios (PR #95472)

via flang-commits flang-commits at lists.llvm.org
Thu Jun 13 13:53:45 PDT 2024


https://github.com/agozillon created https://github.com/llvm/llvm-project/pull/95472

This typo would unfortunately cause code like the following to ICE, where common block symbols/names are used in a map clause:

subroutine sb()
  implicit none
  integer:: b, c
  common /var/ b, c

!$omp target map(tofrom: /var/)
   b = 1
   c = 2
!$omp end target
end subroutine

>From 5f7b0270e3a7eb9955981fa4aa0a77df4e0e1b36 Mon Sep 17 00:00:00 2001
From: agozillon <Andrew.Gozillon at amd.com>
Date: Thu, 13 Jun 2024 15:50:58 -0500
Subject: [PATCH] [Flang][OpenMP] Fix type in getBaseObject causing crashes in
 certain scenarios

This type would unfortunately cause code like the following to ICE, where common block symbols/names are used in a map clause:

subroutine sb()
  implicit none
  integer:: b, c
  common /var/ b, c

!$omp target map(tofrom: /var/)
   b = 1
   c = 2
!$omp end target
end subroutine
---
 flang/lib/Lower/OpenMP/Clauses.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp b/flang/lib/Lower/OpenMP/Clauses.cpp
index 1e3fea7c4cdc7..6bae62cd85860 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -153,7 +153,7 @@ Object makeObject(const parser::OmpObject &object,
 std::optional<Object> getBaseObject(const Object &object,
                                     semantics::SemanticsContext &semaCtx) {
   // If it's just the symbol, then there is no base.
-  if (!object.id())
+  if (!object.ref())
     return std::nullopt;
 
   auto maybeRef = evaluate::ExtractDataRef(*object.ref());



More information about the flang-commits mailing list