Skip to content

Commit aca71ef

Browse files
committed
[DomTreeUpdater] Move flushing back into the derived classes
Calling a derived method from a base class destructor leaves you in a half-destroyed state. Sanitizers complain about that.
1 parent 5e1de27 commit aca71ef

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

llvm/include/llvm/Analysis/DomTreeUpdater.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class DomTreeUpdater
3838
GenericDomTreeUpdater<DomTreeUpdater, DominatorTree, PostDominatorTree>;
3939
using Base::Base;
4040

41+
~DomTreeUpdater() { flush(); }
42+
4143
///@{
4244
/// \name Mutation APIs
4345
///

llvm/include/llvm/Analysis/GenericDomTreeUpdater.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ class GenericDomTreeUpdater {
4848
UpdateStrategy Strategy_)
4949
: DT(DT_), PDT(PDT_), Strategy(Strategy_) {}
5050

51-
~GenericDomTreeUpdater() { flush(); }
51+
~GenericDomTreeUpdater() {
52+
// We cannot call into derived() here as it will already be destroyed.
53+
assert(!hasPendingUpdates() &&
54+
"Pending updates were not flushed by derived class.");
55+
}
5256

5357
/// Returns true if the current strategy is Lazy.
5458
bool isLazy() const { return Strategy == UpdateStrategy::Lazy; }

llvm/include/llvm/CodeGen/MachineDomTreeUpdater.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class MachineDomTreeUpdater
3333
MachinePostDominatorTree>;
3434
using Base::Base;
3535

36+
~MachineDomTreeUpdater() { flush(); }
37+
3638
///@{
3739
/// \name Mutation APIs
3840
///

0 commit comments

Comments
 (0)