diff options
Diffstat (limited to 'include/llvm/Support/GenericDomTree.h')
| -rw-r--r-- | include/llvm/Support/GenericDomTree.h | 58 |
1 files changed, 19 insertions, 39 deletions
diff --git a/include/llvm/Support/GenericDomTree.h b/include/llvm/Support/GenericDomTree.h index c716e4a4d300..b3018bac310a 100644 --- a/include/llvm/Support/GenericDomTree.h +++ b/include/llvm/Support/GenericDomTree.h @@ -24,6 +24,14 @@ #ifndef LLVM_SUPPORT_GENERICDOMTREE_H #define LLVM_SUPPORT_GENERICDOMTREE_H +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/Support/CFGUpdate.h" +#include "llvm/Support/raw_ostream.h" #include <algorithm> #include <cassert> #include <cstddef> @@ -32,13 +40,6 @@ #include <type_traits> #include <utility> #include <vector> -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/GraphTraits.h" -#include "llvm/ADT/PointerIntPair.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/Support/raw_ostream.h" namespace llvm { @@ -192,6 +193,10 @@ template <typename DomTreeT> void Calculate(DomTreeT &DT); template <typename DomTreeT> +void CalculateWithUpdates(DomTreeT &DT, + ArrayRef<typename DomTreeT::UpdateType> Updates); + +template <typename DomTreeT> void InsertEdge(DomTreeT &DT, typename DomTreeT::NodePtr From, typename DomTreeT::NodePtr To); @@ -199,36 +204,6 @@ template <typename DomTreeT> void DeleteEdge(DomTreeT &DT, typename DomTreeT::NodePtr From, typename DomTreeT::NodePtr To); -// UpdateKind and Update are used by the batch update API and it's easiest to -// define them here. -enum class UpdateKind : unsigned char { Insert, Delete }; - -template <typename NodePtr> -struct Update { - using NodeKindPair = PointerIntPair<NodePtr, 1, UpdateKind>; - - NodePtr From; - NodeKindPair ToAndKind; - - Update(UpdateKind Kind, NodePtr From, NodePtr To) - : From(From), ToAndKind(To, Kind) {} - - UpdateKind getKind() const { return ToAndKind.getInt(); } - NodePtr getFrom() const { return From; } - NodePtr getTo() const { return ToAndKind.getPointer(); } - bool operator==(const Update &RHS) const { - return From == RHS.From && ToAndKind == RHS.ToAndKind; - } - - friend raw_ostream &operator<<(raw_ostream &OS, const Update &U) { - OS << (U.getKind() == UpdateKind::Insert ? "Insert " : "Delete "); - U.getFrom()->printAsOperand(OS, false); - OS << " -> "; - U.getTo()->printAsOperand(OS, false); - return OS; - } -}; - template <typename DomTreeT> void ApplyUpdates(DomTreeT &DT, ArrayRef<typename DomTreeT::UpdateType> Updates); @@ -254,8 +229,8 @@ class DominatorTreeBase { using ParentType = typename std::remove_pointer<ParentPtr>::type; static constexpr bool IsPostDominator = IsPostDom; - using UpdateType = DomTreeBuilder::Update<NodePtr>; - using UpdateKind = DomTreeBuilder::UpdateKind; + using UpdateType = cfg::Update<NodePtr>; + using UpdateKind = cfg::UpdateKind; static constexpr UpdateKind Insert = UpdateKind::Insert; static constexpr UpdateKind Delete = UpdateKind::Delete; @@ -759,6 +734,11 @@ public: DomTreeBuilder::Calculate(*this); } + void recalculate(ParentType &Func, ArrayRef<UpdateType> Updates) { + Parent = &Func; + DomTreeBuilder::CalculateWithUpdates(*this, Updates); + } + /// verify - checks if the tree is correct. There are 3 level of verification: /// - Full -- verifies if the tree is correct by making sure all the /// properties (including the parent and the sibling property) |
