@@ -83,13 +83,8 @@ class SimplifyCFG {
83
83
// this set may or may not still be LoopHeaders.
84
84
// (ultimately this can be used to eliminate findLoopHeaders)
85
85
SmallPtrSet<SILBasicBlock *, 4 > ClonedLoopHeaders;
86
- // The accumulated cost of jump threading per basic block. Initially
87
- // zero. Each clone increases the cost by ~ the number of copied instructions.
88
- // Effectively multiplying a block's cost is by the number of times it has
89
- // been cloned prevents any one block from being cloned indefinitely. Cloned
90
- // blocks inherit their original block's current cost to avoid indefinitely
91
- // optimizing the newly cloned blocks (primarily relevant for loops where the
92
- // number of predecessors can remain the same).
86
+ // The cost (~ number of copied instructions) of jump threading per basic
87
+ // block. Used to prevent infinite jump threading loops.
93
88
llvm::SmallDenseMap<SILBasicBlock *, int , 8 > JumpThreadingCost;
94
89
95
90
// Dominance and post-dominance info for the current function
@@ -323,8 +318,6 @@ bool SimplifyCFG::threadEdge(const ThreadInfo &ti) {
323
318
return false ;
324
319
325
320
Cloner.cloneBranchTarget (SrcTerm);
326
- JumpThreadingCost[Cloner.getNewBB ()] =
327
- JumpThreadingCost[SrcTerm->getDestBB ()];
328
321
329
322
// We have copied the threaded block into the edge.
330
323
auto *clonedSrc = Cloner.getNewBB ();
@@ -1095,7 +1088,7 @@ bool SimplifyCFG::tryJumpThreading(BranchInst *BI) {
1095
1088
}
1096
1089
}
1097
1090
}
1098
- // Deduct the prior cost of cloning these blocks (initially zero).
1091
+
1099
1092
ThreadingBudget -= JumpThreadingCost[SrcBB];
1100
1093
ThreadingBudget -= JumpThreadingCost[DestBB];
1101
1094
@@ -1131,19 +1124,13 @@ bool SimplifyCFG::tryJumpThreading(BranchInst *BI) {
1131
1124
LLVM_DEBUG (llvm::dbgs () << " jump thread from bb" << SrcBB->getDebugID ()
1132
1125
<< " to bb" << DestBB->getDebugID () << ' \n ' );
1133
1126
1134
- // Accumulate the cost of cloning the block to avoid indefinite cloning.
1135
1127
JumpThreadingCost[DestBB] += copyCosts;
1136
1128
1137
1129
// Duplicate the destination block into this one, rewriting uses of the BBArgs
1138
1130
// to use the branch arguments as we go.
1139
1131
Cloner.cloneBranchTarget (BI);
1140
1132
Cloner.updateSSAAfterCloning ();
1141
1133
1142
- // Also account the costs to the cloned DestBB, so the jump threading cannot
1143
- // loop by cloning the cloned block again. This is primarily relevant for
1144
- // loops where the number of predecessors might not decrease with each clone.
1145
- JumpThreadingCost[Cloner.getNewBB ()] += copyCosts;
1146
-
1147
1134
// Once all the instructions are copied, we can nuke BI itself. We also add
1148
1135
// the threaded and edge block to the worklist now that they (likely) can be
1149
1136
// simplified.
@@ -2886,8 +2873,6 @@ bool SimplifyCFG::tailDuplicateObjCMethodCallSuccessorBlocks() {
2886
2873
Cloner.cloneBranchTarget (Branch);
2887
2874
Cloner.updateSSAAfterCloning ();
2888
2875
2889
- JumpThreadingCost[Cloner.getNewBB ()] = JumpThreadingCost[DestBB];
2890
-
2891
2876
Changed = true ;
2892
2877
// Simplify the cloned block and continue tail duplicating through its new
2893
2878
// successors edges.
0 commit comments