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

inference: correctly translate inter-procedural information at everywhere #42847

Merged
merged 3 commits into from
Oct 29, 2021

Conversation

aviatesk
Copy link
Sponsor Member

There are some remaining cases where we need to call collect_limitations!
within abstract_invoke.
Also it turns out we need to handle InterConditional in any inter-procedural
contexts, so refactored that part within abstract_call_gf_by_type and
apply the logic everywhere inter-procedural propagation happens.

Now InterConditional propagation and callsite argument type refinement
are enabled for invoke and opaque closure call sites, e.g.:

ispositive(a) = isa(a, Int) && a > 0
@test Base.return_types((Any,)) do a
    if Base.@invoke ispositive(a::Any)
    return a
    end
    return 0
end |> only == Int

@test Base.return_types((Any,)) do a
    f = Base.Experimental.@opaque a -> isa(a, Int) && a > 0
    if f(a)
        return a
    end
    return 0
end |> only == Bool

@aviatesk aviatesk requested a review from vtjnash October 29, 2021 16:43
@aviatesk aviatesk added the compiler:inference Type inference label Oct 29, 2021
test/compiler/inference.jl Outdated Show resolved Hide resolved
aviatesk and others added 3 commits October 30, 2021 02:52
…here

There are some remaining cases where we need to call `collect_limitations!`
within `abstract_invoke`.
Also it turns out we need to handle `InterConditional` in any inter-procedural
contexts, so refactored that part within `abstract_call_gf_by_type` and
apply the logic everywhere inter-procedural propagation happens.

Now `InterConditional` propagation and callsite argument type refinement
are enabled for `invoke` and opaque closure call sites, e.g.:
```julia
ispositive(a) = isa(a, Int) && a > 0
@test Base.return_types((Any,)) do a
    if Base.@invoke ispositive(a::Any)
    return a
    end
    return 0
end |> only == Int

@test Base.return_types((Any,)) do a
    f = Base.Experimental.@opaque a -> isa(a, Int) && a > 0
    if f(a)
        return a
    end
    return 0
end |> only == Int
```
@aviatesk aviatesk added the status:merge me PR is reviewed. Merge when all tests are passing label Oct 29, 2021
@DilumAluthge DilumAluthge merged commit 11fc7ed into master Oct 29, 2021
@DilumAluthge DilumAluthge deleted the avi/correctinterprocedural branch October 29, 2021 21:01
@DilumAluthge DilumAluthge removed the status:merge me PR is reviewed. Merge when all tests are passing label Oct 30, 2021
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
…here (JuliaLang#42847)

There are some remaining cases where we need to call `collect_limitations!`
within `abstract_invoke`.
Also it turns out we need to handle `InterConditional` in any inter-procedural
contexts, so refactored that part within `abstract_call_gf_by_type` and
apply the logic everywhere inter-procedural propagation happens.

Now `InterConditional` propagation and callsite argument type refinement
are enabled for `invoke` and opaque closure call sites, e.g.:
```julia
ispositive(a) = isa(a, Int) && a > 0
@test Base.return_types((Any,)) do a
    if Base.@invoke ispositive(a::Any)
    return a
    end
    return 0
end |> only == Int

@test Base.return_types((Any,)) do a
    f = Base.Experimental.@opaque a -> isa(a, Int) && a > 0
    if f(a)
        return a
    end
    return 0
end |> only == Int
```

Co-authored-by: Jameson Nash <[email protected]>
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
…here (JuliaLang#42847)

There are some remaining cases where we need to call `collect_limitations!`
within `abstract_invoke`.
Also it turns out we need to handle `InterConditional` in any inter-procedural
contexts, so refactored that part within `abstract_call_gf_by_type` and
apply the logic everywhere inter-procedural propagation happens.

Now `InterConditional` propagation and callsite argument type refinement
are enabled for `invoke` and opaque closure call sites, e.g.:
```julia
ispositive(a) = isa(a, Int) && a > 0
@test Base.return_types((Any,)) do a
    if Base.@invoke ispositive(a::Any)
    return a
    end
    return 0
end |> only == Int

@test Base.return_types((Any,)) do a
    f = Base.Experimental.@opaque a -> isa(a, Int) && a > 0
    if f(a)
        return a
    end
    return 0
end |> only == Int
```

Co-authored-by: Jameson Nash <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants