[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
llvm-svn: 354652
diff --git a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
index 92840e5..8463ceb 100644
--- a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
+++ b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
@@ -366,7 +366,7 @@
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
diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
index 5ae7036..755bf34 100644
--- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
+++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
@@ -373,7 +373,7 @@
++NumDeadCases;
Changed = true;
if (--SuccessorsCount[Succ] == 0)
- DTU.deleteEdge(BB, Succ);
+ DTU.applyUpdates({{DominatorTree::Delete, BB, Succ}});
continue;
}
if (State == LazyValueInfo::True) {
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index f74f7e2..80b3cd7 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -1159,7 +1159,7 @@
ConstantInt::getFalse(CondCmp->getType());
ReplaceFoldableUses(CondCmp, CI);
}
- DTU->deleteEdgeRelaxed(BB, ToRemoveSucc);
+ DTU->applyUpdates({{DominatorTree::Delete, BB, ToRemoveSucc}});
return true;
}
@@ -1246,7 +1246,7 @@
RemoveSucc->removePredecessor(BB);
BranchInst::Create(KeepSucc, BI);
BI->eraseFromParent();
- DTU->deleteEdgeRelaxed(BB, RemoveSucc);
+ DTU->applyUpdates({{DominatorTree::Delete, BB, RemoveSucc}});
return true;
}
CurrentBB = CurrentPred;
diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
index 8238fad..c3ccfde 100644
--- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
@@ -678,7 +678,7 @@
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;
}
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index 6f49eae..0d6d102 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -721,7 +721,7 @@
UncondBranch->eraseFromParent();
if (DTU)
- DTU->deleteEdge(Pred, BB);
+ DTU->applyUpdates({{DominatorTree::Delete, Pred, BB}});
return cast<ReturnInst>(NewRet);
}
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 12c4ff1..3ef5494 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -128,7 +128,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 44f47bf..c3a0268 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -535,10 +535,9 @@
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.