[clang] [llvm] [mlir] [OpenMP] Preserve host capture lifetimes in frontend lowering (PR #218453)

Tomas Matheson via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 04:05:57 PDT 2026


================
@@ -1897,6 +1897,16 @@ hostParallelCallback(OpenMPIRBuilder *OMPIRBuilder, Function &OutlinedFn,
          "Expected at least tid and bounded tid as arguments");
   unsigned NumCapturedVars = OutlinedFn.arg_size() - /* tid & bounded tid */ 2;
 
+  // CodeExtractor packs all captures into a fresh structure owned by the
+  // caller. Only this argument exposes the structure to the outlined function,
+  // and the synchronous fork keeps it alive until all callbacks return. These
+  // attributes describe the structure, not the objects its fields point to.
+  if (NumCapturedVars) {
+    assert(NumCapturedVars == 1 && "Expected an aggregate capture argument");
+    OutlinedFn.addParamAttr(2, Attribute::NoAlias);
----------------
tommat01 wrote:

Done

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


More information about the llvm-commits mailing list