Repository navigation
Emit llvm dereferenceable in more cases on newer LLVM versions - #158863
Conversation
|
With LLVM 23 we can also put |
|
@RalfJung yes. What currently stops rust/compiler/rustc_ty_utils/src/abi.rs Lines 406 to 424 in f10db29 With I suppose another way to put this is that rustc already uses dereferenceable-at-a-point semantics since #156281, and applies dereferenceable-at-a-point everywhere it's valid. The only check that prevents llvm |
|
Nice, that's what I was hoping for. :) This will be much easier to review once we actually have LLVM 23 and can look at the codegen test diff. |
| // This one is *not* `noalias` because it might be self-referential. | ||
| // It is also not `dereferenceable` due to | ||
| // It is also not `dereferenceable` prior to LLVM23 due to | ||
| // <https://github.com/rust-lang/unsafe-code-guidelines/issues/381>. |
There was a problem hiding this comment.
@RalfJung I'm confused by this. You said applying dereferenceable on &!Freeze / &mut !Unpin should be fine now, but rust-lang/unsafe-code-guidelines#381 seems to disagree with that. Was there some kind of update since that issue was written or am I missing something else?
There was a problem hiding this comment.
Ah... good point. I had forgotten about this. This also relates to an old LLVM semantics question that never got resolved.
In the end the question is what dereferenceable really means to LLVM. Does it mean "this memory is in-bounds of some allocation" or does it mean "pretend we did a byte-type read here". The former is fine, Miri checks that. The latter is not fine as that read can affect the aliasing model (and the data race model, but LLVM ~defines that problem away and this is not our worst crime on the memory model side so we hope it's fine).
So what is unambiguously correct is to add dereferenceable to &i32 and &mut i32 return types, and to Box<i32> arguments and return types. But for !Freeze or !Unpin things are indeed less clear.
There was a problem hiding this comment.
Changed to PR such that it only emits dereferenceable in cases when miri performs implicit reads. #158863 (comment).
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Emit llvm dereferenceable in more cases on newer LLVM versions
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (69d43e7): comparison URL. Overall result: ❌ regressions - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 4.3%, secondary -1.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.4%, secondary 4.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 459.982s -> 458.725s (-0.27%) |
|
Regression feels like noise to me. |
This comment has been minimized.
This comment has been minimized.
Emit llvm dereferenceable in more cases on newer LLVM versions
This comment has been minimized.
This comment has been minimized.
Emit llvm dereferenceable in more cases on newer LLVM versions On llvm >= 23 emit `dereferenceable` even without `nofree`, since llvm/llvm-project#204795 makes `dereferenceable` act "at a point" / not imply `nofree`. Additionally restrict `dereferenceable` to `&Freeze` / `&mut Unpin` / `Box<Unpin, _>` only (this is only relevant for `llvm >= 23` as otherwise `!Freeze`/`!Unpin` suppress `nofree` and as such `dereferenceable`). r? nikic I thought this will be a bit harder change, but since your refactoring in #156281 it's actually trivial ^^' Draft because I don't think this can be tested prior to LLVM update. I'm also not sure if the version check I did is the appropriate one... cc @RalfJung
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (d93ffcb): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary 1.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 490.969s -> 489.48s (-0.30%) |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
💔 Test for b5e0884 failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
Emit llvm dereferenceable in more cases on newer LLVM versions try-job: test-i686-gnu-nopt-1
This comment has been minimized.
This comment has been minimized.
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 c165834 (parent) -> da51be1 (this PR) Test differencesShow 26 test diffsStage 1
Stage 2
Additionally, 2 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard da51be10c32bd6d06a2eb348bce844435739ed90 --output-dir test-dashboardAnd 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 (da51be1): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesResults (secondary 3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.0%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 491.121s -> 488.784s (-0.48%) |
View all comments
On llvm >= 23 emit
dereferenceableeven withoutnofree, since llvm/llvm-project#204795 makesdereferenceableact "at a point" / not implynofree.Additionally restrict
dereferenceableto&Freeze/&mut Unpin/Box<Unpin, _>only (this is only relevant forllvm >= 23as otherwise!Freeze/!Unpinsuppressnofreeand as suchdereferenceable).r? nikic
I thought this will be a bit harder change, but since your refactoring in #156281 it's actually trivial ^^'
Draft because I don't think this can be tested prior to LLVM update. I'm also not sure if the version check I did is the appropriate one...
cc @RalfJung