[flang-commits] [flang] [mlir] [OpenACC] add acc::FirstprivateSaveOp (PR #211011)

Scott Manley via flang-commits flang-commits at lists.llvm.org
Wed Jul 22 07:59:36 PDT 2026


================
@@ -318,6 +319,17 @@ LogicalResult ACCRecipeMaterialization::materialize(
     Region &copyRegion = recipe.getCopyRegion();
     setLocation(copyRegion, loc);
     acc::cloneACCRegionInto(&copyRegion, block, std::next(ip), mapping, {});
+
+    // Create a temporary acc.firstprivate_save op to keep the value live-out
+    // until after other passes have determined it is truly firstprivate.
+    b.setInsertionPoint(accOp.getBody().getTerminator());
+    auto ptrLikeType = dyn_cast<acc::PointerLikeType>(alloca.getType());
+    assert(ptrLikeType && "alloca must be a pointer-like type");
+    auto xTyped = cast<TypedValue<acc::PointerLikeType>>(alloca);
+    assert(xTyped && "alloca must be a typed value");
+    auto loadOp = ptrLikeType.genLoad(b, op.getLoc(), xTyped, {});
----------------
rscottmanley wrote:

This is a good point. Ugh, this sort of suggests we need a "save" recipe.

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


More information about the flang-commits mailing list