[Mlir-commits] [mlir] [mlir][memref] Fix hoist-static-allocs option of buffer-results-to-out-params when function parameters are returned (PR #102093)
donald chen
llvmlistbot at llvm.org
Thu Aug 8 06:03:03 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)) {
----------------
cxy-1993 wrote:
We dont have to. My point is we dont need hoistStaticAllocs to eliminate copy.
https://github.com/llvm/llvm-project/pull/102093
More information about the Mlir-commits
mailing list