[Mlir-commits] [mlir] [mlir] Add removeDomTree method to DominanceInfoBase (PR #192050)

lonely eagle llvmlistbot at llvm.org
Tue Apr 14 05:53:49 PDT 2026


https://github.com/linuxlonelyeagle created https://github.com/llvm/llvm-project/pull/192050

When a pass runs and marks markAnalysesPreserved<DominanceInfo, PostDominanceInfo>(), any deleted RegionOps that have associated dominator trees will keep those trees in memory until DominanceInfo is destructed. This PR introduces a removeDomTree method in DominanceInfoBase, allowing us to explicitly remove dominator trees in a timely manner.

>From ca71d6f35f2c2d2a3dd0e60a42a796fd1464eaec Mon Sep 17 00:00:00 2001
From: linuxlonelyeagle <2020382038 at qq.com>
Date: Tue, 14 Apr 2026 10:45:37 +0000
Subject: [PATCH] add removeDomTree method to DominanceInfoBase.

---
 mlir/include/mlir/IR/Dominance.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mlir/include/mlir/IR/Dominance.h b/mlir/include/mlir/IR/Dominance.h
index 9e1254c1dfe1e..5ec455b3ec4da 100644
--- a/mlir/include/mlir/IR/Dominance.h
+++ b/mlir/include/mlir/IR/Dominance.h
@@ -104,6 +104,13 @@ class DominanceInfoBase {
     return *getDominanceInfo(region, /*needsDomTree=*/true).getPointer();
   }
 
+  void removeDomTree(Region *region) {
+    if (dominanceInfos.contains(region)) {
+      delete dominanceInfos[region].getPointer();
+      dominanceInfos.erase(region);
+    }
+  };
+
 protected:
   using super = DominanceInfoBase<IsPostDom>;
 



More information about the Mlir-commits mailing list