[clang] [CIR][OpenMP] Add support for the OpenMP 'for' directive (PR #229256)

Jan Leyonberg via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 4 11:08:21 PST 2026


================
@@ -101,10 +102,32 @@ emitParallelOp(CIRGenFunction &cgf, const DirectiveTy &s,
          "reduction(task: ...) should already be rejected as NYI");
 
   mlir::LogicalResult res = emitBody();
+  ls.forceCleanup();
----------------
jsjodin wrote:

Scoping ls doesn't quite work: when a LexicalScope is destroyed it terminates the block with a cir.yield, which isn't valid inside an OpenMP region. forceCleanup() runs the cleanups without adding a terminator, so we can add the omp.terminator ourselves. To make it hard to forget, I moved the scope, forceCleanup() and terminator into one helper, emitOMPRegionBody, which all the OpenMP region ops can use.

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


More information about the cfe-commits mailing list