Skip to content

AbstractInterpreter: Add a hook to opt into more extensive stmt info #39716

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

Merged
merged 1 commit into from
Feb 19, 2021

Conversation

Keno
Copy link
Member

@Keno Keno commented Feb 17, 2021

I'm in the process of updating Cthulhu to make use of an AbstractInterpreter
instead of using raw inference queries. Over time Cthulhu has grown many
heuristics for trying to reverse engineer what inference did in order to
present this to the user. Of course, these heuristics are incomplete and
worse, we do already mostly have this information neatly packaged in
the stmt_info field, since optimization needs the same information.
Switching Cthulhu to an AbstractInterpreter gives it access to this info
(as well as allowing it to maintain its own caches, fixing various
weirdness around statement order dependence with the base inference
caches). However, there are a few places in inference where we drop
stmt info that Cthulhu would like to read because the optimizer doesn't
need it. This adds a hook for Cthulhu (and other tooling that would
like to receive it) to get more verbose stmt info out of inference.

As an example, this adds statement info for return_type, which is only
produced on opt in. There is a few more of these, but this shows the
flavor of what I'm going for.

My end goal here is to turn Cthulhu entirely into a viewer for inference
data structures, and not have it contain any heuristics that duplicate
inference functionality. I think we're pretty close to that, but
a few tweaks are required. Hopefully the end result should be a much
more functional and precise Cthulhu (as well as being easier to
maintain, since we get to delete half the code).

I'm in the process of updating Cthulhu to make use of an AbstractInterpreter
instead of using raw inference queries. Over time Cthulhu has grown many
heuristics for trying to reverse engineer what inference did in order to
present this to the user. Of course, these heuristics are incomplete and
worse, we do already mostly have this information neatly packaged in
the stmt_info field, since optimization needs the same information.
Switching Cthulhu to an AbstractInterpreter gives it access to this info
(as well as allowing it to maintain its own caches, fixing various
weirdness around statement order dependence with the base inference
caches). However, there are a few places in inference where we drop
stmt info that Cthulhu would like to read because the optimizer doesn't
need it. This adds a hook for Cthulhu (and other tooling that would
like to receive it) to get more verbose stmt info out of inference.

My end goal here is to turn Cthulhu entirely into a viewer for inference
data structures, and not have it contain any heuristics that duplicate
inference functionality. I think we're pretty close to that, but
a few tweaks are required. Hopefully the end result should be a much
more functional and precise Cthulhu (as well as being easier to
maintain, since we get to delete half the code).
Keno added a commit to JuliaDebug/Cthulhu.jl that referenced this pull request Feb 17, 2021
Rips out all the heuristics that are duplicating the analysis
that inference already does to figure out what is getting called.
This should be much more precise and general. We may want to
revisit the whole CallInfo setup in the future to maybe use the
stmt info more directly, but this should be good for the moment.

Depends on JuliaLang/julia#39716 (so WIP
until that is merged).
Keno added a commit to JuliaDebug/Cthulhu.jl that referenced this pull request Feb 17, 2021
Rips out all the heuristics that are duplicating the analysis
that inference already does to figure out what is getting called.
This should be much more precise and general. We may want to
revisit the whole CallInfo setup in the future to maybe use the
stmt info more directly, but this should be good for the moment.

Depends on JuliaLang/julia#39716 (so WIP
until that is merged).
@Keno Keno merged commit 38aeb48 into master Feb 19, 2021
@Keno Keno deleted the kf/cthulhuhooks branch February 19, 2021 04:20
aviatesk added a commit to aviatesk/JET.jl that referenced this pull request Feb 20, 2021
Keno added a commit to JuliaDebug/Cthulhu.jl that referenced this pull request Mar 3, 2021
Rips out all the heuristics that are duplicating the analysis
that inference already does to figure out what is getting called.
This should be much more precise and general. We may want to
revisit the whole CallInfo setup in the future to maybe use the
stmt info more directly, but this should be good for the moment.

Depends on JuliaLang/julia#39716 (so WIP
until that is merged).
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
…uliaLang#39716)

I'm in the process of updating Cthulhu to make use of an AbstractInterpreter
instead of using raw inference queries. Over time Cthulhu has grown many
heuristics for trying to reverse engineer what inference did in order to
present this to the user. Of course, these heuristics are incomplete and
worse, we do already mostly have this information neatly packaged in
the stmt_info field, since optimization needs the same information.
Switching Cthulhu to an AbstractInterpreter gives it access to this info
(as well as allowing it to maintain its own caches, fixing various
weirdness around statement order dependence with the base inference
caches). However, there are a few places in inference where we drop
stmt info that Cthulhu would like to read because the optimizer doesn't
need it. This adds a hook for Cthulhu (and other tooling that would
like to receive it) to get more verbose stmt info out of inference.

My end goal here is to turn Cthulhu entirely into a viewer for inference
data structures, and not have it contain any heuristics that duplicate
inference functionality. I think we're pretty close to that, but
a few tweaks are required. Hopefully the end result should be a much
more functional and precise Cthulhu (as well as being easier to
maintain, since we get to delete half the code).
antoine-levitt pushed a commit to antoine-levitt/julia that referenced this pull request May 9, 2021
…uliaLang#39716)

I'm in the process of updating Cthulhu to make use of an AbstractInterpreter
instead of using raw inference queries. Over time Cthulhu has grown many
heuristics for trying to reverse engineer what inference did in order to
present this to the user. Of course, these heuristics are incomplete and
worse, we do already mostly have this information neatly packaged in
the stmt_info field, since optimization needs the same information.
Switching Cthulhu to an AbstractInterpreter gives it access to this info
(as well as allowing it to maintain its own caches, fixing various
weirdness around statement order dependence with the base inference
caches). However, there are a few places in inference where we drop
stmt info that Cthulhu would like to read because the optimizer doesn't
need it. This adds a hook for Cthulhu (and other tooling that would
like to receive it) to get more verbose stmt info out of inference.

My end goal here is to turn Cthulhu entirely into a viewer for inference
data structures, and not have it contain any heuristics that duplicate
inference functionality. I think we're pretty close to that, but
a few tweaks are required. Hopefully the end result should be a much
more functional and precise Cthulhu (as well as being easier to
maintain, since we get to delete half the code).
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.

2 participants