File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
include/swift/SILOptimizer/Utils Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -153,10 +153,17 @@ class StackNesting {
153
153
// / Returns the location bit number for a stack deallocation instruction.
154
154
int bitNumberForDealloc (SILInstruction *DeallocInst) {
155
155
assert (DeallocInst->isDeallocatingStack ());
156
- auto *AllocInst = cast<SingleValueInstruction> (DeallocInst-> getOperand ( 0 ) );
156
+ auto *AllocInst = getAllocForDealloc (DeallocInst);
157
157
return bitNumberForAlloc (AllocInst);
158
158
}
159
159
160
+ // / Returns the stack allocation instruction for a stack deallocation
161
+ // / instruction.
162
+ SingleValueInstruction *getAllocForDealloc (SILInstruction *Dealloc) const {
163
+ return cast<SingleValueInstruction>(
164
+ Dealloc->getOperand (0 )->getDefiningInstruction ());
165
+ }
166
+
160
167
// / Insert deallocations at block boundaries.
161
168
Changes insertDeallocsAtBlockBoundaries ();
162
169
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ void StackNesting::setup() {
44
44
45
45
BI.StackInsts .push_back (Alloc);
46
46
} else if (I.isDeallocatingStack ()) {
47
- auto *AllocInst = cast<SingleValueInstruction>(I. getOperand ( 0 ) );
47
+ auto *AllocInst = getAllocForDealloc (&I );
48
48
if (!BI.StackInsts .empty () && BI.StackInsts .back () == AllocInst) {
49
49
// As an optimization, we ignore perfectly nested alloc-dealloc pairs
50
50
// inside a basic block.
@@ -374,7 +374,7 @@ void StackNesting::dump() const {
374
374
dumpBits (StackLocs[BitNr].AliveLocs );
375
375
llvm::dbgs () << " , " << *StackInst;
376
376
} else if (StackInst->isDeallocatingStack ()) {
377
- auto *AllocInst = cast<SingleValueInstruction> (StackInst-> getOperand ( 0 ) );
377
+ auto *AllocInst = getAllocForDealloc (StackInst);
378
378
int BitNr = StackLoc2BitNumbers.lookup (AllocInst);
379
379
llvm::dbgs () << " dealloc for #" << BitNr << " \n "
380
380
" " << *StackInst;
You can’t perform that action at this time.
0 commit comments