[llvm] aca71ef - [DomTreeUpdater] Move flushing back into the derived classes
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 28 06:48:39 PDT 2024
Author: Benjamin Kramer
Date: 2024-06-28T15:46:57+02:00
New Revision: aca71efefe3d5907a1128566540d386d2aea8aa9
URL: https://github.com/llvm/llvm-project/commit/aca71efefe3d5907a1128566540d386d2aea8aa9
DIFF: https://github.com/llvm/llvm-project/commit/aca71efefe3d5907a1128566540d386d2aea8aa9.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/Analysis/DomTreeUpdater.h
llvm/include/llvm/Analysis/GenericDomTreeUpdater.h
llvm/include/llvm/CodeGen/MachineDomTreeUpdater.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/DomTreeUpdater.h b/llvm/include/llvm/Analysis/DomTreeUpdater.h
index 9ffd4948c1750..e07d2bf2b0df1 100644
--- a/llvm/include/llvm/Analysis/DomTreeUpdater.h
+++ b/llvm/include/llvm/Analysis/DomTreeUpdater.h
@@ -38,6 +38,8 @@ class DomTreeUpdater
GenericDomTreeUpdater<DomTreeUpdater, DominatorTree, PostDominatorTree>;
using Base::Base;
+ ~DomTreeUpdater() { flush(); }
+
///@{
/// \name Mutation APIs
///
diff --git a/llvm/include/llvm/Analysis/GenericDomTreeUpdater.h b/llvm/include/llvm/Analysis/GenericDomTreeUpdater.h
index 644230264bfe0..84ed882c6de84 100644
--- a/llvm/include/llvm/Analysis/GenericDomTreeUpdater.h
+++ b/llvm/include/llvm/Analysis/GenericDomTreeUpdater.h
@@ -48,7 +48,11 @@ class GenericDomTreeUpdater {
UpdateStrategy Strategy_)
: DT(DT_), PDT(PDT_), Strategy(Strategy_) {}
- ~GenericDomTreeUpdater() { flush(); }
+ ~GenericDomTreeUpdater() {
+ // We cannot call into derived() here as it will already be destroyed.
+ assert(!hasPendingUpdates() &&
+ "Pending updates were not flushed by derived class.");
+ }
/// Returns true if the current strategy is Lazy.
bool isLazy() const { return Strategy == UpdateStrategy::Lazy; }
diff --git a/llvm/include/llvm/CodeGen/MachineDomTreeUpdater.h b/llvm/include/llvm/CodeGen/MachineDomTreeUpdater.h
index e08b6b54c8e70..9e3971f0b9fce 100644
--- a/llvm/include/llvm/CodeGen/MachineDomTreeUpdater.h
+++ b/llvm/include/llvm/CodeGen/MachineDomTreeUpdater.h
@@ -33,6 +33,8 @@ class MachineDomTreeUpdater
MachinePostDominatorTree>;
using Base::Base;
+ ~MachineDomTreeUpdater() { flush(); }
+
///@{
/// \name Mutation APIs
///
More information about the llvm-commits
mailing list