-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
inference: refactoring to allow irinterp to perform :call
inference
#48913
Conversation
- remove `update_valid_age!(edge::InferenceState, sv::InferenceState)` and replace all the usages with `update_valid_age!(sv, edge.valid_worlds)`: this will simplify the incoming `AbsIntState` interface (see #48913) - remove `Effects(sv::InferenceState)` utility: replace all the usages with `sv.ipo_effects`, which is more explictly saying that we are looking at IPO-valid effects - normalize more `li::MethodInstance` to `mi::MethodInstance` - import `Core.MethodTable` - fix up `setindex!` return values
56bea36
to
1010057
Compare
- remove `update_valid_age!(edge::InferenceState, sv::InferenceState)` and replace all the usages with `update_valid_age!(sv, edge.valid_worlds)`: this will simplify the incoming `AbsIntState` interface (see #48913) - remove `Effects(sv::InferenceState)` utility: replace all the usages with `sv.ipo_effects`, which is more explictly saying that we are looking at IPO-valid effects - normalize more `li::MethodInstance` to `mi::MethodInstance` - import `Core.MethodTable` - fix up `setindex!` return values
a4d3be7
to
513c5e6
Compare
c01f6cc
to
4f0d57f
Compare
965c082
to
53809c6
Compare
I am still working on item 1, which is to implement a proper recursion detection support for irinterp. I am currently wondering if a simple recursion detection mechanism is sufficient, as the existing recursion detection mechanism with |
I'm not sure. :terminates is a pretty strong condition, so in theory it should probably be ok, but I'm not sure I'm comfortable saying that it can't happen. However, if it does happen, we probably have the same issue right now without this change, so if you want to finish this up and keep working on the termination change separately I think that would be ok as long as nothing shows up on pkgeval. I do think it would be good to eventually relax the :terminates requirement, for which strong recursion detection would be required, but that can be separate. |
Okay, now I think this PR is ready. I also tweaked miscellaneous inference subroutines like @nanosoldier |
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for splitting this up.
This commit implements a significant refactoring of the inference routines, which is necessary to enable `:call` inference in irinterp. While this commit does not yet enable `:call` inference, a subsequent small commit will do so. This is because external `AbstractInterpreter`s first need to adjust their code for this refactoring, and in the event of a regression detected by the recursive `:call` inference, we will be able to simply revert the small commit. Additionally, this commit improves the robustness of irinterp by allowing it to handle invoke calls, which currently result in a crash. TODOs: - [x] implement a simple recursion detection mechanism for `IRInterpretationState` - [x] add proper invalidation support - [x] allow constant inference from semi-concrete interpretation - [x] propagate callinfo and allow double inlining
@nanosoldier |
Nanosoldier is down, but we don't expect this to change performance that much (yet); it's the follow-on PR that will have significant impact. |
Nanosoldier is not affected by the PkgEval outage |
- remove `update_valid_age!(edge::InferenceState, sv::InferenceState)` and replace all the usages with `update_valid_age!(sv, edge.valid_worlds)`: this will simplify the incoming `AbsIntState` interface (see JuliaLang#48913) - remove `Effects(sv::InferenceState)` utility: replace all the usages with `sv.ipo_effects`, which is more explictly saying that we are looking at IPO-valid effects - normalize more `li::MethodInstance` to `mi::MethodInstance` - import `Core.MethodTable` - fix up `setindex!` return values
* inference: enable `:call` inference in irinterp Built on top of #48913, this commit enables `:call` inference in irinterp. In a case when some regression is detected, we can simply revert this commit rather than reverting the whole refactoring from #48913. * fix irinterp lattice Now `LimitedAccuracy` can appear in irinterp, so we should include `InferenceLattice` for `[typeinf|ipo]_lattice` for irinterp.
If the LimitedAccuracy was supposed to resolve against the top-most frame (or hypothetically a non-InferenceState frame), it would not have a parentframe, preventing it from reaching the subsequent poison_callstack line that is required for reliable inference (avoiding caching bad results). This should restore the original intent of this code (pre #48913)
If the LimitedAccuracy was supposed to resolve against the top-most frame (or hypothetically a non-InferenceState frame), it would not have a parentframe, preventing it from reaching the subsequent poison_callstack line that is required for reliable inference (avoiding caching bad results). This should restore the original intent of this code (pre #48913) (cherry picked from commit d1b1a5d)
If the LimitedAccuracy was supposed to resolve against the top-most frame (or hypothetically a non-InferenceState frame), it would not have a parentframe, preventing it from reaching the subsequent poison_callstack line that is required for reliable inference (avoiding caching bad results). This should restore the original intent of this code (pre JuliaLang#48913)
This commit implements a significant refactoring of the inference routines,
which is necessary to enable
:call
inference in irinterp. While thiscommit does not yet enable
:call
inference, a subsequent small commitwill do so. This is because external
AbstractInterpreter
s first needto adjust their code for this refactoring, and in the event of a
regression detected by the recursive
:call
inference, we will be ableto simply revert the small commit.
Additionally, this commit improves the robustness of irinterp by
allowing it to handle invoke calls, which currently result in a crash.
TODOs:
IRInterpretationState