[Mlir-commits] [mlir] [mlir] Add erase sub-region dominate tree logic in DominanceInfoBase::invalidate method (PR #192469)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Apr 16 07:49:52 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: lonely eagle (linuxlonelyeagle)
<details>
<summary>Changes</summary>
Fix the issue: a region may contain nested sub-regions. When we remove the dominate tree of a parent region, the dominate trees of its sub-regions should also be removed.
---
Full diff: https://github.com/llvm/llvm-project/pull/192469.diff
1 Files Affected:
- (modified) mlir/lib/IR/Dominance.cpp (+11-4)
``````````diff
diff --git a/mlir/lib/IR/Dominance.cpp b/mlir/lib/IR/Dominance.cpp
index 0e53b431b5d31..2ef0c35a13536 100644
--- a/mlir/lib/IR/Dominance.cpp
+++ b/mlir/lib/IR/Dominance.cpp
@@ -42,10 +42,17 @@ void DominanceInfoBase<IsPostDom>::invalidate() {
template <bool IsPostDom>
void DominanceInfoBase<IsPostDom>::invalidate(Region *region) {
- auto it = dominanceInfos.find(region);
- if (it != dominanceInfos.end()) {
- delete it->second.getPointer();
- dominanceInfos.erase(it);
+ SmallVector<Region *> regions = {region};
+ region->walk([&](Operation *op) {
+ for (Region &r : op->getRegions())
+ regions.push_back(&r);
+ });
+ for (Region *region : regions) {
+ auto it = dominanceInfos.find(region);
+ if (it != dominanceInfos.end()) {
+ delete it->second.getPointer();
+ dominanceInfos.erase(it);
+ }
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/192469
More information about the Mlir-commits
mailing list