[flang-commits] [flang] 91f10df - [Flang][OpenMP] Skip implicit mapping of named constants (#145966)

via flang-commits flang-commits at lists.llvm.org
Fri Jun 27 05:05:25 PDT 2025


Author: Akash Banerjee
Date: 2025-06-27T13:05:22+01:00
New Revision: 91f10df794d3293e18a56770acc1fd66fa0b7690

URL: https://github.com/llvm/llvm-project/commit/91f10df794d3293e18a56770acc1fd66fa0b7690
DIFF: https://github.com/llvm/llvm-project/commit/91f10df794d3293e18a56770acc1fd66fa0b7690.diff

LOG: [Flang][OpenMP] Skip implicit mapping of named constants (#145966)

Added early return when mapping named constants.

This prevents linking error in the following example:

```
program test
   use, intrinsic :: iso_c_binding, only: c_double
   implicit none

   real(c_double) :: x
   integer        :: i
   x = 0.0_c_double
   !$omp target teams distribute parallel do reduction(+:x)
   do i = 0, 9
      x = x + 1.0_c_double
   end do
   !$omp end target teams distribute parallel do
end program test
```

Added: 
    

Modified: 
    flang/lib/Lower/OpenMP/OpenMP.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index e21d0effe2ef6..e4c15e8ba254c 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -2441,6 +2441,10 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
     if (dsp.getAllSymbolsToPrivatize().contains(&sym))
       return;
 
+    // Skip parameters/constants as they do not need to be mapped.
+    if (semantics::IsNamedConstant(sym))
+      return;
+
     // These symbols are mapped individually in processHasDeviceAddr.
     if (llvm::is_contained(hasDeviceAddrSyms, &sym))
       return;


        


More information about the flang-commits mailing list