Skip to content

Commit 0b2a626

Browse files
committed
Revert "Comment SimplifyCFG JumpThreadingCost."
This reverts commit 7a1065c.
1 parent 50032a6 commit 0b2a626

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lib/SILOptimizer/Transforms/SimplifyCFG.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,8 @@ class SimplifyCFG {
8383
// this set may or may not still be LoopHeaders.
8484
// (ultimately this can be used to eliminate findLoopHeaders)
8585
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.
9388
llvm::SmallDenseMap<SILBasicBlock *, int, 8> JumpThreadingCost;
9489

9590
// Dominance and post-dominance info for the current function
@@ -323,8 +318,8 @@ bool SimplifyCFG::threadEdge(const ThreadInfo &ti) {
323318
return false;
324319

325320
Cloner.cloneBranchTarget(SrcTerm);
326-
JumpThreadingCost[Cloner.getNewBB()] =
327-
JumpThreadingCost[SrcTerm->getDestBB()];
321+
JumpThreadingCost[Cloner.getNewBB()] = JumpThreadingCost[SrcTerm->getDestBB()];
322+
328323

329324
// We have copied the threaded block into the edge.
330325
auto *clonedSrc = Cloner.getNewBB();
@@ -1095,7 +1090,7 @@ bool SimplifyCFG::tryJumpThreading(BranchInst *BI) {
10951090
}
10961091
}
10971092
}
1098-
// Deduct the prior cost of cloning these blocks (initially zero).
1093+
10991094
ThreadingBudget -= JumpThreadingCost[SrcBB];
11001095
ThreadingBudget -= JumpThreadingCost[DestBB];
11011096

@@ -1131,7 +1126,6 @@ bool SimplifyCFG::tryJumpThreading(BranchInst *BI) {
11311126
LLVM_DEBUG(llvm::dbgs() << "jump thread from bb" << SrcBB->getDebugID()
11321127
<< " to bb" << DestBB->getDebugID() << '\n');
11331128

1134-
// Accumulate the cost of cloning the block to avoid indefinite cloning.
11351129
JumpThreadingCost[DestBB] += copyCosts;
11361130

11371131
// Duplicate the destination block into this one, rewriting uses of the BBArgs
@@ -1140,8 +1134,7 @@ bool SimplifyCFG::tryJumpThreading(BranchInst *BI) {
11401134
Cloner.updateSSAAfterCloning();
11411135

11421136
// 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.
1137+
// loop by cloning the cloned block again.
11451138
JumpThreadingCost[Cloner.getNewBB()] += copyCosts;
11461139

11471140
// Once all the instructions are copied, we can nuke BI itself. We also add

0 commit comments

Comments
 (0)