-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Flang][OpenMP] Do not default privatize symbols that are not variables #117886
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
[Flang][OpenMP] Do not default privatize symbols that are not variables #117886
Conversation
Fixes an issue where the compiler is trying to default privatize construct names. Fixes llvm#112572
@llvm/pr-subscribers-flang-openmp Author: Kiran Chandramohan (kiranchandramohan) ChangesFixes an issue where the compiler is trying to default privatize construct names. Fixes #112572 Full diff: https://github.com/llvm/llvm-project/pull/117886.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 80e238f3476ac8..59013619cc689d 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2112,7 +2112,7 @@ void OmpAttributeVisitor::Post(const parser::OpenMPAllocatorsConstruct &x) {
static bool IsPrivatizable(const Symbol *sym) {
auto *misc{sym->detailsIf<MiscDetails>()};
- return !IsProcedure(*sym) && !IsNamedConstant(*sym) &&
+ return IsVariableName(*sym) && !IsProcedure(*sym) && !IsNamedConstant(*sym) &&
!semantics::IsAssumedSizeArray(
*sym) && /* OpenMP 5.2, 5.1.1: Assumed-size arrays are shared*/
!sym->owner().IsDerivedType() &&
diff --git a/flang/test/Semantics/OpenMP/critical_within_default.f90 b/flang/test/Semantics/OpenMP/critical_within_default.f90
new file mode 100644
index 00000000000000..dd972e6e529492
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/critical_within_default.f90
@@ -0,0 +1,17 @@
+! RUN: %flang_fc1 -fopenmp -fdebug-dump-symbols %s | FileCheck %s
+! Test that we do not make a private copy of the critical name
+
+!CHECK: MainProgram scope: mn
+!CHECK-NEXT: j size=4 offset=0: ObjectEntity type: INTEGER(4)
+!CHECK-NEXT: OtherConstruct scope:
+!CHECK-NEXT: j (OmpPrivate): HostAssoc
+!CHECK-NEXT: k2 (OmpCriticalLock): Unknown
+program mn
+ integer :: j
+ j=2
+ !$omp parallel default(private)
+ !$omp critical(k2)
+ j=200
+ !$omp end critical(k2)
+ !$omp end parallel
+end
|
@llvm/pr-subscribers-flang-semantics Author: Kiran Chandramohan (kiranchandramohan) ChangesFixes an issue where the compiler is trying to default privatize construct names. Fixes #112572 Full diff: https://github.com/llvm/llvm-project/pull/117886.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 80e238f3476ac8..59013619cc689d 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2112,7 +2112,7 @@ void OmpAttributeVisitor::Post(const parser::OpenMPAllocatorsConstruct &x) {
static bool IsPrivatizable(const Symbol *sym) {
auto *misc{sym->detailsIf<MiscDetails>()};
- return !IsProcedure(*sym) && !IsNamedConstant(*sym) &&
+ return IsVariableName(*sym) && !IsProcedure(*sym) && !IsNamedConstant(*sym) &&
!semantics::IsAssumedSizeArray(
*sym) && /* OpenMP 5.2, 5.1.1: Assumed-size arrays are shared*/
!sym->owner().IsDerivedType() &&
diff --git a/flang/test/Semantics/OpenMP/critical_within_default.f90 b/flang/test/Semantics/OpenMP/critical_within_default.f90
new file mode 100644
index 00000000000000..dd972e6e529492
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/critical_within_default.f90
@@ -0,0 +1,17 @@
+! RUN: %flang_fc1 -fopenmp -fdebug-dump-symbols %s | FileCheck %s
+! Test that we do not make a private copy of the critical name
+
+!CHECK: MainProgram scope: mn
+!CHECK-NEXT: j size=4 offset=0: ObjectEntity type: INTEGER(4)
+!CHECK-NEXT: OtherConstruct scope:
+!CHECK-NEXT: j (OmpPrivate): HostAssoc
+!CHECK-NEXT: k2 (OmpCriticalLock): Unknown
+program mn
+ integer :: j
+ j=2
+ !$omp parallel default(private)
+ !$omp critical(k2)
+ j=200
+ !$omp end critical(k2)
+ !$omp end parallel
+end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -2112,7 +2112,7 @@ void OmpAttributeVisitor::Post(const parser::OpenMPAllocatorsConstruct &x) { | |||
|
|||
static bool IsPrivatizable(const Symbol *sym) { | |||
auto *misc{sym->detailsIf<MiscDetails>()}; | |||
return !IsProcedure(*sym) && !IsNamedConstant(*sym) && | |||
return IsVariableName(*sym) && !IsProcedure(*sym) && !IsNamedConstant(*sym) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole check can probably be simplified further in a separate patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it should be OK to remove at least !IsNamedConstant(*sym)
, probably !IsProcedure(*sym)
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update in a separate patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
When I looked at this I really didn't realize that the name was only identifying the critical construct.
Fixes an issue where the compiler is trying to default privatize construct names.
Fixes #112572