[OPENMP]Fix PR48658: [OpenMP 5.0] Compiler crash when OpenMP atomic sync hints used.
authorAlexey Bataev <a.bataev@outlook.com>
Tue, 30 Mar 2021 17:36:23 +0000 (10:36 -0700)
committerAlexey Bataev <a.bataev@outlook.com>
Wed, 31 Mar 2021 19:58:24 +0000 (12:58 -0700)
No need to consider hint clause kind as the main atomic clause kind at the
codegen.

Differential Revision: https://reviews.llvm.org/D99611

clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/atomic_codegen.cpp

index 5373805..2858369 100644 (file)
@@ -5594,7 +5594,11 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, OpenMPClauseKind Kind,
   case OMPC_exclusive:
   case OMPC_uses_allocators:
   case OMPC_affinity:
-  default:
+  case OMPC_init:
+  case OMPC_inbranch:
+  case OMPC_notinbranch:
+  case OMPC_link:
+  case OMPC_use:
     llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
 }
@@ -5626,7 +5630,7 @@ void CodeGenFunction::EmitOMPAtomicDirective(const OMPAtomicDirective &S) {
         C->getClauseKind() != OMPC_acq_rel &&
         C->getClauseKind() != OMPC_acquire &&
         C->getClauseKind() != OMPC_release &&
-        C->getClauseKind() != OMPC_relaxed) {
+        C->getClauseKind() != OMPC_relaxed && C->getClauseKind() != OMPC_hint) {
       Kind = C->getClauseKind();
       break;
     }
index 47ab0b4..ada47d4 100644 (file)
@@ -58,7 +58,7 @@ void parallel_atomic_ewc() {
       // CHECK: {{invoke|call}} void @_ZN2StD1Ev(%struct.St* {{[^,]*}} [[TEMP_ST_ADDR]])
 #pragma omp atomic
       St().get() %= b;
-#pragma omp atomic
+#pragma omp atomic hint(6)
       s.field++;
       // CHECK: invoke void @_ZN2StC1Ev(%struct.St* {{[^,]*}} [[TEMP_ST_ADDR:%.+]])
       // CHECK: [[SCALAR_ADDR:%.+]] = invoke nonnull align 4 dereferenceable(4) i32* @_ZN2St3getEv(%struct.St* {{[^,]*}} [[TEMP_ST_ADDR]])