[clang] [OpenACC][CIR] Implement 'alloca copying' for private lowering (PR #161382)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 30 13:30:04 PDT 2025
================
@@ -125,14 +200,21 @@ mlir::Value OpenACCRecipeBuilderBase::makeBoundsAlloca(
mlir::Type eltTy = cgf.convertType(resultType);
cir::PointerType ptrTy = builder.getPointerTo(eltTy);
- builder.createAlloca(loc, ptrTy, eltTy, "openacc.init.bounds",
- cgf.getContext().getTypeAlignInChars(resultType),
- curSize);
-
- // TODO: OpenACC : At this point we should be copying the addresses of
- // each element of this to the last allocation. At the moment, that is
- // not yet implemented.
- cgf.cgm.errorNYI(exprRange, "OpenACC recipe alloca copying");
+ mlir::Value curAlloca = builder.createAlloca(
+ loc, ptrTy, eltTy, "openacc.init.bounds",
+ cgf.getContext().getTypeAlignInChars(resultType), curSize);
+
+ makeAllocaCopy(loc, ptrTy, cumulativeElts, eltsPerSubArray, lastAlloca,
+ curAlloca);
+ lastAlloca = curAlloca;
+ } else {
+ // In the case of an array, we just need to decay the pointer, so just do
+ // a zero-offset stride on the last alloca to decay it down an array
+ // level.
+ cir::ConstantOp constZero = builder.getConstInt(loc, itrTy, 0);
+ lastAlloca = builder.getArrayElement(
+ loc, loc, lastAlloca, cgf.convertType(resultType),
+ constZero.getResult(), /*shouldDecay=*/true);
----------------
andykaylor wrote:
```suggestion
constZero, /*shouldDecay=*/true);
```
https://github.com/llvm/llvm-project/pull/161382
More information about the cfe-commits
mailing list