[flang][OpenMP] Resolve names for declare simd uniform clause (#142160)

Add a visitor for OmpClause::Uniform to resolve its parameter names.
Add Symbol::Flag::OmpUniform to attach it to the resolved symbols.
Fixes issue #140741.

---------

Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
This commit is contained in:
Kajetan Puchalski
2025-06-02 16:37:02 +01:00
committed by GitHub
parent f50fe748b3
commit 01d4b16406
5 changed files with 38 additions and 2 deletions

View File

@@ -786,7 +786,7 @@ public:
OmpExecutableAllocateDirective, OmpDeclareSimd, OmpDeclareTarget,
OmpThreadprivate, OmpDeclareReduction, OmpFlushed, OmpCriticalLock,
OmpIfSpecified, OmpNone, OmpPreDetermined, OmpImplicit, OmpDependObject,
OmpInclusiveScan, OmpExclusiveScan, OmpInScanReduction);
OmpInclusiveScan, OmpExclusiveScan, OmpInScanReduction, OmpUniform);
using Flags = common::EnumSet<Flag, Flag_enumSize>;
const Scope &owner() const { return *owner_; }

View File

@@ -550,6 +550,11 @@ public:
return false;
}
bool Pre(const parser::OmpClause::Uniform &x) {
ResolveOmpNameList(x.v, Symbol::Flag::OmpUniform);
return false;
}
bool Pre(const parser::OmpInReductionClause &x) {
auto &objects{std::get<parser::OmpObjectList>(x.t)};
ResolveOmpObjectList(objects, Symbol::Flag::OmpInReduction);
@@ -752,7 +757,8 @@ private:
Symbol::Flag::OmpLastPrivate, Symbol::Flag::OmpReduction,
Symbol::Flag::OmpCriticalLock, Symbol::Flag::OmpCopyIn,
Symbol::Flag::OmpUseDevicePtr, Symbol::Flag::OmpUseDeviceAddr,
Symbol::Flag::OmpIsDevicePtr, Symbol::Flag::OmpHasDeviceAddr};
Symbol::Flag::OmpIsDevicePtr, Symbol::Flag::OmpHasDeviceAddr,
Symbol::Flag::OmpUniform};
Symbol::Flags ompFlagsRequireMark{Symbol::Flag::OmpThreadprivate,
Symbol::Flag::OmpDeclareTarget, Symbol::Flag::OmpExclusiveScan,

View File

@@ -1511,6 +1511,11 @@ public:
return false;
}
bool Pre(const parser::OpenMPDeclareSimdConstruct &x) {
AddOmpSourceRange(x.source);
return true;
}
bool Pre(const parser::OmpInitializerProc &x) {
auto &procDes = std::get<parser::ProcedureDesignator>(x.t);
auto &name = std::get<parser::Name>(procDes.u);

View File

@@ -842,6 +842,9 @@ std::string Symbol::OmpFlagToClauseName(Symbol::Flag ompFlag) {
case Symbol::Flag::OmpLinear:
clauseName = "LINEAR";
break;
case Symbol::Flag::OmpUniform:
clauseName = "UNIFORM";
break;
case Symbol::Flag::OmpFirstPrivate:
clauseName = "FIRSTPRIVATE";
break;

View File

@@ -0,0 +1,22 @@
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! RUN: %flang_fc1 -fopenmp -fdebug-dump-symbols %s | FileCheck %s
! Test declare simd with uniform clause
function add2(a,b,i,fact,alc) result(c)
!$omp declare simd(add2) uniform(a,b,fact)
integer :: i
integer,pointer::alc
double precision :: a(*),b(*),fact,c
c = a(i) + b(i) + fact
end function
end
! CHECK-LABEL: Subprogram scope: add2 size=48 alignment=8 sourceRange=189 bytes
! CHECK-NEXT: a (OmpUniform): ObjectEntity dummy type: REAL(8) shape: 1_8:*
! CHECK-NEXT: add2 (Function): HostAssoc
! CHECK-NEXT: alc, POINTER size=24 offset=8: ObjectEntity dummy type: INTEGER(4)
! CHECK-NEXT: b (OmpUniform): ObjectEntity dummy type: REAL(8) shape: 1_8:*
! CHECK-NEXT: c size=8 offset=40: ObjectEntity funcResult type: REAL(8)
! CHECK-NEXT: fact (OmpUniform) size=8 offset=32: ObjectEntity dummy type: REAL(8)
! CHECK-NEXT: i size=4 offset=0: ObjectEntity dummy type: INTEGER(4)