-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
[rustc_ty_utils] Treat drop_in_place
's *mut argument like &mut when adding LLVM attributes
#111807
Conversation
…in_place` in certain cases. 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 the case of a value that has a programmer-defined Drop implementation, we know that the first thing `drop_in_place` will do is pass a pointer to the object to `Drop::drop`. `Drop::drop` takes `&mut`, so it must be guaranteed that there are no pointers to the object upon entering that function. Therefore, it should be safe to mark `noalias` there. With this patch, we mark `noalias` only when the type is a value with a programmer-defined Drop implementation. This is possibly overly conservative, but I thought that proceeding cautiously was best in this instance.
… unconditionally. We've done measurements with Miri and have determined that `noalias` shouldn't break code. The requirements that allow us to add dereferenceable and align have been long documented in the standard library documentation.
The CHECK, -NOT, -SAME pattern ensures that the `CHECK-NOT: noalias` is limited to only one line, and won't match unrelated lines further down in the file. Explicit drop call added to preserve the `foo` argument name, since names of unused arguments are not preserved.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit c4d69b7 with merge 68f76c31233347201320d356e0de9c9ace939293... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
/// | ||
/// * `to_drop` must be nonnull, even if `T` has size 0. | ||
/// | ||
/// * The value `to_drop` points to must be valid for dropping, which may mean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular requirement is ill-placed in the list since it is not a consequence of the things said above the enumeration -- but the docs claim that all list items follow from that prior information.
I think it is better to just state the requirement, we don't need to document hiw they come about because from the internal implementation details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, undid the change to the introduction of this section
Finished benchmarking commit (68f76c31233347201320d356e0de9c9ace939293): comparison URL. Overall result: ❌ regressions - 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never 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: 645.412s -> 646.792s (0.21%) |
Perf regressions are few, small in primary benchmarks (and not huge in secondary benchmarks), and are generally attributed to LLVM, which I think is acceptable. The point of this is to enable more optimizations*, so it's expected that LLVM does more work. |
@bors r+ |
⌛ Testing commit 340827a with merge 4570822ab9e0203f50ec1ec449a66f4351270ad8... |
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (f3d597b): comparison URL. Overall result: ❌ regressions - 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.
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: 644.28s -> 646.644s (0.37%) |
This change emits more attributes; it is expected to slow down the compiler, and that is compensated by the fact that it enables better code-generation from what we emit out of the compiler @rustbot label: +perf-regression-triaged |
This resurrects PR #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 todrop_in_place
in areas like argument promotion. Because the Rust compiler fully controls the code fordrop_in_place
, it can soundly deduce parameter attributes on it.In #103957, Miri was changed to retag
drop_in_place
's argument as if it was&mut
, matching this change.