diff options
| -rw-r--r-- | mlir/include/mlir/IR/Dominance.h | 4 | ||||
| -rw-r--r-- | mlir/lib/IR/Dominance.cpp | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/mlir/include/mlir/IR/Dominance.h b/mlir/include/mlir/IR/Dominance.h index 30f5674..82bf34c 100644 --- a/mlir/include/mlir/IR/Dominance.h +++ b/mlir/include/mlir/IR/Dominance.h @@ -46,8 +46,8 @@ public: /// Invalidate dominance info. This can be used by clients that make major /// changes to the CFG and don't have a good way to update it. - void invalidate() { dominanceInfos.clear(); } - void invalidate(Region *region) { dominanceInfos.erase(region); } + void invalidate(); + void invalidate(Region *region); /// Finds the nearest common dominator block for the two given blocks a /// and b. If no common dominator can be found, this function will return diff --git a/mlir/lib/IR/Dominance.cpp b/mlir/lib/IR/Dominance.cpp index beb7f7b..2b138ae 100644 --- a/mlir/lib/IR/Dominance.cpp +++ b/mlir/lib/IR/Dominance.cpp @@ -34,6 +34,21 @@ DominanceInfoBase<IsPostDom>::~DominanceInfoBase() { delete entry.second.getPointer(); } +template <bool IsPostDom> void DominanceInfoBase<IsPostDom>::invalidate() { + for (auto entry : dominanceInfos) + delete entry.second.getPointer(); + dominanceInfos.clear(); +} + +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); + } +} + /// Return the dom tree and "hasSSADominance" bit for the given region. The /// DomTree will be null for single-block regions. This lazily constructs the /// DomTree on demand when needsDomTree=true. |
