[PATCH] D99611: [OPENMP]Fix PR48658: [OpenMP 5.0] Compiler crash when OpenMP atomic sync hints used.

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 30 10:38:35 PDT 2021


ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: jfb, guansong, yaxunl.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

No need to consider hint clause kind as the main atomic clause kind at the
codegen.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99611

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


Index: clang/test/OpenMP/atomic_codegen.cpp
===================================================================
--- clang/test/OpenMP/atomic_codegen.cpp
+++ clang/test/OpenMP/atomic_codegen.cpp
@@ -58,7 +58,7 @@
       // 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]])
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -5587,7 +5587,11 @@
   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'.");
   }
 }
@@ -5619,7 +5623,7 @@
         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;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99611.334221.patch
Type: text/x-patch
Size: 1462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210330/fa44e5f9/attachment.bin>


More information about the cfe-commits mailing list