[llvm] r354652 - [DTU] Deprecate insertEdge*/deleteEdge*

Chijun Sima via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 21 21:41:43 PST 2019


Author: sima
Date: Thu Feb 21 21:41:43 2019
New Revision: 354652

URL: http://llvm.org/viewvc/llvm-project?rev=354652&view=rev
Log:
[DTU] Deprecate insertEdge*/deleteEdge*

Summary: This patch converts all existing `insertEdge*/deleteEdge*` to `applyUpdates` and marks `insertEdge*/deleteEdge*` as deprecated.

Reviewers: kuhar, brzycki

Reviewed By: kuhar, brzycki

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58443

Modified:
    llvm/trunk/include/llvm/Analysis/DomTreeUpdater.h
    llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
    llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
    llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
    llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp
    llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
    llvm/trunk/lib/Transforms/Utils/Local.cpp
    llvm/trunk/lib/Transforms/Utils/LoopUtils.cpp
    llvm/trunk/unittests/Analysis/DomTreeUpdaterTest.cpp

Modified: llvm/trunk/include/llvm/Analysis/DomTreeUpdater.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DomTreeUpdater.h?rev=354652&r1=354651&r2=354652&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/DomTreeUpdater.h (original)
+++ llvm/trunk/include/llvm/Analysis/DomTreeUpdater.h Thu Feb 21 21:41:43 2019
@@ -136,7 +136,8 @@ public:
   /// DEBUG mode. CAUTION! This function has to be called *after* making the
   /// update on the actual CFG. It is illegal to submit any update that has
   /// already been applied. }
-  void insertEdge(BasicBlock *From, BasicBlock *To);
+  LLVM_ATTRIBUTE_DEPRECATED(void insertEdge(BasicBlock *From, BasicBlock *To),
+                            "Use applyUpdates() instead.");
 
   /// \deprecated {Submit an edge insertion to all available trees.
   /// Under either Strategy, an invalid update will be discard silently.
@@ -146,7 +147,9 @@ public:
   /// want to discard an invalid update.
   /// CAUTION! It is illegal to submit any update that has already been
   /// submitted. }
-  void insertEdgeRelaxed(BasicBlock *From, BasicBlock *To);
+  LLVM_ATTRIBUTE_DEPRECATED(void insertEdgeRelaxed(BasicBlock *From,
+                                                   BasicBlock *To),
+                            "Use applyUpdates() instead.");
 
   /// \deprecated { Submit an edge deletion to all available trees. The Eager
   /// Strategy flushes this update immediately while the Lazy Strategy queues
@@ -155,7 +158,8 @@ public:
   /// CAUTION! This function has to be called *after* making the update on the
   /// actual CFG. It is illegal to submit any update that has already been
   /// submitted. }
-  void deleteEdge(BasicBlock *From, BasicBlock *To);
+  LLVM_ATTRIBUTE_DEPRECATED(void deleteEdge(BasicBlock *From, BasicBlock *To),
+                            "Use applyUpdates() instead.");
 
   /// \deprecated { Submit an edge deletion to all available trees.
   /// Under either Strategy, an invalid update will be discard silently.
@@ -165,7 +169,9 @@ public:
   /// want to discard an invalid update.
   /// CAUTION! It is illegal to submit any update that has already been
   /// submitted. }
-  void deleteEdgeRelaxed(BasicBlock *From, BasicBlock *To);
+  LLVM_ATTRIBUTE_DEPRECATED(void deleteEdgeRelaxed(BasicBlock *From,
+                                                   BasicBlock *To),
+                            "Use applyUpdates() instead.");
 
   /// Delete DelBB. DelBB will be removed from its Parent and
   /// erased from available trees if it exists and finally get deleted.

Modified: llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp?rev=354652&r1=354651&r2=354652&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp Thu Feb 21 21:41:43 2019
@@ -366,7 +366,7 @@ static void splitCallSite(
     assert(Splits.size() == 2 && "Expected exactly 2 splits!");
     for (unsigned i = 0; i < Splits.size(); i++) {
       Splits[i]->getTerminator()->eraseFromParent();
-      DTU.deleteEdge(Splits[i], TailBB);
+      DTU.applyUpdates({{DominatorTree::Delete, Splits[i], TailBB}});
     }
 
     // Erase the tail block once done with musttail patching

Modified: llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp?rev=354652&r1=354651&r2=354652&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp Thu Feb 21 21:41:43 2019
@@ -373,7 +373,7 @@ static bool processSwitch(SwitchInst *SI
       ++NumDeadCases;
       Changed = true;
       if (--SuccessorsCount[Succ] == 0)
-        DTU.deleteEdge(BB, Succ);
+        DTU.applyUpdates({{DominatorTree::Delete, BB, Succ}});
       continue;
     }
     if (State == LazyValueInfo::True) {

Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=354652&r1=354651&r2=354652&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Thu Feb 21 21:41:43 2019
@@ -1159,7 +1159,7 @@ bool JumpThreadingPass::ProcessBlock(Bas
             ConstantInt::getFalse(CondCmp->getType());
           ReplaceFoldableUses(CondCmp, CI);
         }
-        DTU->deleteEdgeRelaxed(BB, ToRemoveSucc);
+        DTU->applyUpdates({{DominatorTree::Delete, BB, ToRemoveSucc}});
         return true;
       }
 
@@ -1246,7 +1246,7 @@ bool JumpThreadingPass::ProcessImpliedCo
       RemoveSucc->removePredecessor(BB);
       BranchInst::Create(KeepSucc, BI);
       BI->eraseFromParent();
-      DTU->deleteEdgeRelaxed(BB, RemoveSucc);
+      DTU->applyUpdates({{DominatorTree::Delete, BB, RemoveSucc}});
       return true;
     }
     CurrentBB = CurrentPred;

Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=354652&r1=354651&r2=354652&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Thu Feb 21 21:41:43 2019
@@ -678,7 +678,7 @@ static bool eliminateRecursiveTailCall(
 
   BB->getInstList().erase(Ret);  // Remove return.
   BB->getInstList().erase(CI);   // Remove call.
-  DTU.insertEdge(BB, OldEntry);
+  DTU.applyUpdates({{DominatorTree::Insert, BB, OldEntry}});
   ++NumEliminated;
   return true;
 }

Modified: llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp?rev=354652&r1=354651&r2=354652&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Thu Feb 21 21:41:43 2019
@@ -721,7 +721,7 @@ ReturnInst *llvm::FoldReturnIntoUncondBr
   UncondBranch->eraseFromParent();
 
   if (DTU)
-    DTU->deleteEdge(Pred, BB);
+    DTU->applyUpdates({{DominatorTree::Delete, Pred, BB}});
 
   return cast<ReturnInst>(NewRet);
 }

Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=354652&r1=354651&r2=354652&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Thu Feb 21 21:41:43 2019
@@ -128,7 +128,8 @@ bool llvm::ConstantFoldTerminator(BasicB
       Builder.CreateBr(Destination);
       BI->eraseFromParent();
       if (DTU)
-        DTU->deleteEdgeRelaxed(BB, OldDest);
+        DTU->applyUpdates({{DominatorTree::Delete, BB, OldDest}},
+                          /*ForceRemoveDuplicates*/ true);
       return true;
     }
 
@@ -204,7 +205,8 @@ bool llvm::ConstantFoldTerminator(BasicB
         i = SI->removeCase(i);
         e = SI->case_end();
         if (DTU)
-          DTU->deleteEdgeRelaxed(ParentBB, DefaultDest);
+          DTU->applyUpdates({{DominatorTree::Delete, ParentBB, DefaultDest}},
+                            /*ForceRemoveDuplicates*/ true);
         continue;
       }
 
@@ -664,7 +666,8 @@ void llvm::RemovePredecessorAndSimplify(
     if (PhiIt != OldPhiIt) PhiIt = &BB->front();
   }
   if (DTU)
-    DTU->deleteEdgeRelaxed(Pred, BB);
+    DTU->applyUpdates({{DominatorTree::Delete, Pred, BB}},
+                      /*ForceRemoveDuplicates*/ true);
 }
 
 /// MergeBasicBlockIntoOnlyPred - DestBB is a block with one predecessor and its
@@ -1967,7 +1970,8 @@ static void changeToCall(InvokeInst *II,
   UnwindDestBB->removePredecessor(BB);
   II->eraseFromParent();
   if (DTU)
-    DTU->deleteEdgeRelaxed(BB, UnwindDestBB);
+    DTU->applyUpdates({{DominatorTree::Delete, BB, UnwindDestBB}},
+                      /*ForceRemoveDuplicates*/ true);
 }
 
 BasicBlock *llvm::changeToInvokeAndSplitBasicBlock(CallInst *CI,
@@ -2114,7 +2118,8 @@ static bool markAliveBlocks(Function &F,
           UnwindDestBB->removePredecessor(II->getParent());
           II->eraseFromParent();
           if (DTU)
-            DTU->deleteEdgeRelaxed(BB, UnwindDestBB);
+            DTU->applyUpdates({{DominatorTree::Delete, BB, UnwindDestBB}},
+                              /*ForceRemoveDuplicates*/ true);
         } else
           changeToCall(II, DTU);
         Changed = true;
@@ -2203,7 +2208,8 @@ void llvm::removeUnwindEdge(BasicBlock *
   TI->replaceAllUsesWith(NewTI);
   TI->eraseFromParent();
   if (DTU)
-    DTU->deleteEdgeRelaxed(BB, UnwindDest);
+    DTU->applyUpdates({{DominatorTree::Delete, BB, UnwindDest}},
+                      /*ForceRemoveDuplicates*/ true);
 }
 
 /// removeUnreachableBlocks - Remove blocks that are not reachable, even

Modified: llvm/trunk/lib/Transforms/Utils/LoopUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUtils.cpp?rev=354652&r1=354651&r2=354652&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopUtils.cpp Thu Feb 21 21:41:43 2019
@@ -535,10 +535,9 @@ void llvm::deleteDeadLoop(Loop *L, Domin
   DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
   if (DT) {
     // Update the dominator tree by informing it about the new edge from the
-    // preheader to the exit.
-    DTU.insertEdge(Preheader, ExitBlock);
-    // Inform the dominator tree about the removed edge.
-    DTU.deleteEdge(Preheader, L->getHeader());
+    // preheader to the exit and the removed edge.
+    DTU.applyUpdates({{DominatorTree::Insert, Preheader, ExitBlock},
+                      {DominatorTree::Delete, Preheader, L->getHeader()}});
   }
 
   // Use a map to unique and a vector to guarantee deterministic ordering.

Modified: llvm/trunk/unittests/Analysis/DomTreeUpdaterTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/DomTreeUpdaterTest.cpp?rev=354652&r1=354651&r2=354652&view=diff
==============================================================================
--- llvm/trunk/unittests/Analysis/DomTreeUpdaterTest.cpp (original)
+++ llvm/trunk/unittests/Analysis/DomTreeUpdaterTest.cpp Thu Feb 21 21:41:43 2019
@@ -71,8 +71,9 @@ TEST(DomTreeUpdater, EagerUpdateBasicOpe
   SwitchInst *SI = dyn_cast<SwitchInst>(BB0->getTerminator());
   ASSERT_NE(SI, nullptr) << "Couldn't get SwitchInst.";
 
-  DTU.insertEdgeRelaxed(BB0, BB0);
-  DTU.deleteEdgeRelaxed(BB0, BB0);
+  DTU.applyUpdates(
+      {{DominatorTree::Insert, BB0, BB0}, {DominatorTree::Delete, BB0, BB0}},
+      /*ForceRemoveDuplicates*/ true);
 
   // Delete edge bb0 -> bb3 and push the update twice to verify duplicate
   // entries are discarded.
@@ -105,9 +106,10 @@ TEST(DomTreeUpdater, EagerUpdateBasicOpe
   ASSERT_FALSE(DTU.hasPendingUpdates());
 
   // Invalid Insert: no edge bb1 -> bb2 after change to bb0.
-  DTU.insertEdgeRelaxed(BB1, BB2);
   // Invalid Delete: edge exists bb0 -> bb1 after change to bb0.
-  DTU.deleteEdgeRelaxed(BB0, BB1);
+  DTU.applyUpdates(
+      {{DominatorTree::Insert, BB1, BB2}, {DominatorTree::Delete, BB0, BB1}},
+      /*ForceRemoveDuplicates*/ true);
 
   // DTU working with Eager UpdateStrategy does not need to flush.
   ASSERT_TRUE(DT.verify());
@@ -182,7 +184,8 @@ TEST(DomTreeUpdater, EagerUpdateReplaceE
   EXPECT_EQ(F->begin()->getName(), NewEntry->getName());
   EXPECT_TRUE(&F->getEntryBlock() == NewEntry);
 
-  DTU.insertEdgeRelaxed(NewEntry, BB0);
+  DTU.applyUpdates({{DominatorTree::Insert, NewEntry, BB0}},
+                   /*ForceRemoveDuplicates*/ true);
 
   // Changing the Entry BB requires a full recalculation of DomTree.
   DTU.recalculate(*F);
@@ -251,7 +254,7 @@ TEST(DomTreeUpdater, LazyUpdateDTBasicOp
   BasicBlock *BB3 = &*FI++;
 
   // Test discards of self-domination update.
-  DTU.deleteEdge(BB0, BB0);
+  DTU.applyUpdates({{DominatorTree::Delete, BB0, BB0}});
   ASSERT_FALSE(DTU.hasPendingDomTreeUpdates());
 
   // Delete edge bb0 -> bb3 and push the update twice to verify duplicate
@@ -358,8 +361,10 @@ TEST(DomTreeUpdater, LazyUpdateDTInherit
   //   +-> succ
   //
   // While the final CFG form is functionally identical the updates to
-  // DTU are not. In the first case we must have DTU.insertEdge(Pred1, Succ)
-  // while in the latter case we must *NOT* have DTU.insertEdge(Pred1, Succ).
+  // DTU are not. In the first case we must have
+  // DTU.applyUpdates({{DominatorTree::Insert, Pred1, Succ}}) while in the
+  // latter case we must *NOT* have DTU.applyUpdates({{DominatorTree::Insert,
+  // Pred1, Succ}}).
 
   // CFG Change: bb0 now only has bb0 -> bb1 and bb0 -> bb3. We are preparing to
   // remove bb2.
@@ -412,9 +417,9 @@ TEST(DomTreeUpdater, LazyUpdateDTInherit
   ASSERT_TRUE(isa<UnreachableInst>(BB1->getTerminator()));
   EXPECT_EQ(BB1->getParent(), F);
 
-  // Update the DTU. In this case we don't call DTU.insertEdge(BB0, BB3) because
-  // the edge previously existed at the start of this test when DT was first
-  // created.
+  // Update the DTU. In this case we don't submit {DominatorTree::Insert, BB0,
+  // BB3} because the edge previously existed at the start of this test when DT
+  // was first created.
   Updates.push_back({DominatorTree::Delete, BB0, BB1});
   Updates.push_back({DominatorTree::Delete, BB1, BB3});
 
@@ -467,7 +472,7 @@ TEST(DomTreeUpdater, LazyUpdateBasicOper
   BasicBlock *BB2 = &*FI++;
   BasicBlock *BB3 = &*FI++;
   // Test discards of self-domination update.
-  DTU.deleteEdge(BB0, BB0);
+  DTU.applyUpdates({{DominatorTree::Delete, BB0, BB0}});
 
   // Delete edge bb0 -> bb3 and push the update twice to verify duplicate
   // entries are discarded.
@@ -558,7 +563,7 @@ TEST(DomTreeUpdater, LazyUpdateReplaceEn
   // Insert the new edge between new_entry -> bb0. Without this the
   // recalculate() call below will not actually recalculate the DT as there
   // are no changes pending and no blocks deleted.
-  DTU.insertEdge(NewEntry, BB0);
+  DTU.applyUpdates({{DominatorTree::Insert, NewEntry, BB0}});
 
   // Changing the Entry BB requires a full recalculation.
   DTU.recalculate(*F);




More information about the llvm-commits mailing list