Skip to content
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] Add the LLVM noalias parameter attribute to drop_in_place in certain cases. #103614

Closed
wants to merge 5 commits into from

Commits on Nov 17, 2022

  1. [rustc_ty_utils] Add the LLVM noalias parameter attribute to `drop_…

    …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.
    pcwalton committed Nov 17, 2022
    Configuration menu
    Copy the full SHA
    5ce1a00 View commit details
    Browse the repository at this point in the history
  2. Fix noalias box test

    pcwalton committed Nov 17, 2022
    Configuration menu
    Copy the full SHA
    ecfb332 View commit details
    Browse the repository at this point in the history
  3. Apply noalias, nonnull, dereferenceable, and align attributes…

    … 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.
    pcwalton committed Nov 17, 2022
    Configuration menu
    Copy the full SHA
    67ddb33 View commit details
    Browse the repository at this point in the history

Commits on Nov 18, 2022

  1. Configuration menu
    Copy the full SHA
    02cfabe View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    53f21aa View commit details
    Browse the repository at this point in the history