Skip to content

Commit 378b6d4

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents f8aff50 + ac56f03 commit 378b6d4

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

lib/SILOptimizer/Transforms/SimplifyCFG.cpp

Lines changed: 3 additions & 18 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,6 @@ bool SimplifyCFG::threadEdge(const ThreadInfo &ti) {
323318
return false;
324319

325320
Cloner.cloneBranchTarget(SrcTerm);
326-
JumpThreadingCost[Cloner.getNewBB()] =
327-
JumpThreadingCost[SrcTerm->getDestBB()];
328321

329322
// We have copied the threaded block into the edge.
330323
auto *clonedSrc = Cloner.getNewBB();
@@ -1095,7 +1088,7 @@ bool SimplifyCFG::tryJumpThreading(BranchInst *BI) {
10951088
}
10961089
}
10971090
}
1098-
// Deduct the prior cost of cloning these blocks (initially zero).
1091+
10991092
ThreadingBudget -= JumpThreadingCost[SrcBB];
11001093
ThreadingBudget -= JumpThreadingCost[DestBB];
11011094

@@ -1131,19 +1124,13 @@ bool SimplifyCFG::tryJumpThreading(BranchInst *BI) {
11311124
LLVM_DEBUG(llvm::dbgs() << "jump thread from bb" << SrcBB->getDebugID()
11321125
<< " to bb" << DestBB->getDebugID() << '\n');
11331126

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

11371129
// Duplicate the destination block into this one, rewriting uses of the BBArgs
11381130
// to use the branch arguments as we go.
11391131
Cloner.cloneBranchTarget(BI);
11401132
Cloner.updateSSAAfterCloning();
11411133

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-
11471134
// Once all the instructions are copied, we can nuke BI itself. We also add
11481135
// the threaded and edge block to the worklist now that they (likely) can be
11491136
// simplified.
@@ -2886,8 +2873,6 @@ bool SimplifyCFG::tailDuplicateObjCMethodCallSuccessorBlocks() {
28862873
Cloner.cloneBranchTarget(Branch);
28872874
Cloner.updateSSAAfterCloning();
28882875

2889-
JumpThreadingCost[Cloner.getNewBB()] = JumpThreadingCost[DestBB];
2890-
28912876
Changed = true;
28922877
// Simplify the cloned block and continue tail duplicating through its new
28932878
// successors edges.

unittests/runtime/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
# We can't currently build the runtime tests under ASAN
2+
# The problem is that we want to use the just-build compiler (just like the
3+
# runtime) but ASAN will complain if we link against libgtest and LLVMSupport
4+
# libraries because they were compiled with the host compiler.
15
if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
2-
("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "${SWIFT_PRIMARY_VARIANT_ARCH}"))
6+
("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "${SWIFT_PRIMARY_VARIANT_ARCH}") AND
7+
(NOT (LLVM_USE_SANITIZER STREQUAL "Address")))
38

49
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
510
if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER)

0 commit comments

Comments
 (0)