-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Rework :inbounds effects tainting #48246
Conversation
This works to fix #48243, by only tanting effects if an `@inbounds` statement is actually reached. Further, it refines the `noinbounds` effect to be IPO-cached and used to track whether a particular method read the inbounds state. A `:boundscheck` expression now does not immediately taint consistencty, but instead, taints `noinbounds` only. Then, if a method that has `:noinbounds` tainted is called within an `@inbounds` region, consistency is tainted. Similarly, a tainted `:noinbounds` disables constant propagation at `@inbounds` statements or if the method propagates inbounds.
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.
LGTM.
@goto delay_effects_analysis | ||
end | ||
end | ||
flag = sv.src.ssaflags[sv.currpc] |
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.
We can use get_curr_ssaflag(sv)
for this.
noinbounds = inbounds === :on || (inbounds === :default && all(flag::UInt8->iszero(flag&IR_FLAG_INBOUNDS), src.ssaflags)) | ||
consistent = noinbounds ? ALWAYS_TRUE : ALWAYS_FALSE | ||
ipo_effects = Effects(EFFECTS_TOTAL; consistent, noinbounds) | ||
ipo_effects = Effects(EFFECTS_TOTAL) |
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.
EFFECTS_TOTAL
LLVM can prove this inbounds and the annotation weakens the inferable effects for tuple iteration, which has a surprisingly large inference performance and precision impact. Unfortunately, my previous changes to :inbounds tainting weren't quite strong enough yet, because `getfield` was still tainting consistency on unknown boundscheck arguments. To fix that, we pass through the fargs into the fetfield effects to check if we're getting a literal `:boundscheck`, in which case the `:noinbounds` consistency-tainting logic I added in #48246 is sufficient to not require additional consistency tainting. Also add a test for both effects and codegen to make sure this doens't regress.
LLVM can prove this inbounds and the annotation weakens the inferable effects for tuple iteration, which has a surprisingly large inference performance and precision impact. Unfortunately, my previous changes to :inbounds tainting weren't quite strong enough yet, because `getfield` was still tainting consistency on unknown boundscheck arguments. To fix that, we pass through the fargs into the fetfield effects to check if we're getting a literal `:boundscheck`, in which case the `:noinbounds` consistency-tainting logic I added in #48246 is sufficient to not require additional consistency tainting. Also add a test for both effects and codegen to make sure this doens't regress.
LLVM can prove this inbounds and the annotation weakens the inferable effects for tuple iteration, which has a surprisingly large inference performance and precision impact. Unfortunately, my previous changes to :inbounds tainting weren't quite strong enough yet, because `getfield` was still tainting consistency on unknown boundscheck arguments. To fix that, we pass through the fargs into the fetfield effects to check if we're getting a literal `:boundscheck`, in which case the `:noinbounds` consistency-tainting logic I added in #48246 is sufficient to not require additional consistency tainting. Also add a test for both effects and codegen to make sure this doens't regress.
This works to fix #48243, by only tanting effects if an `@inbounds` statement is actually reached. Further, it refines the `noinbounds` effect to be IPO-cached and used to track whether a particular method read the inbounds state. A `:boundscheck` expression now does not immediately taint consistencty, but instead, taints `noinbounds` only. Then, if a method that has `:noinbounds` tainted is called within an `@inbounds` region, consistency is tainted. Similarly, a tainted `:noinbounds` disables constant propagation at `@inbounds` statements or if the method propagates inbounds. (cherry picked from commit d544e78)
* Remove @inbounds in tuple iteration LLVM can prove this inbounds and the annotation weakens the inferable effects for tuple iteration, which has a surprisingly large inference performance and precision impact. Unfortunately, my previous changes to :inbounds tainting weren't quite strong enough yet, because `getfield` was still tainting consistency on unknown boundscheck arguments. To fix that, we pass through the fargs into the fetfield effects to check if we're getting a literal `:boundscheck`, in which case the `:noinbounds` consistency-tainting logic I added in #48246 is sufficient to not require additional consistency tainting. Also add a test for both effects and codegen to make sure this doens't regress. * Int64 -> Int * fixup typo
We used to have this hack before #48246, but I removed it because I had hoped we don't need. Unfortunately, we weren't able to infer consistency of ``` @inbounds (1,2)[1] ``` With this hack, constprop is able to independently prove inbounded-ness, overriding the usual consistency taintaing that happens for inbounds.
We used to have this hack before #48246, but I removed it because I had hoped we don't need. Unfortunately, we weren't able to infer consistency of ``` @inbounds (1,2)[1] ``` With this hack, constprop is able to independently prove inbounded-ness, overriding the usual consistency taintaing that happens for inbounds.
We used to have this hack before #48246, but I removed it because I had hoped we don't need. Unfortunately, we weren't able to infer consistency of ``` @inbounds (1,2)[1] ``` With this hack, constprop is able to independently prove inbounded-ness, overriding the usual consistency taintaing that happens for inbounds. (cherry picked from commit 113c2f3)
We used to have this hack before #48246, but I removed it because I had hoped we don't need. Unfortunately, we weren't able to infer consistency of ``` @inbounds (1,2)[1] ``` With this hack, constprop is able to independently prove inbounded-ness, overriding the usual consistency taintaing that happens for inbounds. (cherry picked from commit 113c2f3)
We used to have this hack before #48246, but I removed it because I had hoped we don't need. Unfortunately, we weren't able to infer consistency of ``` @inbounds (1,2)[1] ``` With this hack, constprop is able to independently prove inbounded-ness, overriding the usual consistency taintaing that happens for inbounds. (cherry picked from commit 113c2f3)
We used to have this hack before #48246, but I removed it because I had hoped we don't need. Unfortunately, we weren't able to infer consistency of ``` @inbounds (1,2)[1] ``` With this hack, constprop is able to independently prove inbounded-ness, overriding the usual consistency taintaing that happens for inbounds. (cherry picked from commit 113c2f3)
We used to have this hack before #48246, but I removed it because I had hoped we don't need. Unfortunately, we weren't able to infer consistency of ``` @inbounds (1,2)[1] ``` With this hack, constprop is able to independently prove inbounded-ness, overriding the usual consistency taintaing that happens for inbounds. (cherry picked from commit 113c2f3)
This works to fix #48243, by only tanting effects if an
@inbounds
statement is actually reached. Further, it refines thenoinbounds
effect to be IPO-cached and used to track whether a particular method read the inbounds state. A:boundscheck
expression now does not immediately taint consistencty, but instead, taintsnoinbounds
only. Then, if a method that has:noinbounds
tainted is called within an@inbounds
region, consistency is tainted. Similarly, a tainted:noinbounds
disables constant propagation at@inbounds
statements or if the method propagates inbounds.