[flang-commits] [flang] [flang][OpenACC] Release declare-create allocatable on deallocate (PR #220541)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Wed Sep 2 08:14:00 PDT 2026
================
@@ -4090,26 +4090,26 @@ static void createDeclareDeallocFunc(mlir::OpBuilder &modBuilder,
std::stringstream asFortran;
asFortran << Fortran::lower::mangle::demangleName(globalOp.getSymName());
- std::stringstream postDeallocFuncName;
- postDeallocFuncName << globalOp.getSymName().str()
- << Fortran::lower::declarePostDeallocSuffix.str();
- auto postDeallocOp =
- createDeclareFunc(modBuilder, builder, loc, postDeallocFuncName.str(),
+ // No post-dealloc recipe: it would run after the host storage is freed,
+ // when the descriptor no longer holds the address the mapping is keyed on.
+ std::stringstream preDeallocFuncName;
+ preDeallocFuncName << globalOp.getSymName().str()
+ << Fortran::lower::declarePreDeallocSuffix.str();
+ auto preDeallocOp =
+ createDeclareFunc(modBuilder, builder, loc, preDeallocFuncName.str(),
/*argsTy=*/{}, /*locs=*/{}, /*linkable=*/true);
-
fir::AddrOfOp addrOp = fir::AddrOfOp::create(
builder, loc, fir::ReferenceType::get(globalOp.getType()),
globalOp.getSymbol());
llvm::SmallVector<mlir::Value> bounds;
- // End the structured declare region using declare_exit.
mlir::acc::GetDevicePtrOp descEntryOp =
createDataEntryOp<mlir::acc::GetDevicePtrOp>(
builder, loc, addrOp, asFortran, bounds,
- /*structured=*/false, /*implicit=*/true, clause, addrOp.getType(),
+ /*structured=*/false, /*implicit=*/false, clause, addrOp.getType(),
----------------
vzakhari wrote:
Why `true` becomes `false`?
https://github.com/llvm/llvm-project/pull/220541
More information about the flang-commits
mailing list