mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-24 04:26:07 +00:00
[mlir][IR] Fix memory leak in DominanceInfo
Differential Revision: https://reviews.llvm.org/D154185
This commit is contained in:
parent
e4d6860d2d
commit
c487fe3967
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user