Skip to content

Commit 0fc25cc

Browse files
committed
[Mem2Reg] Skipped unreachable blocks.
Uses of an alloc_stack instruction in an unreachable block must also be unreachable. Don't waste time optimizing unreachable code.
1 parent c209f52 commit 0fc25cc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,10 @@ bool MemoryToRegisters::run() {
17331733
f.verifyCriticalEdges();
17341734

17351735
for (auto &block : f) {
1736+
// Don't waste time optimizing unreachable blocks.
1737+
if (!domInfo->isReachableFromEntry(&block)) {
1738+
continue;
1739+
}
17361740
for (SILInstruction *inst : deleter.updatingReverseRange(&block)) {
17371741
auto *asi = dyn_cast<AllocStackInst>(inst);
17381742
if (!asi)

0 commit comments

Comments
 (0)