[flang-commits] [flang] [Flang][OpenMP] Skip implicit mapping of named constants (PR #145966)
Akash Banerjee via flang-commits
flang-commits at lists.llvm.org
Thu Jun 26 13:45:52 PDT 2025
https://github.com/TIFitis created https://github.com/llvm/llvm-project/pull/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
```
>From 28e336fa0c4a13c81f500ad31d56c046fb895af0 Mon Sep 17 00:00:00 2001
From: Akash Banerjee <Akash.Banerjee at amd.com>
Date: Thu, 26 Jun 2025 21:39:51 +0100
Subject: [PATCH] [Flang][OpenMP] Skip implicit mapping of named constants
Added early return when mapping implicit variables for 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
---
flang/lib/Lower/OpenMP/OpenMP.cpp | 4 ++++
1 file changed, 4 insertions(+)
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;
More information about the flang-commits
mailing list