[Mlir-commits] [mlir] [MLIR] Prevent invalid IR from being passed outside of RemoveDeadValues (PR #121079)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Mon Dec 30 14:23:10 PST 2024
================
@@ -616,24 +714,28 @@ struct RemoveDeadValues : public impl::RemoveDeadValuesBase<RemoveDeadValues> {
void RemoveDeadValues::runOnOperation() {
auto &la = getAnalysis<RunLivenessAnalysis>();
Operation *module = getOperation();
+ DenseSet<Value> deletionSet;
+ CleanupList cl;
module->walk([&](Operation *op) {
if (auto funcOp = dyn_cast<FunctionOpInterface>(op)) {
- cleanFuncOp(funcOp, module, la);
+ cleanFuncOp(cl, deletionSet, funcOp, module, la);
} else if (auto regionBranchOp = dyn_cast<RegionBranchOpInterface>(op)) {
- cleanRegionBranchOp(regionBranchOp, la);
+ cleanRegionBranchOp(cl, deletionSet, regionBranchOp, la);
} else if (auto branchOp = dyn_cast<BranchOpInterface>(op)) {
- cleanBranchOp(branchOp, la);
+ cleanBranchOp(cl, deletionSet, branchOp, la);
} else if (op->hasTrait<::mlir::OpTrait::IsTerminator>()) {
// Nothing to do here because this is a terminator op and it should be
// honored with respect to its parent
} else if (isa<CallOpInterface>(op)) {
// Nothing to do because this op is associated with a function op and gets
// cleaned when the latter is cleaned.
} else {
- cleanSimpleOp(op, la);
+ cleanSimpleOp(cl, deletionSet, op, la);
----------------
banach-space wrote:
I would make `cl` and `deletionSet` as the trailing rather than the leading arguments. For example, in `leanFuncOp` the function to "clean" feels like the main argument.
Also, these method no longer "clean", so perhaps `clean` -> `process`? Or `analyse`?
https://github.com/llvm/llvm-project/pull/121079
More information about the Mlir-commits
mailing list