Skip to content

effects: taint :nothrow effect on unknown :static_parameter #46791

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 4 commits into from
Feb 8, 2023
Merged

Conversation

aviatesk
Copy link
Member

With this commit, we taint :nothrow effect property correctly on access to unknown :static_parameter, e.g.:

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.:

unknown_sparam_nothrow(x::Ref{T}) where {T} = (T; nothing)
@test_broken Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_nothrow, (Ref,)))

fix #46771

@aviatesk aviatesk added the compiler:effects effect analysis label Sep 16, 2022
@aviatesk aviatesk force-pushed the avi/46771 branch 4 times, most recently from 7cc9fbb to 14243e3 Compare September 18, 2022 04:46
@aviatesk
Copy link
Member Author

@Keno is it okay for now to merge this as is, and try to improve the accuracy of this nothrow analysis in a follow up PR (it seems a bit tricky than I expected though)?

@Keno
Copy link
Member

Keno commented Sep 18, 2022

I would prefer to try to get at least some precision in at the same time, because I suspect we're relying on this bug for performance in a number of applications

@aviatesk aviatesk changed the base branch from master to avi/sptypes December 8, 2022 10:24
@aviatesk aviatesk added the DO NOT MERGE Do not merge this PR! label Dec 8, 2022
Base automatically changed from avi/sptypes to master December 9, 2022 01:49
@staticfloat
Copy link
Member

@aviatesk I rebased this branch, so that we can push forward Keno's PR more easily.

@vchuravy
Copy link
Member

vchuravy commented Feb 7, 2023

Will this need to be backported to 1.9 since it's a bugfix to the effect system?

@aviatesk aviatesk changed the title effects: taint :nothrow effect on unknown :static_parameter (conservatively) effects: taint :nothrow effect on unknown :static_parameter Feb 7, 2023
@aviatesk
Copy link
Member Author

aviatesk commented Feb 7, 2023

Will this need to be backported to 1.9 since it's a bugfix to the effect system?

Yes, I think we should do it.

@oscardssmith oscardssmith added bugfix This change fixes an existing bug and removed DO NOT MERGE Do not merge this PR! labels Feb 7, 2023
@KristofferC KristofferC added the backport 1.9 Change should be backported to release-1.9 label Feb 7, 2023
@aviatesk
Copy link
Member Author

aviatesk commented Feb 7, 2023

@nanosoldier runbenchmarks("inference", vs=":master")

aviatesk added a commit that referenced this pull request Feb 7, 2023
This is an alternative to #46791.
Will be filed as a PR to check the performance difference.
@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - no performance regressions were detected. A full report can be found here.

@oscardssmith
Copy link
Member

given that there aren't any regressions here, good to merge?

@aviatesk
Copy link
Member Author

aviatesk commented Feb 7, 2023

There is one test failure on this PR, so don't merge now.

@staticfloat staticfloat force-pushed the avi/46771 branch 3 times, most recently from 14dfe1b to 248fb3c Compare February 8, 2023 00:36
aviatesk and others added 3 commits February 8, 2023 14:53
…ervatively)

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,)))
```
@aviatesk
Copy link
Member Author

aviatesk commented Feb 8, 2023

@nanosoldier runbenchmarks("inference", vs=":master")

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}.
@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@Keno Keno merged commit b5d17ea into master Feb 8, 2023
@Keno Keno deleted the avi/46771 branch February 8, 2023 09:40
@KristofferC KristofferC mentioned this pull request Feb 20, 2023
50 tasks
KristofferC pushed a commit that referenced this pull request Feb 20, 2023
* 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)
KristofferC pushed a commit that referenced this pull request Feb 20, 2023
* 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)
KristofferC pushed a commit that referenced this pull request Feb 20, 2023
* 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)
KristofferC pushed a commit that referenced this pull request Feb 21, 2023
* 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)
KristofferC pushed a commit that referenced this pull request Feb 21, 2023
* 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)
KristofferC pushed a commit that referenced this pull request Feb 21, 2023
* 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)
@KristofferC KristofferC removed the backport 1.9 Change should be backported to release-1.9 label Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug compiler:effects effect analysis
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect nothrow modeling of :static_parameter
7 participants