[StackNesting] NFC: Added helper.

Just pull the notion that the alloc corresponds to operand 0 into a
helper method.
This commit is contained in:
Nate Chandler
2023-05-25 07:31:27 -07:00
parent 8c8f5dfc2a
commit 389fb97b44
2 changed files with 10 additions and 3 deletions

View File

@@ -153,10 +153,17 @@ private:
/// Returns the location bit number for a stack deallocation instruction.
int bitNumberForDealloc(SILInstruction *DeallocInst) {
assert(DeallocInst->isDeallocatingStack());
auto *AllocInst = cast<SingleValueInstruction>(DeallocInst->getOperand(0));
auto *AllocInst = getAllocForDealloc(DeallocInst);
return bitNumberForAlloc(AllocInst);
}
/// Returns the stack allocation instruction for a stack deallocation
/// instruction.
SingleValueInstruction *getAllocForDealloc(SILInstruction *Dealloc) const {
return cast<SingleValueInstruction>(
Dealloc->getOperand(0)->getDefiningInstruction());
}
/// Insert deallocations at block boundaries.
Changes insertDeallocsAtBlockBoundaries();