[flang-commits] [flang] c952f0e - [Flang][OpenMP] Do not default privatize symbols that are not variables (#117886)

via flang-commits flang-commits at lists.llvm.org
Thu Nov 28 04:37:26 PST 2024


Author: Kiran Chandramohan
Date: 2024-11-28T12:37:22Z
New Revision: c952f0ee5436318733c1ab21a8a7402f7f0a4caa

URL: https://github.com/llvm/llvm-project/commit/c952f0ee5436318733c1ab21a8a7402f7f0a4caa
DIFF: https://github.com/llvm/llvm-project/commit/c952f0ee5436318733c1ab21a8a7402f7f0a4caa.diff

LOG: [Flang][OpenMP] Do not default privatize symbols that are not variables (#117886)

Fixes an issue where the compiler is trying to default privatize
construct names.

Fixes #112572

Added: 
    flang/test/Semantics/OpenMP/critical_within_default.f90

Modified: 
    flang/lib/Semantics/resolve-directives.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 0c3708b3fd29b4..55dd94c1e69b7c 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2119,7 +2119,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 


        


More information about the flang-commits mailing list