[Mlir-commits] [mlir] 230d757 - [mlir][reducer] make opt-reduction pass clone topOp after check (NFC) (#189356)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Apr 4 07:08:40 PDT 2026
Author: lonely eagle
Date: 2026-04-04T22:08:34+08:00
New Revision: 230d757a134b3a1c144db2a9bad2a91e3b7f438e
URL: https://github.com/llvm/llvm-project/commit/230d757a134b3a1c144db2a9bad2a91e3b7f438e
DIFF: https://github.com/llvm/llvm-project/commit/230d757a134b3a1c144db2a9bad2a91e3b7f438e.diff
LOG: [mlir][reducer] make opt-reduction pass clone topOp after check (NFC) (#189356)
To avoid potential memory leaks, this PR defers the ModuleOp cloning
until after the verification check. If the check fails, the
moduleVariant might not be properly deallocated(original
implementation), leading to a memory leak. Therefore, this PR ensures
that the clone operation is only performed after a successful check. It
is part of https://github.com/llvm/llvm-project/pull/189353.
Added:
Modified:
mlir/lib/Reducer/OptReductionPass.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Reducer/OptReductionPass.cpp b/mlir/lib/Reducer/OptReductionPass.cpp
index 255df1ca092af..62d05c37bfab1 100644
--- a/mlir/lib/Reducer/OptReductionPass.cpp
+++ b/mlir/lib/Reducer/OptReductionPass.cpp
@@ -45,9 +45,7 @@ void OptReductionPass::runOnOperation() {
LDBG() << "\nOptimization Reduction pass: ";
Tester test(testerName, testerArgs);
-
Operation *topOp = this->getOperation();
- Operation *topOpVariant = topOp->clone();
PassManager passManager(topOp->getName());
if (failed(parsePassPipeline(optPass, passManager))) {
@@ -60,6 +58,7 @@ void OptReductionPass::runOnOperation() {
topOp->emitError() << "\nthe original input is not interested";
return signalPassFailure();
}
+ Operation *topOpVariant = topOp->clone();
LogicalResult pipelineResult = passManager.run(topOpVariant);
if (failed(pipelineResult)) {
More information about the Mlir-commits
mailing list