Uh oh!
There was an error while loading. Please reload this page.
Add CastKind::Transmute to MIR - #108442
Conversation
rustbot
commented
Feb 25, 2023
Failed to set assignee to
|
rustbot
commented
Feb 25, 2023
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
rustbot
commented
Feb 25, 2023
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
oli-obk
commented
Feb 25, 2023
To test it you could make the intrinsic mir pass convert the transmute function calls into an assignment of the new rvalue. That should allow removing all the intrinsic logic for transmute from the various backends |
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rustbot
commented
Feb 25, 2023
The Miri subtree was changed cc @rust-lang/miri |
Uh oh!
There was an error while loading. Please reload this page.
| self.fail(location, format!("Source and destination layouts have different sizes: {src_layout:?} vs {dst_layout:?}")); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Hmm, thinking about it more, I actually don't think we should have any check like this. Transmutes are presumably things that optimizations want to introduce, and making these kinds of cases not well-formed just feels like a footgun for those opts.
It's probably fine to keep this in for now, but can you include a comment that indicates that we can and should relax this restriction if some opts run into the need for it?
There was a problem hiding this comment.
Yeah, relaxing it in future sounds reasonable. I've added the comment, since relaxing it will probably need a bunch of intrinsics::mir! tests around how the various consumers would handle such a thing, which I'd rather not do right now.
Uh oh!
There was an error while loading. Please reload this page.
@oli-obk I see you resolved some comment threads here. Anything else you need from me before this is good to go? (If it's just that you need time to thoroughly review it that's totally ok!) |
oli-obk
commented
Feb 28, 2023
yea, just needed to get to a PC to be able to review the diff properly and look at code that isn't nearby your changes. @bors r+ |
bors
commented
Feb 28, 2023
Detect uninhabited types early in const eval r? `@RalfJung` implements rust-lang/rust#108442 (comment) this is a breaking change, as some UB during const eval is now detected instead of silently being ignored. Users can see this and other UB that may cause future breakage with `-Zextra-const-ub-checks` or just by running miri on their code, which sets that flag by default.
| let size_in_bytes = src.layout.size.bytes(); | ||
| if size_in_bytes == 0 { |
There was a problem hiding this comment.
This could also be
| let size_in_bytes = src.layout.size.bytes(); | |
| if size_in_bytes == 0{ | |
| if src.layout.is_zst(){ |
| // These cases are statically rejected by `mem::transmute`, so we need custom | ||
| // MIR to be able to get to constant evaluation. |
There was a problem hiding this comment.
Glad you like it! I was really impressed with the custom mir stuff; way easier to use and update than I'd worried it would be.
oli-obk
commented
Mar 23, 2023
@bors r+ |
bors
commented
Mar 23, 2023
bors
commented
Mar 23, 2023
⌛ Testing commit 64cce5f with merge cd1c3b968ac7aec48620234dd7481cdbd657295d... |
bors
commented
Mar 23, 2023
💔 Test failed - checks-actions |
rust-log-analyzer
commented
Mar 23, 2023
The job Click to see the possible cause of the failure (guessed by this bot) |
oli-obk
commented
Mar 23, 2023
@bors retry bootstrap self test network failure |
bors
commented
Mar 23, 2023
bors
commented
Mar 23, 2023
☀️ Test successful - checks-actions |
rust-timer
commented
Mar 23, 2023
Finished benchmarking commit (e216300): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
rylev
commented
Mar 28, 2023
The regressions are small enough that I don't think this is worth investigating. @rustbot label: +perf-regression-triaged |
Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.Includes lowering
transmutecalls to it, so it's used.Zulip Conversation: https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610