[Mlir-commits] [mlir] [mlir][memref] Fix hoist-static-allocs option of buffer-results-to-out-params when function parameters are returned (PR #102093)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Aug 6 06:30:20 PDT 2024
================
@@ -120,10 +128,15 @@ static LogicalResult updateReturnOps(func::FuncOp func,
}
OpBuilder builder(op);
for (auto [orig, arg] : llvm::zip(copyIntoOutParams, appendedEntryArgs)) {
- if (hoistStaticAllocs && isa<memref::AllocOp>(orig.getDefiningOp()) &&
- mlir::cast<MemRefType>(orig.getType()).hasStaticShape()) {
+ bool mayHoistStaticAlloc =
+ hoistStaticAllocs &&
+ mlir::cast<MemRefType>(orig.getType()).hasStaticShape();
+ if (mayHoistStaticAlloc &&
+ isa_and_nonnull<memref::AllocOp>(orig.getDefiningOp())) {
orig.replaceAllUsesWith(arg);
orig.getDefiningOp()->erase();
+ } else if (mayHoistStaticAlloc && isFunctionArgument(orig)) {
----------------
Menooker wrote:
It indeed changes the behavior of the program. It is not sure to me what is the expected behavior of this pass without `hoistStaticAllocs`, if we return the memref from an arg. If we should copy the data from arg to arg?
https://github.com/llvm/llvm-project/pull/102093
More information about the Mlir-commits
mailing list