-
-
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
codegen: remove UB from uninitialized bitstypes in new #52169
Conversation
In the time since the creation of issue #26764, there _is_ now 'a way to say to llvm "I don't care what this value is, but it always has to be the same"', so we can use that to instruct LLVM to not give us undefined behavior when users are using uninitialized memory. There should not be an impact if users were already avoiding this paradigm and are fully initializing their structs. Fixes #26764
Note that this is already consistent with the way that inference treats these bitstype allocations as being non-pure:
|
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. |
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. |
I investigated into this and found this is a bug that we don't propagate julia/base/compiler/ssair/inlining.jl Lines 1268 to 1275 in e754f20
(i.e. :noub is actually tainted during abstract interpretation time but it is refined by post-opt analysis).
I think now we don't need to taint |
After #52169, the UB previously associated with allocations with uninitialized fields has been addressed, so there's no longer a need to taint `:noub` for `:new` allocations during abstract interpretation. I believe, even without #52169, uninitialized field does not inherently leads to UB, but just causes inconsistency of the program, since what actually causes UB is `getfield` that accesses into whatever object, but not the allocation itself.
Just for clarity, will there be any impact on users who create uninitialized structs? i.e. are there things such as performance implications to this, or does this simply eliminate a family of bugs where LLVM was previously free to swap out bits |
After #52169, the UB previously associated with allocations with uninitialized fields has been addressed, so there's no longer a need to taint `:noub` for `:new` allocations during abstract interpretation. I believe, even without #52169, uninitialized field does not inherently leads to UB, but just causes inconsistency of the program, since what actually causes UB is `getfield` that accesses into whatever object, but not the allocation itself.
There are performance implications for people who were using uninitialized memory, though that was previously discouraged anyways. Some positive and some negative effects. |
After #52169, there is no need to taint `:consistent`-cy on accessing undefined `isbitstype` field since the value of the fields is consistent always.
After #52169, there is no need to taint `:consistent`-cy on allocations with undefined `isbitstype` field since the value of the fields is consistent always.
After #52169, there is no need to taint `:consistent`-cy on accessing undefined `isbitstype` field since the value of the fields is consistent always.
After #52169, there is no need to taint `:consistent`-cy on allocations with undefined `isbitstype` field since the value of the fields is consistent always.
After #52169, there is no need to taint `:consistent`-cy on accessing undefined `isbitstype` field since the value of the fields is consistent always.
After #52169, there is no need to taint `:consistent`-cy on allocations with undefined `isbitstype` field since the value of the fields is consistent always.
After #52169, there is no need to taint `:consistent`-cy on accessing undefined `isbitstype` field since the value of the fields is consistent always.
After #52169, there is no need to taint `:consistent`-cy on allocations with undefined `isbitstype` field since the value of the fields is consistent always.
In the time since the creation of issue #26764, there is now 'a way to say to llvm "I don't care what this value is, but it always has to be the same"' using the
freeze
instruction, so we can use that to instruct LLVM to not give us undefined behavior when users are using uninitialized memory. There should not be an impact if users were already avoiding this paradigm and are fully initializing their structs.Fixes #26764