Refactor inlining to allow re-use in more sophisticated inlining passes #37027
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.
The inlining transform basically has three parts:
At the moment, we already separate this out into two passes:
Analysis/Policy (assemble_inline_todo!) and Mechanism (batch_inline!).
For our needs in base, the policy bits are quite simple (how large
is the optimized version of this function), but that policy is
insufficient for some more sophisticated inlining needs I have
in an external compiler pass (where I want to interleave inlining
with different transforms as well as potentially run inlining multiple
times). To facilitate such use cases, this commit optionally splits
out the policy part, but lets the analysis and mechanism parts be
re-used by a more sophisticated inlining pass. It also refactors
the optimization state to more clearly delineate the different
independent parts (edge tracking, inference catches, method table),
as well as making the different parts optional (where not required).
We were already essentially supporting optimization without edge
tracking (for testing purposes), so this is just a bit more
explicit about it (which is useful for me, since the different
inlining passes in my pipeline may need different settings).
For base itself, nothing should functionally change, though
hopefully things are factored a bit cleaner.