Author: Erich Keane Date: 2025-12-16T06:57:07-08:00 New Revision: 49f697971c643aae6a1d669e320986564f20b172
URL: https://github.com/llvm/llvm-project/commit/49f697971c643aae6a1d669e320986564f20b172 DIFF: https://github.com/llvm/llvm-project/commit/49f697971c643aae6a1d669e320986564f20b172.diff LOG: [OpenMP][CIR] Implement 'barrier' lowering (#172305) As my next patch showing how OMP lowering should work, here is a simple construct implementation. Best I can tell, the 'barrier' construct just results in a omp.barrier to be emitted into the IR. This is our first use of the omp dialect, though the dialect was already added in my last patch. Added: clang/test/CIR/CodeGenOpenMP/barrier.c Modified: clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp Removed: ################################################################################ diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp b/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp index 7fb2dd085acd3..08eeefcbeb151 100644 --- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp @@ -47,8 +47,9 @@ CIRGenFunction::emitOMPTaskyieldDirective(const OMPTaskyieldDirective &s) { } mlir::LogicalResult CIRGenFunction::emitOMPBarrierDirective(const OMPBarrierDirective &s) { - getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPBarrierDirective"); - return mlir::failure(); + mlir::omp::BarrierOp::create(builder, getLoc(s.getBeginLoc())); + assert(s.clauses().empty() && "omp barrier doesn't support clauses"); + return mlir::success(); } mlir::LogicalResult CIRGenFunction::emitOMPMetaDirective(const OMPMetaDirective &s) { diff --git a/clang/test/CIR/CodeGenOpenMP/barrier.c b/clang/test/CIR/CodeGenOpenMP/barrier.c new file mode 100644 index 0000000000000..83520b26dfe05 --- /dev/null +++ b/clang/test/CIR/CodeGenOpenMP/barrier.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fopenmp -emit-cir -fclangir %s -o - | FileCheck %s + +void before(void); +void after(void); + +void emit_simple_barrier() { + // CHECK: cir.func{{.*}}@emit_simple_barrier + before(); + // CHECK-NEXT: cir.call @before +#pragma omp barrier + // CHECK-NEXT: omp.barrier + after(); + // CHECK-NEXT: cir.call @after +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
