Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor inlining to allow re-use in more sophisticated inlining passes #37027

Merged
merged 1 commit into from
Sep 17, 2020

Conversation

Keno
Copy link
Member

@Keno Keno commented Aug 13, 2020

The inlining transform basically has three parts:

  1. Analysis (What needs to be inlined and are we allowed to do that?)
  2. Policy (Should we inline this?)
  3. Mechanism (Stuff the bits from one function into the other)

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.

The inlining transform basically has three parts:
1. Analysis (What needs to be inlined and are we allowed to do that?)
2. Policy (Should we inline this?)
3. Mechanism (Stuff the bits from one function into the other)

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.
@Keno Keno merged commit 2bd31a0 into master Sep 17, 2020
@Keno Keno deleted the kf/fancyinline branch September 17, 2020 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant