-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Extend the alignment check to borrows #137940
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
Conversation
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
Yes, that is the most subtle part. Please add a test ensuring we do not complain in a case where |
We actually already have a test for this (@saethlin added an amazing test-suite for this check): https://github.com/rust-lang/rust/blob/2b285cd5f0877e30ad1d83e04f8cc46254e43391/tests/ui/mir/alignment/place_computation.rs. I rename it as part of this PR to make it more clear what we actually test here in the context of the new pass. |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Extend the alignment check to borrows The current alignment check does not include checks for creating misaligned references from raw pointers, which is now added in this patch. When inserting the check we need to be careful with references to field projections (e.g. `&(*ptr).a`), in which case the resulting reference must be aligned according to the field type and not the type of the pointer. r? `@saethlin` cc `@RalfJung,` after our discussion in rust-lang#134424
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (a7ce54d): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 1.8%)This 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary 0.1%)This 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: 782.898s -> 782.134s (-0.10%) |
I'm going to review this and also start a crater run, just so that we can know what the impact is before t-release finds it. @craterbot run mode=build-and-test |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
@craterbot run name=pr-137940-2 mode=build-and-test crates=https://crater-reports.s3.amazonaws.com/pr-137940/retry-regressed-list.txt |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
Thanks a lot for the Crater run! I started with a first analysis of the results (pre-rerun):
That's 87 regressions which is way more than I initially expected. The null-check crater-numbers were in a similar ballpark, but ~3/4th of them were explainable by a bug in an old bindgen version. I will research if that is the case here as well. Also qq: what is the reason for the rerun? Are you not certain about the quality of the regressed results because of a lot of spurious failures? |
🎉 Experiment
|
Yeah crater has a lot of false regressions. Seems like in this case we're already down to 24. :) |
Ah, I completely forgot that there are existing crates that already fail the alignment check. Looking now only in the regressed folder we see 7 failures:
This involves two crates on crates.io, where one already has an open issue for the misalignment. (Due to @saethlin's ub.https://asan.saethlin.dev/ub, awesome 🥳 ). For the other one I'll open an issue. Looking at the other regressions: There seems nothing related to this patch, the build failures come from the linker, the test failures are wrong assertions. |
58d25ed
to
db8b83e
Compare
The current alignment check does not include checks for creating misaligned references from raw pointers, which is now added in this patch. When inserting the check we need to be careful with references to field projections (e.g. `&(*ptr).a`), in which case the resulting reference must be aligned according to the field type and not the type of the pointer.
This makes the implementation of our PointerFinder a bit more straightforward.
db8b83e
to
7082fa2
Compare
@rustbot ready |
Sweet. Thanks for keeping the commit history clean! @bors r+ |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 1b8ab72 (parent) -> 4c83e55 (this PR) Test differencesShow 13 test diffsStage 1
Stage 2
Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 4c83e55e2d88ff93155be2784b9f64b91b870e99 --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Finished benchmarking commit (4c83e55): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -0.4%)This 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.
CyclesResults (primary 0.2%, secondary 6.0%)This 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 sizeResults (primary 0.1%)This 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: 764.09s -> 763.658s (-0.06%) |
The current alignment check does not include checks for creating misaligned references from raw pointers, which is now added in this patch.
When inserting the check we need to be careful with references to field projections (e.g.
&(*ptr).a
), in which case the resulting reference must be aligned according to the field type and not the type of the pointer.r? @saethlin
cc @RalfJung, after our discussion in #134424