-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
WIP: Improve nothrow modeling for :static_parameter #46820
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
Conversation
base/compiler/inferencestate.jl
Outdated
| end | ||
|
|
||
| """ | ||
| has_non_dt_typevar(typ, v) -> Bool |
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.
I think we have an existing version of this in Test which is much less conservative (it does methods lookups too)? Should we try to unify them?
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.
You're talking about Test.constrains_param?
737267b to
b7059b7
Compare
|
Seems good to me --- are the test failures related to deletion that now occurs due to increased effects accuracy? |
|
@Keno what's the status of this? Do we want it? |
423b939 to
dd6aab0
Compare
609f039 to
6181f20
Compare
dd6aab0 to
860f7c7
Compare
eb08722 to
5fbbd34
Compare
5fbbd34 to
468b612
Compare
* effects: taint `:nothrow` effect on unknown `:static_parameter` (conservatively)
With this commit, we taint `:nothrow` effect property correctly on
access to unknown `:static_parameter`, e.g.:
```julia
unknown_sparam_throw(::Union{Nothing, Type{T}}) where T = (T; nothing)
@test Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Type{Int},))))
@test !Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Nothing,))))
```
This commit implements a very conservative analysis, and thus there is a
room for improvement still, e.g.:
```julia
unknown_sparam_nothrow(x::Ref{T}) where {T} = (T; nothing)
@test_broken Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_nothrow, (Ref,)))
```
* inference: improve `:nothrow` modeling for `:static_parameter` (#46820)
* Fix test with free type params
* Test: Ignore ::Type{T} in detect_unbounded
These are only technically unbounded because of the existence of
ill-formed types. However, this function is supposed to be an API
sanity check and ordinary users should never have ill-formed types,
so for the purpose we want here, allow unboundedness in Type{T}.
---------
Co-authored-by: Keno Fischer <[email protected]>
Co-authored-by: Elliot Saba <[email protected]>
* effects: taint `:nothrow` effect on unknown `:static_parameter` (conservatively)
With this commit, we taint `:nothrow` effect property correctly on
access to unknown `:static_parameter`, e.g.:
```julia
unknown_sparam_throw(::Union{Nothing, Type{T}}) where T = (T; nothing)
@test Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Type{Int},))))
@test !Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Nothing,))))
```
This commit implements a very conservative analysis, and thus there is a
room for improvement still, e.g.:
```julia
unknown_sparam_nothrow(x::Ref{T}) where {T} = (T; nothing)
@test_broken Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_nothrow, (Ref,)))
```
* inference: improve `:nothrow` modeling for `:static_parameter` (#46820)
* Fix test with free type params
* Test: Ignore ::Type{T} in detect_unbounded
These are only technically unbounded because of the existence of
ill-formed types. However, this function is supposed to be an API
sanity check and ordinary users should never have ill-formed types,
so for the purpose we want here, allow unboundedness in Type{T}.
---------
Co-authored-by: Keno Fischer <[email protected]>
Co-authored-by: Elliot Saba <[email protected]>
(cherry picked from commit b5d17ea)
* effects: taint `:nothrow` effect on unknown `:static_parameter` (conservatively)
With this commit, we taint `:nothrow` effect property correctly on
access to unknown `:static_parameter`, e.g.:
```julia
unknown_sparam_throw(::Union{Nothing, Type{T}}) where T = (T; nothing)
@test Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Type{Int},))))
@test !Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Nothing,))))
```
This commit implements a very conservative analysis, and thus there is a
room for improvement still, e.g.:
```julia
unknown_sparam_nothrow(x::Ref{T}) where {T} = (T; nothing)
@test_broken Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_nothrow, (Ref,)))
```
* inference: improve `:nothrow` modeling for `:static_parameter` (#46820)
* Fix test with free type params
* Test: Ignore ::Type{T} in detect_unbounded
These are only technically unbounded because of the existence of
ill-formed types. However, this function is supposed to be an API
sanity check and ordinary users should never have ill-formed types,
so for the purpose we want here, allow unboundedness in Type{T}.
---------
Co-authored-by: Keno Fischer <[email protected]>
Co-authored-by: Elliot Saba <[email protected]>
(cherry picked from commit b5d17ea)
* effects: taint `:nothrow` effect on unknown `:static_parameter` (conservatively)
With this commit, we taint `:nothrow` effect property correctly on
access to unknown `:static_parameter`, e.g.:
```julia
unknown_sparam_throw(::Union{Nothing, Type{T}}) where T = (T; nothing)
@test Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Type{Int},))))
@test !Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Nothing,))))
```
This commit implements a very conservative analysis, and thus there is a
room for improvement still, e.g.:
```julia
unknown_sparam_nothrow(x::Ref{T}) where {T} = (T; nothing)
@test_broken Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_nothrow, (Ref,)))
```
* inference: improve `:nothrow` modeling for `:static_parameter` (#46820)
* Fix test with free type params
* Test: Ignore ::Type{T} in detect_unbounded
These are only technically unbounded because of the existence of
ill-formed types. However, this function is supposed to be an API
sanity check and ordinary users should never have ill-formed types,
so for the purpose we want here, allow unboundedness in Type{T}.
---------
Co-authored-by: Keno Fischer <[email protected]>
Co-authored-by: Elliot Saba <[email protected]>
(cherry picked from commit b5d17ea)
* effects: taint `:nothrow` effect on unknown `:static_parameter` (conservatively)
With this commit, we taint `:nothrow` effect property correctly on
access to unknown `:static_parameter`, e.g.:
```julia
unknown_sparam_throw(::Union{Nothing, Type{T}}) where T = (T; nothing)
@test Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Type{Int},))))
@test !Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Nothing,))))
```
This commit implements a very conservative analysis, and thus there is a
room for improvement still, e.g.:
```julia
unknown_sparam_nothrow(x::Ref{T}) where {T} = (T; nothing)
@test_broken Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_nothrow, (Ref,)))
```
* inference: improve `:nothrow` modeling for `:static_parameter` (#46820)
* Fix test with free type params
* Test: Ignore ::Type{T} in detect_unbounded
These are only technically unbounded because of the existence of
ill-formed types. However, this function is supposed to be an API
sanity check and ordinary users should never have ill-formed types,
so for the purpose we want here, allow unboundedness in Type{T}.
---------
Co-authored-by: Keno Fischer <[email protected]>
Co-authored-by: Elliot Saba <[email protected]>
(cherry picked from commit b5d17ea)
* effects: taint `:nothrow` effect on unknown `:static_parameter` (conservatively)
With this commit, we taint `:nothrow` effect property correctly on
access to unknown `:static_parameter`, e.g.:
```julia
unknown_sparam_throw(::Union{Nothing, Type{T}}) where T = (T; nothing)
@test Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Type{Int},))))
@test !Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Nothing,))))
```
This commit implements a very conservative analysis, and thus there is a
room for improvement still, e.g.:
```julia
unknown_sparam_nothrow(x::Ref{T}) where {T} = (T; nothing)
@test_broken Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_nothrow, (Ref,)))
```
* inference: improve `:nothrow` modeling for `:static_parameter` (#46820)
* Fix test with free type params
* Test: Ignore ::Type{T} in detect_unbounded
These are only technically unbounded because of the existence of
ill-formed types. However, this function is supposed to be an API
sanity check and ordinary users should never have ill-formed types,
so for the purpose we want here, allow unboundedness in Type{T}.
---------
Co-authored-by: Keno Fischer <[email protected]>
Co-authored-by: Elliot Saba <[email protected]>
(cherry picked from commit b5d17ea)
* effects: taint `:nothrow` effect on unknown `:static_parameter` (conservatively)
With this commit, we taint `:nothrow` effect property correctly on
access to unknown `:static_parameter`, e.g.:
```julia
unknown_sparam_throw(::Union{Nothing, Type{T}}) where T = (T; nothing)
@test Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Type{Int},))))
@test !Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Nothing,))))
```
This commit implements a very conservative analysis, and thus there is a
room for improvement still, e.g.:
```julia
unknown_sparam_nothrow(x::Ref{T}) where {T} = (T; nothing)
@test_broken Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_nothrow, (Ref,)))
```
* inference: improve `:nothrow` modeling for `:static_parameter` (#46820)
* Fix test with free type params
* Test: Ignore ::Type{T} in detect_unbounded
These are only technically unbounded because of the existence of
ill-formed types. However, this function is supposed to be an API
sanity check and ordinary users should never have ill-formed types,
so for the purpose we want here, allow unboundedness in Type{T}.
---------
Co-authored-by: Keno Fischer <[email protected]>
Co-authored-by: Elliot Saba <[email protected]>
(cherry picked from commit b5d17ea)
@aviatesk This was my attempt at #46791 while retaining some precision. Untested, but maybe it helps.