Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

mrkajetanp
Copy link
Contributor

Add a visitor for OmpClause::Uniform to resolve its parameter names.
Fixes issue #140741.

Add a visitor for OmpClause::Uniform to resolve its parameter names.
Fixes issue llvm#140741.

Signed-off-by: Kajetan Puchalski <[email protected]>
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:openmp flang:semantics labels May 30, 2025
@llvmbot
Copy link
Member

llvmbot commented May 30, 2025

@llvm/pr-subscribers-flang-openmp

Author: Kajetan Puchalski (mrkajetanp)

Changes

Add a visitor for OmpClause::Uniform to resolve its parameter names.
Fixes issue #140741.


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

4 Files Affected:

  • (modified) flang/include/flang/Semantics/symbol.h (+1-1)
  • (modified) flang/lib/Semantics/resolve-directives.cpp (+7)
  • (modified) flang/lib/Semantics/resolve-names.cpp (+5)
  • (added) flang/test/Semantics/OpenMP/declare-simd-uniform.f90 (+13)
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 4cded64d170cd..9ebdd3a8081ed 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -786,7 +786,7 @@ class Symbol {
       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_; }
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 9fa7bc8964854..ecb4f02732a4b 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -550,6 +550,13 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
     return false;
   }
 
+  bool Pre(const parser::OmpClause::Uniform &x) {
+    for (const auto &name : x.v) {
+      ResolveOmpName(name, Symbol::Flag::OmpUniform);
+    }
+    return false;
+  }
+
   bool Pre(const parser::OmpInReductionClause &x) {
     auto &objects{std::get<parser::OmpObjectList>(x.t)};
     ResolveOmpObjectList(objects, Symbol::Flag::OmpInReduction);
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 57035c57ee16f..7bea6fdb00e55 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1511,6 +1511,11 @@ class OmpVisitor : public virtual DeclarationVisitor {
     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);
diff --git a/flang/test/Semantics/OpenMP/declare-simd-uniform.f90 b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
new file mode 100644
index 0000000000000..3a0c52b8e7b0e
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
@@ -0,0 +1,13 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+! 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
+

@llvmbot
Copy link
Member

llvmbot commented May 30, 2025

@llvm/pr-subscribers-flang-semantics

Author: Kajetan Puchalski (mrkajetanp)

Changes

Add a visitor for OmpClause::Uniform to resolve its parameter names.
Fixes issue #140741.


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

4 Files Affected:

  • (modified) flang/include/flang/Semantics/symbol.h (+1-1)
  • (modified) flang/lib/Semantics/resolve-directives.cpp (+7)
  • (modified) flang/lib/Semantics/resolve-names.cpp (+5)
  • (added) flang/test/Semantics/OpenMP/declare-simd-uniform.f90 (+13)
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 4cded64d170cd..9ebdd3a8081ed 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -786,7 +786,7 @@ class Symbol {
       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_; }
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 9fa7bc8964854..ecb4f02732a4b 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -550,6 +550,13 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
     return false;
   }
 
+  bool Pre(const parser::OmpClause::Uniform &x) {
+    for (const auto &name : x.v) {
+      ResolveOmpName(name, Symbol::Flag::OmpUniform);
+    }
+    return false;
+  }
+
   bool Pre(const parser::OmpInReductionClause &x) {
     auto &objects{std::get<parser::OmpObjectList>(x.t)};
     ResolveOmpObjectList(objects, Symbol::Flag::OmpInReduction);
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 57035c57ee16f..7bea6fdb00e55 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1511,6 +1511,11 @@ class OmpVisitor : public virtual DeclarationVisitor {
     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);
diff --git a/flang/test/Semantics/OpenMP/declare-simd-uniform.f90 b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
new file mode 100644
index 0000000000000..3a0c52b8e7b0e
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
@@ -0,0 +1,13 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+! 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
+

Copy link
Contributor

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG. Please wait for @tblah

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mrkajetanp mrkajetanp merged commit 01d4b16 into llvm:main Jun 2, 2025
11 checks passed
sallto pushed a commit to sallto/llvm-project that referenced this pull request Jun 3, 2025
…42160)

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

---------

Signed-off-by: Kajetan Puchalski <[email protected]>
DhruvSrivastavaX pushed a commit to DhruvSrivastavaX/lldb-for-aix that referenced this pull request Jun 12, 2025
…42160)

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

---------

Signed-off-by: Kajetan Puchalski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:openmp flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants