[clang] [CIR][OpenMP] Add support for combined target parallel directives (PR #207019)

Sergio Afonso via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 16 05:30:44 PDT 2026


================
@@ -48,29 +70,35 @@ CIRGenFunction::emitOMPParallelDirective(const OMPParallelDirective &s) {
 
   auto parallelOp = mlir::omp::ParallelOp::create(builder, begin, clauseOps);
 
-  {
-    mlir::Block &block = parallelOp.getRegion().emplaceBlock();
-    mlir::OpBuilder::InsertionGuard guardCase(builder);
-    builder.setInsertionPointToEnd(&block);
+  mlir::Block &block = parallelOp.getRegion().emplaceBlock();
+  mlir::OpBuilder::InsertionGuard guard(builder);
+  builder.setInsertionPointToEnd(&block);
 
-    LexicalScope ls{*this, begin, builder.getInsertionBlock()};
+  CIRGenFunction::LexicalScope ls{cgf, begin, builder.getInsertionBlock()};
+
+  if (s.hasCancel())
+    cgm.errorNYI(s.getBeginLoc(), "OpenMP Parallel with Cancel");
----------------
skatrak wrote:

I just noticed that `cgm.errorNYI` doesn't immediately exit the application, unlike Flang's `TODO`. This means that both this and `OpenMPClauseEmitter::emitNYI` emit errors and then continue normally. I think the right thing to do is to make the latter return an `mlir::LogicalResult` and handle it properly when calling it:
```c++
if (failed(ce.emitNYI</*supported=*/...>(/*nyi=*/OpenMPClauseList<...>{}...)))
  return mlir::failure();
```
And here:
```suggestion
    return cgm.errorNYI(s.getBeginLoc(), "OpenMP Parallel with Cancel");
```

https://github.com/llvm/llvm-project/pull/207019


More information about the cfe-commits mailing list