[Mlir-commits] [mlir] [mlir][reducer] Add eraseAllOpsInRegion function to reduction-tree pass (PR #185892)
lonely eagle
llvmlistbot at llvm.org
Sat Mar 14 07:30:50 PDT 2026
================
@@ -145,19 +145,59 @@ static LogicalResult findOptimal(ModuleOp module, Region ®ion,
return success();
}
+/// This function attempts to erase all operations within the region currently
+/// being processed.
+static LogicalResult eraseAllOpsInRegion(ModuleOp module, Region ®ion,
+ const Tester &test) {
+ std::pair<Tester::Interestingness, size_t> initStatus =
+ test.isInteresting(module);
+
+ // While exploring the reduction tree, we always branch from an interesting
+ // node. Thus the root node must be interesting.
+ if (initStatus.first != Tester::Interestingness::True)
+ return module.emitWarning() << "uninterested module will not be reduced";
+ llvm::SpecificBumpPtrAllocator<ReductionNode> allocator;
+
+ // Setting the ranges to {{0, 0}} will result in the deletion of all ops
+ // within the region.
+ std::vector<ReductionNode::Range> ranges{{0, 0}};
+ ReductionNode *root = allocator.Allocate();
+ new (root) ReductionNode(nullptr, ranges, allocator);
----------------
linuxlonelyeagle wrote:
Thank you for raising this. The point you’ve raised make sense to me. My previous implementation followed existing patterns in the codebase, and I hadn't considered the issue you pointed out. I have now implemented it using stack allocation.❤️
https://github.com/llvm/llvm-project/pull/185892
More information about the Mlir-commits
mailing list