Skip to content

Make it easy to attach LLVM attributes to Rust functions #15180

Closed

Description

@kmcallister

Activity

  1. kmcallister commented on Jun 25, 2014

    @kmcallister
    ContributorAuthor

    This should only be allowed on unsafe fn because it can cause incorrect codegen. We should also determine if it's possible for a bad attribute to break the code for other functions in cases where the function with the attribute is never actually called.

  2. Tobba commented on Jun 25, 2014

    @Tobba
    Contributor

    There should also be a feature gated way to inject LLVM bitcode, which is really useful in certain cases

  3. Thiez commented on Jun 25, 2014

    @Thiez
    Contributor

    I think feature gates are for featues that we wish to eventually make it into the 'official' language, are they not? So it would not make sense to enable injection of LLVM bitcode, or it would not be possible to create a non-LLVM based rust compiler (not that I would expect that to happen any time soon, but it would be interesting to see a rustc that uses the GCC backend after the language reaches 1.0).

  4. huonw commented on Jun 25, 2014

    @huonw
    Contributor

    This and inline IR should probably go via an RFC.

  5. kmcallister commented on Sep 17, 2014

    @kmcallister
    ContributorAuthor

    Maybe codegen plugins are a more appropriate way to do this. I have a demo working on a Rust branch and it suits my use case well, because I want to set some attributes globally and others on specific functions.

  6. thestinger commented on Sep 17, 2014

    @thestinger
    Contributor

    There aren't many of these attributes so I think we should just expose the ones that are useful for Rust. For example, there's already a #[cold] attribute.

  7. steveklabnik commented on Sep 3, 2015

    @steveklabnik
    Contributor

    Triage: no update specifically.

  8. alexcrichton commented on Sep 3, 2015

    @alexcrichton
    Member

    It's unlikely that this would end up ever being stabilized because we don't want to tie ourselves so closely to LLVM, and we already export a good number of the useful attributes from LLVM. We can add more over time but a general mechanism to just forward everything through is pretty scary from a backwards-compatibility perspective, so I'm going to close this for now. Any missing attributes we're not using in LLVM can certainly have attributes added for them though!

  9. added a commit that references this issue on Jul 17, 2023
  10. boozook commented on Oct 2, 2025

    @boozook

    I so need noprofile/skipprofile and no_sanitize(“address”)/disable_sanitizer_instrumentation! ❤️‍🔥

    For sanitizer's instrumentation we probably have workaround -fsanitize-ignorelist file, but not for profile (PGO).

    Is it possible to implement any custom "attributes -> codegen" using register_tool(tool) feature? (like register_tool(llvm))

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions