-
-
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
Make it easier to avoid StackOverflowErrors with promotion and convert #19918
Conversation
Also worth noting that we still have good codegen: julia> @code_llvm flipsign(1,Int8(1))
define i64 @julia_flipsign_62360(i64, i8) #0 !dbg !5 {
top:
%2 = sext i8 %1 to i64
%3 = ashr i64 %2, 63
%4 = add i64 %3, %0
%5 = xor i64 %4, %3
ret i64 %5
} Still, we should @nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
I can't reproduce any of those regressions, so I think this is good to go. Merge? Perhaps the name |
|
That suggestion has merit, and I even thought of it ahead of time. I went with |
I think |
1e9ab71
to
3fabcb2
Compare
On my branch, the |
Sorry to steal a couple of issue-closings from you, but presumably you'll close so many when that merges you won't notice 😉. (Obviously feel free to modify those tests as needed.) |
This guards against errors that can lead to stack overflows. It resolves a mutually-recursive interaction between
T(x)
andconvert(T, x)
forT==Union{}
, and more significantly introduces a new function,promote_noncircular(x, y, z...)
, that throws an error if promotion didn't change at least one of the types. That prevents stack overflows for definitions likepromote_noncircular
is somewhat similar to (but more general than)promote_to_supertype
. It is not quite as@pure
, so the existing mechanism is also retained. At some point we may want to think about exporting this (or a variant), but for now this is a purely internal method.Fixes #12007, fixes #10326, fixes #15736