Author: Alexey Bataev Date: 2021-03-31T12:58:24-07:00 New Revision: 66da4f6fc9c1cd2a63f089b9888729292f0709f8
URL: https://github.com/llvm/llvm-project/commit/66da4f6fc9c1cd2a63f089b9888729292f0709f8 DIFF: https://github.com/llvm/llvm-project/commit/66da4f6fc9c1cd2a63f089b9888729292f0709f8.diff LOG: [OPENMP]Fix PR48658: [OpenMP 5.0] Compiler crash when OpenMP atomic sync hints used. No need to consider hint clause kind as the main atomic clause kind at the codegen. Differential Revision: https://reviews.llvm.org/D99611 Added: Modified: clang/lib/CodeGen/CGStmtOpenMP.cpp clang/test/OpenMP/atomic_codegen.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 5373805f0e1ca..2858369896026 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -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; } diff --git a/clang/test/OpenMP/atomic_codegen.cpp b/clang/test/OpenMP/atomic_codegen.cpp index 47ab0b4e18043..ada47d44cc5d2 100644 --- a/clang/test/OpenMP/atomic_codegen.cpp +++ b/clang/test/OpenMP/atomic_codegen.cpp @@ -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]]) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits