Skip to content

Commit cd5275a

Browse files
committed
Don't try to hoist/sink {begin,end}_access when the loop has no exits
This fixes compiler crash with message `LICM: Could not perform must-sink instruction`. Fixes: #67084
1 parent 7c83991 commit cd5275a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/SILOptimizer/LoopTransforms/LICM.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,11 @@ hoistSpecialInstruction(std::unique_ptr<LoopNestSummary> &LoopSummary,
502502
bool Changed = false;
503503

504504
for (auto *Inst : Special) {
505+
if (isa<BeginAccessInst>(Inst) && LoopSummary->Loop->hasNoExitBlocks()) {
506+
// If no exit block, don't try to hoist BeginAccess because
507+
// sinking EndAccess would fail later.
508+
continue;
509+
}
505510
if (!hoistInstruction(DT, Inst, Loop, Preheader)) {
506511
continue;
507512
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-swiftc_driver -O %s
2+
3+
// Issue URL
4+
// Don't crash failing to sink the corresponding end_access after
5+
// hoisting the begin_access when the loop has no exit.
6+
7+
var i = 0
8+
while true {
9+
i += 1
10+
}

0 commit comments

Comments
 (0)