[llvm] [DomTreeUpdater] Move critical edge splitting code to updater (PR #115111)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 04:14:47 PST 2024


================
@@ -250,12 +270,23 @@ void GenericDomTreeUpdater<DerivedT, DomTreeT,
     return;
 
   // Only apply updates not are applied by DomTree.
-  if (hasPendingDomTreeUpdates()) {
-    const auto I = PendUpdates.begin() + PendDTUpdateIndex;
+  while (hasPendingDomTreeUpdates()) {
+    auto I = PendUpdates.begin() + PendDTUpdateIndex;
     const auto E = PendUpdates.end();
     assert(I < E && "Iterator range invalid; there should be DomTree updates.");
-    DT->applyUpdates(ArrayRef<typename DomTreeT::UpdateType>(I, E));
-    PendDTUpdateIndex = PendUpdates.size();
+    if (!I->IsCriticalEdgeSplit) {
+      SmallVector<UpdateT, 32> NormalUpdates;
+      for (; I != E && !I->IsCriticalEdgeSplit; ++I)
+        NormalUpdates.push_back(I->Update);
+      DT->applyUpdates(NormalUpdates);
+      PendDTUpdateIndex += NormalUpdates.size();
+    } else {
+      SmallVector<CriticalEdge> CriticalEdges;
+      for (; I != E && I->IsCriticalEdgeSplit; ++I)
+        CriticalEdges.push_back(I->EdgeSplit);
+      splitDTCriticalEdges(CriticalEdges);
+      PendDTUpdateIndex += CriticalEdges.size();
+    }
----------------
paperchalice wrote:

Done. Reuse logic by adding a new template member function.

https://github.com/llvm/llvm-project/pull/115111


More information about the llvm-commits mailing list