llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangir

@llvm/pr-subscribers-clang

Author: Erich Keane (erichkeane)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/172305.diff


2 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp (+3-2) 
- (added) clang/test/CIR/CodeGenOpenMP/barrier.c (+14) 


``````````diff
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
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/172305
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to