[SIL Optimization] Improve dead-code in OSLogOptimization pass, fix a bug and add helper functions to the new InstructionDeleter utility #29447
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR consists of two commits. The first one fixes a bug in the identification of dead constant evaluable calls in the new InstructionDeleter utility. The fix makes the check more conservative and assumes that calls with generic arguments are not dead, as generic functions with arbitrary side-effects can be invoked through them.
The second commit improves the OSLogOptimization pass so that it can remove alloc_stacks that are dead as a result of the optimization. This change is specific to the pass and exploits the constant-evaluableness of the calls evaluated in that pass. At this point, this cannot be generalized outside of this pass, as it relies on the fact that the constant_evaluable calls "have been" evaluated successfully, which means that they did not have any side-effects (in that calling context) and were only using constants supported by the constant evaluator (all of which have value semantics).