ir.Method specialization on func.Invoke containing immutable known constants - #735
Open
zhenrongliew wants to merge 5 commits into
Open
zhenrongliew wants to merge 5 commits into
zhenrongliew wants to merge 5 commits into
Conversation
Contributor
|
Contributor
☂️ Code Coverage
Overall Coverage
New Files
Modified Files
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #734
Adds a
Specializepass that clones a method with call-site constants baked into its body and rewrites the call to pass only the remaining arguments. The original method is left untouched and still callable.Design
SpecializeInvoke(rewrite rule) matchesfunc.Invoke, reads one constant fact per operand, and swaps the call. Dropping an operand removes a use; it is DCE's decision to remove it if applicable.Specialize(pass) owns constant propagation, the key policy, the cache, the budget, the worklist, and backedge cleanup.Cache, Key & Budget
On argument values, positionally:
(method, (key₀ … keyₙ)). Sofoo(3, x)andfoo(x, 3)yield different specializations, whilefoo(b=x, a=3)normalizes to the same key asfoo(3, x)and shares a specialization._constant_keyadmits only: scalars, complex, range, and recursively tuple/frozenset/IList. Mutable values stay parameters.max_specializations(default 32) per method. At the limit the call falls back to the original method rather creating new specializations.