[clang] [CIR][OpenMP] Lowering for the private clause for scalar local variables (PR #245430)

Steffen Larsen via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 30 00:35:03 PST 2026


================
@@ -123,6 +124,20 @@ emitParallelOp(CIRGenFunction &cgf, const DirectiveTy &s,
     parallelOp.setCombined(true);
 
   mlir::Block &block = parallelOp.getRegion().emplaceBlock();
+
+  for (auto varAddr : clauseOps.privateVars)
+    block.addArgument(varAddr.getType(), varAddr.getLoc());
+
+  llvm::SmallVector<std::unique_ptr<CIRGenFunction::DeclMapRevertingRAII>>
----------------
steffenlarsen wrote:

I see that `unique_ptr` adds the extra safety of not unintentionally copying the RAII object, but having to both allocate room for the pointers and then having to allocate each RAII object is unnecessary work.

I think a better solution is to use

```suggestion
  llvm::SmallVector<CIRGenFunction::DeclMapRevertingRAII>
```

then use `emplace_back` in the loop. We could then consider a separate patch that deletes the copy and move ctors of `DeclMapRevertingRAII`.

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


More information about the cfe-commits mailing list