Skip to content

Commit 32224d2

Browse files
committed
SILMem2Reg: a small cleanup
NFC
1 parent cff2735 commit 32224d2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -663,15 +663,15 @@ void MemoryToRegisters::removeSingleBlockAllocation(AllocStackInst *ASI) {
663663
}
664664

665665
// Remove dead address instructions that may be uses of the allocation.
666-
SILNode *Node = Inst;
667-
while (isa<StructElementAddrInst>(Node) ||
668-
isa<TupleElementAddrInst>(Node) ||
669-
isa<UncheckedAddrCastInst>(Node)) {
670-
auto *I = cast<SingleValueInstruction>(Node);
671-
if (!I->use_empty()) break;
672-
Node = I->getOperand(0);
673-
I->eraseFromParent();
666+
auto *addrInst = dyn_cast<SingleValueInstruction>(Inst);
667+
while (addrInst && addrInst->use_empty() &&
668+
(isa<StructElementAddrInst>(addrInst) ||
669+
isa<TupleElementAddrInst>(addrInst) ||
670+
isa<UncheckedAddrCastInst>(addrInst))) {
671+
SILValue op = addrInst->getOperand(0);
672+
addrInst->eraseFromParent();
674673
++NumInstRemoved;
674+
addrInst = dyn_cast<SingleValueInstruction>(op);
675675
}
676676
}
677677
}

0 commit comments

Comments
 (0)