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

via flang-commits flang-commits at lists.llvm.org
Thu Jun 26 13:46:31 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-fir-hlfir

Author: Akash Banerjee (TIFitis)

<details>
<summary>Changes</summary>

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
```

---
Full diff: https://github.com/llvm/llvm-project/pull/145966.diff


1 Files Affected:

- (modified) flang/lib/Lower/OpenMP/OpenMP.cpp (+4) 


``````````diff
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index ebd1d038716e4..b52818e5387a6 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -2395,6 +2395,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;

``````````

</details>


https://github.com/llvm/llvm-project/pull/145966


More information about the flang-commits mailing list