swift
4d92cced - [DCE] Tweaked code to end borrows before destroys.

Commit
4 years ago
[DCE] Tweaked code to end borrows before destroys. If a phi argument is dead and it reborrowing it was dependent on some other value, that other value on which it was dependent may have already itself been deleted. In that case, the destroy_value would have been added just before the terminator of the predecessors of the block which contained the dead phi. So, when deciding where to insert the end_borrow, iterate backwards from the end of the block, skipping the terminator updating the insertion point every time a destroy_value instruction is encountered until we hit an instruction with a different opcode. This ensures that no matter how many destroy_values may have been added just before the terminator, the end_borrow will preceed them. This commit just tweaks the preexisting logic that checked for this condition. Specifically, the previous code didn't handle the case where the block contains only a terminator and a destroy_value.
Author
Committer
Parents
Loading