[Optimizer] Use valid inst range to broadcast inlining changes. #84577
+34
−7
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.
When inlining from the SwiftCompilerSources, sometimes a "best effort" list of instructions (in function order) more or less representing which instructions were cloned into the caller is constructed. A loop from the first instruction to the last instruction in that range is performed, and the instructions found are broadcasted to have changed. If the first instruction has been deleted, walking over the instructions in function order doesn't work, so instead of using the apply which inlining deletes, walk from the instruction "which is where the apply used to be" after inlining. And if the last instruction has been deleted, waklnig over the instructions never stops because no instruction seen when walking the instructions in function order is ever equal to the deleted instruction. Rather than just saying that every single instruction after the apply is changed, just don't bother to broadcast if the end of the range is deleted. This matches the preexisting best effort approach which also doesn't broadcast if for example the inlined callee is a
begin_applyimmediately followed by anyend_apply.Fixes a compiler crash.
rdar://161433604