-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Update the alignment checks to match rust-lang/reference#1387 #113343
Conversation
I really don't know who is a good reviewer for this. My question in the PR description needs an answer and I'm not good enough at MIR to know it. Alternatively, a reviewer could decide that "check all place except X" is too fragile and we should go the other direction and only check the operands in a r? @RalfJung Or maybe @cjgillot ? I'd appreciate your input on this, if you have any. cc @rust-lang/opsem generally |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
Yes, |
Yeah I think that would be clearer. Reviewing this would take me a lot of time as currently I find the entire structure of this pass very unclear -- I have no idea what that diff does. So maybe it'd be better if whoever reviewed the pass when it landed could also take this one. |
I added a note to the PR description; I looked at the diff myself and I find it quite choppy and it would be easier to consider this all new code. I agree that this pass is pretty unique, maybe I'll factor its structure out of the pass before I do more passes like it.
r? @oli-obk |
This comment has been minimized.
This comment has been minimized.
5485ff5
to
4a30e21
Compare
This comment has been minimized.
This comment has been minimized.
4a30e21
to
9607331
Compare
I've been trying to motivate myself to review this PR since two weeks, but I'm just dreading mir opts 🙁. I'll give it another shot this week |
📌 Commit 6e6f455fced3b033f3d648de8daeeca675c4ba9a has been approved by It is now in the queue for this repository. |
This comment has been minimized.
This comment has been minimized.
@bors r- looks like this triggers somewhere in boostrap now? |
I'm going to rebase and squash this down then debug. |
As mentioned elsewhere, this triggering on rust/library/std/src/sys/personality/dwarf/mod.rs Lines 28 to 36 in 9339f44
which was previously accepted (even by miri). I also have code (not currently open source) that would be broken by it, and would prefer the pattern be allowed, since at least in my code, it has simplified working with underaligned data. |
A more problematic example is the following code, which is safe and compiles without warnings, but is broken under a rule like the one in this PR. #[repr(C, packed)]
pub struct Blah {
pub foo: u8,
pub bar: i32,
}
pub fn baz(x: &Blah) -> i32 {
x.bar
} While this PR's check only applies to raw pointers, @saethlin indicated in the zulip that it not triggering on the above is basically a false-negative. My opinion is that it would be deeply confusing to allow this only for references to packed structs (and not pointers), and that it would be a breaking language change to forbid it for both. |
This comment has been minimized.
This comment has been minimized.
069805c
to
87b1bef
Compare
Update the alignment checks to match rust-lang/reference#1387 Previously, we had a special case to not check `Rvalue::AddressOf` in this pass because we weren't quite sure if pointers needed to be aligned in the Place passed to it: rust-lang#112026 Since rust-lang/reference#1387 merged, this PR updates this pass to match. The behavior of the check is nearly unchanged, except we also avoid inserting a check for creating references. Most of the changes in this PR are cleanup and new tests.
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
87b1bef
to
f9bd7da
Compare
@bors r=RalfJung |
☀️ Test successful - checks-actions |
Finished benchmarking commit (a42d94e): comparison URL. Overall result: ✅ improvements - no action needed@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.
Binary sizeResultsThis 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.
Bootstrap: 635.113s -> 634.557s (-0.09%) |
84: Automated pull from upstream `master` r=Dajamante a=github-actions[bot] This PR pulls the following changes from the upstream repository: * rust-lang/rust#117585 * rust-lang/rust#117576 * rust-lang/rust#96979 * rust-lang/rust#117191 * rust-lang/rust#117179 * rust-lang/rust#117574 * rust-lang/rust#117537 * rust-lang/rust#117608 * rust-lang/rust#117596 * rust-lang/rust#117588 * rust-lang/rust#117524 * rust-lang/rust#116017 * rust-lang/rust#117504 * rust-lang/rust#117469 * rust-lang/rust#116218 * rust-lang/rust#117589 * rust-lang/rust#117581 * rust-lang/rust#117503 * rust-lang/rust#117590 * rust-lang/rust#117583 * rust-lang/rust#117570 * rust-lang/rust#117562 * rust-lang/rust#117534 * rust-lang/rust#116894 * rust-lang/rust#110340 * rust-lang/rust#113343 * rust-lang/rust#117579 * rust-lang/rust#117094 * rust-lang/rust#117566 * rust-lang/rust#117564 * rust-lang/rust#117554 * rust-lang/rust#117550 * rust-lang/rust#117343 * rust-lang/rust#115274 * rust-lang/rust#117540 * rust-lang/rust#116412 * rust-lang/rust#115333 * rust-lang/rust#117507 * rust-lang/rust#117538 * rust-lang/rust#117533 * rust-lang/rust#117523 * rust-lang/rust#117520 * rust-lang/rust#117505 * rust-lang/rust#117434 * rust-lang/rust#117535 * rust-lang/rust#117510 * rust-lang/rust#116439 * rust-lang/rust#117508 Co-authored-by: Ben Wiederhake <[email protected]> Co-authored-by: SabrinaJewson <[email protected]> Co-authored-by: J-ZhengLi <[email protected]> Co-authored-by: koka <[email protected]> Co-authored-by: bjorn3 <[email protected]> Co-authored-by: Joshua Liebow-Feeser <[email protected]> Co-authored-by: lengyijun <[email protected]> Co-authored-by: Zalathar <[email protected]> Co-authored-by: Oli Scherer <[email protected]> Co-authored-by: Philipp Krones <[email protected]> Co-authored-by: y21 <[email protected]> Co-authored-by: bors <[email protected]> Co-authored-by: bohan <[email protected]>
Previously, we had a special case to not check
Rvalue::AddressOf
in this pass because we weren't quite sure if pointers needed to be aligned in the Place passed to it: #112026Since rust-lang/reference#1387 merged, this PR updates this pass to match. The behavior of the check is nearly unchanged, except we also avoid inserting a check for creating references. Most of the changes in this PR are cleanup and new tests.