[llvm] [DomTreeUpdater] Move critical edge splitting code to updater (PR #115111)
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 11:31:46 PST 2024
================
@@ -347,6 +389,131 @@ void GenericDomTreeUpdater<DerivedT, DomTreeT,
PendPDTUpdateIndex -= dropIndex;
}
+template <typename DerivedT, typename DomTreeT, typename PostDomTreeT>
+void GenericDomTreeUpdater<DerivedT, DomTreeT, PostDomTreeT>::
+ splitDTCriticalEdges(ArrayRef<CriticalEdge> Edges) {
+ // Bail out early if there is nothing to do.
+ if (Edges.empty())
+ return;
+
+ // Remember all the basic blocks that are inserted during
+ // edge splitting.
+ // Invariant: NewBBs == all the basic blocks contained in the NewBB
+ // field of all the elements of Edges.
+ // I.e., forall elt in Edges, it exists BB in NewBBs
+ // such as BB == elt.NewBB.
+ SmallSet<BasicBlockT *, 32> NewBBs;
+ for (auto &Edge : Edges)
+ NewBBs.insert(Edge.NewBB);
+ // For each element in Edges, remember whether or not element
+ // is the new immediate domminator of its successor. The mapping is done by
+ // index, i.e., the information for the ith element of Edges is
+ // the ith element of IsNewIDom.
+ SmallBitVector IsNewIDom(Edges.size(), true);
+ size_t Idx = 0;
+
+ // Collect all the dominance properties info, before invalidating
+ // the underlying DT.
+ for (const auto &Edge : Edges) {
+ // Update dominator information.
+ if (DT) {
----------------
kuhar wrote:
Why isn't this check outside of the loop?
https://github.com/llvm/llvm-project/pull/115111
More information about the llvm-commits
mailing list