Skip to content

[rustc_ty_utils] Add the LLVM noalias parameter attribute to drop_in_place in certain cases.#103614

Closed
pcwalton wants to merge 5 commits into
rust-lang:masterfrom
pcwalton:drop-in-place-noalias
Closed

[rustc_ty_utils] Add the LLVM noalias parameter attribute to drop_in_place in certain cases.#103614
pcwalton wants to merge 5 commits into
rust-lang:masterfrom
pcwalton:drop-in-place-noalias

Conversation

@pcwalton
Copy link
Copy Markdown
Contributor

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.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.