-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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: followups for #51754 #52241
Conversation
base/array.jl
Outdated
@@ -130,9 +130,9 @@ to tell the compiler that indexing operations within the applied expression are | |||
inbounds and do not need to taint `:consistent` and `:nothrow`. | |||
""" | |||
macro _safeindex(ex) |
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 don't really know where this macro came from, but the __safe_getindex function is very dangerous. Effect annotations need to be valid for all possible argument values. I'd like to limits its further propagation if possible. If we really need this, we could potentially think about call-site @assume_effects
, but ugh.
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 it comes from a desire to let f(a, i) = (@boundscheck boundscheck(a, i); @inbounds a[i])
have the same IPO effects as the combined operation f(a, i) = a[i]
, while still poisoning the independent expressions themselves (not consistent and ub, respectively) after inlining
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.
The macro @_safeindex
was created to mimic the effect of @inbounds [getindex|setindex!]
without affecting :noub
. But, echoing Keno's point, a more effective approach might be to isolate the specific indexing code into its own function, and add effects annotations to that function:
I'd rather pull out this table lookup into a separate function along with the
jp
computation and a long comment about why it's inbounds.
I'm not too happy with the last commit, but everything else if fine, so if you want to split the PR, those can go ahead and we can keep talking about the last one. |
9367cc2
to
6723c80
Compare
This commit defines functions that mirror our tools for analyzing return types and computational effects. The key point to discuss is that this commit introduces two functions: `Base.exception_types` and `Base.exception_type`. `Base.exception_types` acts like `Base.return_types`, giving a list of exception types for each method that matches with the given call signature. On the other hand, `Base.exception_type` is akin to `Base.infer_effects`, returning a single exception type that covers all potential outcomes entailed by the given call signature. I personally lean towards the latter for its utility, particularly in testing scenarios, but I included `exception_types` too for consistency with `return_types`. I'd welcome any feedback on this approach.
6723c80
to
15ab026
Compare
525bd6c
to
8dd0cf5
Compare
@nanosoldier |
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. |
Continued from #52241. This PR focuses on improving exception type inference for core math functions by using new callsite `Base.@assume_effects` annnotation.
Composed of:
update_cycle_worklists!
utility (78f7b4e)typename
call (fac36d8):nothrow
is proven (76143d3)improve exception type inference for core math functions (525bd6c)Separated into TODO