Skip to content

Commit 1813b8b

Browse files
authored
Merge pull request #28261 from atrick/check-partialapply
Add support in SILLoop::canDuplicate for PartialApplyInst.
2 parents 8da2311 + 9963fe5 commit 1813b8b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/SIL/LoopInfo.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ bool SILLoop::canDuplicate(SILInstruction *I) const {
4848
return true;
4949
}
5050
if (I->isDeallocatingStack()) {
51-
SILInstruction *Alloc = nullptr;
52-
if (auto *Dealloc = dyn_cast<DeallocStackInst>(I))
53-
Alloc = dyn_cast<AllocStackInst>(Dealloc->getOperand());
54-
if (auto *Dealloc = dyn_cast<DeallocRefInst>(I))
55-
Alloc = dyn_cast<AllocRefInst>(Dealloc->getOperand());
56-
// The matching alloc_stack must be in the loop.
57-
return Alloc && contains(Alloc);
51+
SILInstruction *alloc = nullptr;
52+
if (auto *dealloc = dyn_cast<DeallocStackInst>(I)) {
53+
SILValue address = dealloc->getOperand();
54+
if (isa<AllocStackInst>(address) || isa<PartialApplyInst>(address))
55+
alloc = cast<SingleValueInstruction>(address);
56+
}
57+
if (auto *dealloc = dyn_cast<DeallocRefInst>(I))
58+
alloc = dyn_cast<AllocRefInst>(dealloc->getOperand());
59+
60+
return alloc && contains(alloc);
5861
}
5962

6063
// CodeGen can't build ssa for objc methods.

0 commit comments

Comments
 (0)