You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make it easy to attach LLVM attributes to Rust functions #15180
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.
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).
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.
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.
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!
Activity
kmcallister commentedon Jun 25, 2014
This should only be allowed on
unsafe fnbecause 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.Tobba commentedon Jun 25, 2014
There should also be a feature gated way to inject LLVM bitcode, which is really useful in certain cases
Thiez commentedon Jun 25, 2014
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).
huonw commentedon Jun 25, 2014
This and inline IR should probably go via an RFC.
kmcallister commentedon Sep 17, 2014
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.
thestinger commentedon Sep 17, 2014
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.steveklabnik commentedon Sep 3, 2015
Triage: no update specifically.
alexcrichton commentedon Sep 3, 2015
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!
Auto merge of rust-lang#15180 - alibektas:15176, r=Veykril
boozook commentedon Oct 2, 2025
I so need
noprofile/skipprofileandno_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? (likeregister_tool(llvm))