-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Make UB transmutes really UB in LLVM #143718
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
base: master
Are you sure you want to change the base?
Conversation
Ralf suggested in <rust-lang#143410 (comment)> that UB transmutes shouldn't be trapping, which happened for the one path that PR was changing, but there's another path as well, so this PR changes that other path to match.
Some changes occurred in compiler/rustc_codegen_ssa |
@nikic is this the best way to indicate "unreachable" to LLVM in the middle of a block? Does LLVM quickly normalize this by making the entire block |
According to https://llvm.org/docs/Frontend/PerformanceTips.html#id11, this should be |
Ah! We should have a helper method for this then. |
Oh, interesting! I'll switch it (both here and in the other spot). @rustbot author |
Yes. This makes sence to me. |
FWIW I don't think it particularly matters how Rust emits this. |
Well, if nothing else it's reasonable for there to be a method for "I wanted unreachable but not a terminator", so I can do that and if it ends up not mattering which code pattern it is, then fine. I do think here is different from #127740 because there it was a "runtime" value being passed to the assert, not a constant being created to be passed to it, so there I think it's better to let LLVM normalize, but here where I never specifically wanted an assume in the first place I don't mind just emitting using a different pattern. |
So places that need `unreachable` but in the middle of a basic block can call that instead of figuring out the best way to do it.
@rustbot ready |
@bors r+ |
Ralf suggested in #143410 (comment) that UB transmutes shouldn't be trapping, which happened for the one path that PR was changing, but there's another path as well, so this PR changes that other path to match.
r? codegen