-
Notifications
You must be signed in to change notification settings - Fork 39
use AbstractInterpreter interface #4
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
Conversation
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
16a6e23 to
d431350
Compare
2cc2cc5 to
89f7c9f
Compare
588b195 to
9eae440
Compare
00da6f5 to
67ad8cb
Compare
67ad8cb to
eeb83f5
Compare
eeb83f5 to
47fbbc9
Compare
de449da to
a2e121e
Compare
Owner
Author
|
Backedges shouldn't be used for abstract call stack traversal -- it turns out |
use `InferenceState.parent` instead of `MethodInstances.backedges` for abstract call stack traversal
a2e121e to
41e479c
Compare
41e479c to
4197131
Compare
aviatesk
added a commit
that referenced
this pull request
May 4, 2021
WIP because I found this is better to be generalized to a control flow analysis that checks for "never reaching exit points". For As an example, `sum(a for a in NeverTeminate(::Int))` will come down to `Base._fold_impl`, which directly uses `iterate(::NeverTeminate, [state])`, against which the current implementation based on the iteration protocol can't report an error. > Adapated from https://github.com/JuliaLang/julia/blob/24d9eab45632bdb3120c9e664503745eb58aa2d6/base/reduce.jl#L53-L65 ```julia function _foldl_impl(op::OP, init, itr) where {OP} # Unroll the while loop once; if init is known, the call to op may # be evaluated at compile time y = iterate(itr) y === nothing && return init v = op(init, y[1]) while true y = iterate(itr, y[2]) y === nothing && break v = op(v, y[1]) end return v end ``` > In a lowered representation ```julia CodeInfo( 1 ─ Core.NewvarNode(:(v)) │ y = Base.iterate(itr) │ %3 = y === Base.nothing └── goto #3 if not %3 2 ─ return init 3 ─ %6 = Base.getindex(y, 1) └── v = (op)(init, %6) 4 ┄ goto #8 if not true 5 ─ %9 = Base.getindex(y, 2) │ y = Base.iterate(itr, %9) │ %11 = y === Base.nothing └── goto #7 if not %11 6 ─ goto #8 7 ─ %14 = v │ %15 = Base.getindex(y, 1) │ v = (op)(%14, %15) └── goto #4 8 ┄ return v ) ``` We can report infinite iteration by checking both `goto #3 if not %3` and `goto #7 if not %11` never happens and thus this function never returns. --- - closes #135 - closes #179
aviatesk
added a commit
that referenced
this pull request
May 6, 2021
WIP because I found this is better to be generalized to a control flow analysis that checks for "never reaching exit points". For As an example, `sum(a for a in NeverTeminate(::Int))` will come down to `Base._fold_impl`, which directly uses `iterate(::NeverTeminate, [state])`, against which the current implementation based on the iteration protocol can't report an error. > Adapated from https://github.com/JuliaLang/julia/blob/24d9eab45632bdb3120c9e664503745eb58aa2d6/base/reduce.jl#L53-L65 ```julia function _foldl_impl(op::OP, init, itr) where {OP} # Unroll the while loop once; if init is known, the call to op may # be evaluated at compile time y = iterate(itr) y === nothing && return init v = op(init, y[1]) while true y = iterate(itr, y[2]) y === nothing && break v = op(v, y[1]) end return v end ``` > In a lowered representation ```julia CodeInfo( 1 ─ Core.NewvarNode(:(v)) │ y = Base.iterate(itr) │ %3 = y === Base.nothing └── goto #3 if not %3 2 ─ return init 3 ─ %6 = Base.getindex(y, 1) └── v = (op)(init, %6) 4 ┄ goto #8 if not true 5 ─ %9 = Base.getindex(y, 2) │ y = Base.iterate(itr, %9) │ %11 = y === Base.nothing └── goto #7 if not %11 6 ─ goto #8 7 ─ %14 = v │ %15 = Base.getindex(y, 1) │ v = (op)(%14, %15) └── goto #4 8 ┄ return v ) ``` We can report infinite iteration by checking both `goto #3 if not %3` and `goto #7 if not %11` never happens and thus this function never returns. --- - closes #135 - closes #179
aviatesk
added a commit
that referenced
this pull request
May 10, 2021
WIP because I found this is better to be generalized to a control flow analysis that checks for "never reaching exit points". For As an example, `sum(a for a in NeverTeminate(::Int))` will come down to `Base._fold_impl`, which directly uses `iterate(::NeverTeminate, [state])`, against which the current implementation based on the iteration protocol can't report an error. > Adapated from https://github.com/JuliaLang/julia/blob/24d9eab45632bdb3120c9e664503745eb58aa2d6/base/reduce.jl#L53-L65 ```julia function _foldl_impl(op::OP, init, itr) where {OP} # Unroll the while loop once; if init is known, the call to op may # be evaluated at compile time y = iterate(itr) y === nothing && return init v = op(init, y[1]) while true y = iterate(itr, y[2]) y === nothing && break v = op(v, y[1]) end return v end ``` > In a lowered representation ```julia CodeInfo( 1 ─ Core.NewvarNode(:(v)) │ y = Base.iterate(itr) │ %3 = y === Base.nothing └── goto #3 if not %3 2 ─ return init 3 ─ %6 = Base.getindex(y, 1) └── v = (op)(init, %6) 4 ┄ goto #8 if not true 5 ─ %9 = Base.getindex(y, 2) │ y = Base.iterate(itr, %9) │ %11 = y === Base.nothing └── goto #7 if not %11 6 ─ goto #8 7 ─ %14 = v │ %15 = Base.getindex(y, 1) │ v = (op)(%14, %15) └── goto #4 8 ┄ return v ) ``` We can report infinite iteration by checking both `goto #3 if not %3` and `goto #7 if not %11` never happens and thus this function never returns. --- - closes #135 - closes #179
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.
The final object of this PR is to allow TP to profile even when there are abstract inferred types in profiling.