mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[DCE] Process instructions added during deletion.
In cea0f00598, `InstructionDeleter` began
deleting `load [take]` instructions. Analogous to how it creates a
`destroy_value` when deleting an instruction which consumes a value, in
the case of deleting a `load [take]` the `InstructionDeleter` inserts a
compensating `destroy_addr`.
Previously, `DeadCodeElimination` did not observe the creation of any
instructions created by the `InstructionDeleter`. In the case of the
newly created `destroy_addr`, DCE didn't mark that the `destroy_addr`
was live and so deleted it. The result was a leak.
Here, this is fixed by passing an `InstModCallbacks`--with an
`onCreateNewInst` implementation--down into `erasePhiArgument` that
eventually invokes the `InstructionDeleter`. When the
`InstructionDeleter` creates a new instruction, DCE marks it live.
This commit is contained in:
@@ -658,7 +658,9 @@ bool DCE::removeDead() {
|
||||
|
||||
endLifetimeOfLiveValue(phiArg->getIncomingPhiValue(pred), insertPt);
|
||||
}
|
||||
erasePhiArgument(&BB, i);
|
||||
erasePhiArgument(&BB, i, /*cleanupDeadPhiOps=*/true,
|
||||
InstModCallbacks().onCreateNewInst(
|
||||
[&](auto *inst) { markInstructionLive(inst); }));
|
||||
Changed = true;
|
||||
BranchesChanged = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user