Skip to content

Commit d98cc19

Browse files
committed
[DFAJumpThreading] Update domtree lazily
1 parent 958ec32 commit d98cc19

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class DFAJumpThreading {
158158
void
159159
unfoldSelectInstrs(DominatorTree *DT,
160160
const SmallVector<SelectInstToUnfold, 4> &SelectInsts) {
161-
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
161+
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
162162
SmallVector<SelectInstToUnfold, 4> Stack(SelectInsts);
163163

164164
while (!Stack.empty()) {
@@ -975,8 +975,6 @@ struct TransformDFA {
975975

976976
/// Transform each threading path to effectively jump thread the DFA.
977977
void createAllExitPaths() {
978-
DomTreeUpdater DTU(*DT, DomTreeUpdater::UpdateStrategy::Eager);
979-
980978
// Move the switch block to the end of the path, since it will be duplicated
981979
BasicBlock *SwitchBlock = SwitchPaths->getSwitchBlock();
982980
for (ThreadingPath &TPath : SwitchPaths->getThreadingPaths()) {
@@ -993,15 +991,18 @@ struct TransformDFA {
993991
SmallPtrSet<BasicBlock *, 16> BlocksToClean;
994992
BlocksToClean.insert_range(successors(SwitchBlock));
995993

996-
for (ThreadingPath &TPath : SwitchPaths->getThreadingPaths()) {
997-
createExitPath(NewDefs, TPath, DuplicateMap, BlocksToClean, &DTU);
998-
NumPaths++;
999-
}
994+
{
995+
DomTreeUpdater DTU(*DT, DomTreeUpdater::UpdateStrategy::Lazy);
996+
for (ThreadingPath &TPath : SwitchPaths->getThreadingPaths()) {
997+
createExitPath(NewDefs, TPath, DuplicateMap, BlocksToClean, &DTU);
998+
NumPaths++;
999+
}
10001000

1001-
// After all paths are cloned, now update the last successor of the cloned
1002-
// path so it skips over the switch statement
1003-
for (ThreadingPath &TPath : SwitchPaths->getThreadingPaths())
1004-
updateLastSuccessor(TPath, DuplicateMap, &DTU);
1001+
// After all paths are cloned, now update the last successor of the cloned
1002+
// path so it skips over the switch statement
1003+
for (ThreadingPath &TPath : SwitchPaths->getThreadingPaths())
1004+
updateLastSuccessor(TPath, DuplicateMap, &DTU);
1005+
}
10051006

10061007
// For each instruction that was cloned and used outside, update its uses
10071008
updateSSA(NewDefs);

0 commit comments

Comments
 (0)