Skip to content

Commit 01d4b16

Browse files
authored
[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 <[email protected]>
1 parent f50fe74 commit 01d4b16

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

flang/include/flang/Semantics/symbol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ class Symbol {
786786
OmpExecutableAllocateDirective, OmpDeclareSimd, OmpDeclareTarget,
787787
OmpThreadprivate, OmpDeclareReduction, OmpFlushed, OmpCriticalLock,
788788
OmpIfSpecified, OmpNone, OmpPreDetermined, OmpImplicit, OmpDependObject,
789-
OmpInclusiveScan, OmpExclusiveScan, OmpInScanReduction);
789+
OmpInclusiveScan, OmpExclusiveScan, OmpInScanReduction, OmpUniform);
790790
using Flags = common::EnumSet<Flag, Flag_enumSize>;
791791

792792
const Scope &owner() const { return *owner_; }

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,11 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
550550
return false;
551551
}
552552

553+
bool Pre(const parser::OmpClause::Uniform &x) {
554+
ResolveOmpNameList(x.v, Symbol::Flag::OmpUniform);
555+
return false;
556+
}
557+
553558
bool Pre(const parser::OmpInReductionClause &x) {
554559
auto &objects{std::get<parser::OmpObjectList>(x.t)};
555560
ResolveOmpObjectList(objects, Symbol::Flag::OmpInReduction);
@@ -752,7 +757,8 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
752757
Symbol::Flag::OmpLastPrivate, Symbol::Flag::OmpReduction,
753758
Symbol::Flag::OmpCriticalLock, Symbol::Flag::OmpCopyIn,
754759
Symbol::Flag::OmpUseDevicePtr, Symbol::Flag::OmpUseDeviceAddr,
755-
Symbol::Flag::OmpIsDevicePtr, Symbol::Flag::OmpHasDeviceAddr};
760+
Symbol::Flag::OmpIsDevicePtr, Symbol::Flag::OmpHasDeviceAddr,
761+
Symbol::Flag::OmpUniform};
756762

757763
Symbol::Flags ompFlagsRequireMark{Symbol::Flag::OmpThreadprivate,
758764
Symbol::Flag::OmpDeclareTarget, Symbol::Flag::OmpExclusiveScan,

flang/lib/Semantics/resolve-names.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,11 @@ class OmpVisitor : public virtual DeclarationVisitor {
15111511
return false;
15121512
}
15131513

1514+
bool Pre(const parser::OpenMPDeclareSimdConstruct &x) {
1515+
AddOmpSourceRange(x.source);
1516+
return true;
1517+
}
1518+
15141519
bool Pre(const parser::OmpInitializerProc &x) {
15151520
auto &procDes = std::get<parser::ProcedureDesignator>(x.t);
15161521
auto &name = std::get<parser::Name>(procDes.u);

flang/lib/Semantics/symbol.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,9 @@ std::string Symbol::OmpFlagToClauseName(Symbol::Flag ompFlag) {
842842
case Symbol::Flag::OmpLinear:
843843
clauseName = "LINEAR";
844844
break;
845+
case Symbol::Flag::OmpUniform:
846+
clauseName = "UNIFORM";
847+
break;
845848
case Symbol::Flag::OmpFirstPrivate:
846849
clauseName = "FIRSTPRIVATE";
847850
break;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
2+
! RUN: %flang_fc1 -fopenmp -fdebug-dump-symbols %s | FileCheck %s
3+
! Test declare simd with uniform clause
4+
5+
function add2(a,b,i,fact,alc) result(c)
6+
!$omp declare simd(add2) uniform(a,b,fact)
7+
integer :: i
8+
integer,pointer::alc
9+
double precision :: a(*),b(*),fact,c
10+
c = a(i) + b(i) + fact
11+
end function
12+
13+
end
14+
15+
! CHECK-LABEL: Subprogram scope: add2 size=48 alignment=8 sourceRange=189 bytes
16+
! CHECK-NEXT: a (OmpUniform): ObjectEntity dummy type: REAL(8) shape: 1_8:*
17+
! CHECK-NEXT: add2 (Function): HostAssoc
18+
! CHECK-NEXT: alc, POINTER size=24 offset=8: ObjectEntity dummy type: INTEGER(4)
19+
! CHECK-NEXT: b (OmpUniform): ObjectEntity dummy type: REAL(8) shape: 1_8:*
20+
! CHECK-NEXT: c size=8 offset=40: ObjectEntity funcResult type: REAL(8)
21+
! CHECK-NEXT: fact (OmpUniform) size=8 offset=32: ObjectEntity dummy type: REAL(8)
22+
! CHECK-NEXT: i size=4 offset=0: ObjectEntity dummy type: INTEGER(4)

0 commit comments

Comments
 (0)