Retag as FnEntry on drop_in_place#103957
Conversation
|
r? @nagisa (rustbot has picked a reviewer for you, use r? to override) |
|
Eh, sorry, forgot to r? ghost, feel free to unassign yourself |
|
Failed to set assignee to
|
|
Yeah assigning ghost isn't a thing any more with triagebot, I think... |
9d269f6 to
c4b5c4d
Compare
|
@saethlin had tested this and found no regressions in the ecosystem, so seems reasonable to have. Marking as ready: r? @RalfJung The MIR gen for this is covered by an existing test. I'd also like to add a test to ensure that we find the UB in Miri - should I be adding that to the miri subtree in this PR or submitting a separate PR to rust-lang/miri? |
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
Please add the miri test in the same PR. It's great that we can finally do this. :)
|
RalfJung
left a comment
There was a problem hiding this comment.
LGTM, apart from the missing test.
|
In fact we probably want at least 2 tests -- one for the aliasing concerns and one for the validity (aligned and non-null). |
|
@rustbot author |
c4b5c4d to
8c9d9df
Compare
|
The Miri subtree was changed cc @rust-lang/miri |
|
Sorry for the delay, was traveling. Tests added. @rustbot ready |
This comment has been minimized.
This comment has been minimized.
8c9d9df to
143475e
Compare
|
Rebased and attached a commit to the end. Drop terminators are now a complete nop if the type has no drop glue and are documented as such. @rustbot ready |
0fa3a32 to
8f3584f
Compare
8f3584f to
0229281
Compare
| /// After drop elaboration: `Drop` terminators are a complete nop for types that have no drop | ||
| /// glue. For other types, `Drop` terminators behave exactly like a call to | ||
| /// `core::mem::drop_in_place` with a pointer to the given place. |
There was a problem hiding this comment.
This is the key change in the MIR spec here. It reflects what the codegen backends already do.
|
@bors r+ |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (cca80b9): 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)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.
|
fix vec::IntoIter::drop on high-alignment ZST This fixes a soundness bug: IntoIter would call `drop_in_place` on an insufficiently aligned pointer. So if a ZST with alignment greater 1 had drop glue, that would be called with an unaligned reference. Since rust-lang#103957, Miri checks alignment even if the type does not have drop glue, which is how this bug was found. r? `@thomcc`
fix vec::IntoIter::drop on high-alignment ZST This fixes a soundness bug: IntoIter would call `drop_in_place` on an insufficiently aligned pointer. So if a ZST with alignment greater 1 had drop glue, that would be called with an unaligned reference. Since rust-lang#103957, Miri checks alignment even if the type does not have drop glue, which is how this bug was found. r? ``@thomcc``
fix vec::IntoIter::drop on high-alignment ZST This fixes a soundness bug: IntoIter would call `drop_in_place` on an insufficiently aligned pointer. So if a ZST with alignment greater 1 had drop glue, that would be called with an unaligned reference. Since rust-lang/rust#103957, Miri checks alignment even if the type does not have drop glue, which is how this bug was found. r? ``@thomcc``
Retag as FnEntry on `drop_in_place` This commit changes the mir drop shim to always retag its argument as if it were a `&mut`. cc rust-lang/unsafe-code-guidelines#373
[rustc_ty_utils] Treat `drop_in_place`'s *mut argument like &mut when adding LLVM attributes This resurrects PR rust-lang#103614, which has sat idle for a while. This could probably use a new perf run, since we're on a new LLVM version now. r? `@oli-obk` cc `@RalfJung` --- LLVM can make use of the `noalias` parameter attribute on the parameter to `drop_in_place` in areas like argument promotion. Because the Rust compiler fully controls the code for `drop_in_place`, it can soundly deduce parameter attributes on it. In rust-lang#103957, Miri was changed to retag `drop_in_place`'s argument as if it was `&mut`, matching this change.
This commit changes the mir drop shim to always retag its argument as if it were a
&mut.cc rust-lang/unsafe-code-guidelines#373