[AllocBoxToStack] Drop dead_end dealloc_boxes.

When creating `dealloc_stack`s corresponding to `dealloc_box`es, don't
bother to create a dealloc_stack if the `dealloc_box` is flagged
`dead_end`.
This commit is contained in:
Nate Chandler
2024-07-03 17:03:22 -07:00
parent 1d47d3ca0d
commit 02c28f5de5
2 changed files with 26 additions and 0 deletions

View File

@@ -709,6 +709,11 @@ static bool rewriteAllocBoxAsAllocStack(AllocBoxInst *ABI) {
// instruction we found that isn't an explicit dealloc_box.
Builder.emitDestroyAddrAndFold(Loc, valueToDestroy);
}
auto *dbi = dyn_cast<DeallocBoxInst>(LastRelease);
if (dbi && dbi->isDeadEnd()) {
// Don't bother to create dealloc_stack instructions in dead-ends.
continue;
}
Builder.createDeallocStack(Loc, ASI);
}