about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/attributes.rs
AgeCommit message (Collapse)AuthorLines
2025-09-25Revert "Auto merge of #144086 - clubby789:alloc-zeroed, r=nikic"Nikita Popov-10/+0
This reverts commit 040a98af70f0a7da03f3d5356531b28a2a7a77e4, reversing changes made to e8a792daf500b5ff8097896ddb6cc037abe92487.
2025-09-04compiler: Apply target features to the entry functionWANG Rui-8/+14
2025-08-27inline at the callsite & warn when target features mismatchJames Barford-Evans-10/+21
Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
2025-08-20Auto merge of #144086 - clubby789:alloc-zeroed, r=nikicbors-0/+10
Pass `alloc-variant-zeroed` to LLVM Makes use of https://github.com/llvm/llvm-project/pull/138299 (once we pull in a version of LLVM with this attribute). ~~Unfortunately also requires https://github.com/llvm/llvm-project/pull/149336 to work.~~ Closes rust-lang/rust#104847
2025-08-20Pass `alloc-variant-zeroed` to LLVMclubby789-0/+10
2025-08-19Rollup merge of #145429 - bjorn3:codegen_fn_attrs_improvements, r=jdonszelmann许杰友 Jieyou Xu (Joe)-1/+1
Couple of codegen_fn_attrs improvements As noted in https://github.com/rust-lang/rust/pull/144678#discussion_r2245060329 here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
2025-08-15Merge link_name and export_namebjorn3-1/+1
2025-08-14Remove lto inline logicMarcelo Domínguez-16/+0
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-1/+1
2025-07-16use `codegen_instance_attrs` where an instance is (easily) availableFolkert de Vries-1/+1
2025-07-07compiler: Deduplicate `must_emit_unwind_tables()` commentsMartin Nordholts-15/+0
There is one comment at a call site and one comment in the function definition that are mostly saying the same thing. Fold the call site comment into the function definition comment to reduce duplication. There are actually some inaccuracies in the comments but let's deduplicate before we address the inaccuracies.
2025-07-07rustc_codegen_llvm: Remove reference to non-existing `no_landing_pads()`Martin Nordholts-6/+5
Removing this reference was forgotten in eb4725fc54056. Grepping for no_landing_pads returns no hits after this.
2025-06-22centralize `-Zmin-function-alignment` logicFolkert de Vries-5/+1
2025-06-10use `#[naked]` for `__rust_probestack`Folkert de Vries-2/+3
2025-05-09don't depend on rustc_attr_parsing if rustc_data_structures will domejrs-1/+1
2025-04-28remove noinline attribute and add alwaysinline after AD passbit-aloo-3/+2
2025-04-25add llvm wrappers and corresponding methods in attributebit-aloo-0/+16
2025-04-05Update the minimum external LLVM to 19Josh Stone-29/+21
2025-01-24Rename `OptimizeAttr::None` to `Default`clubby789-1/+1
2025-01-23Implement `optimize(none)` attributeclubby789-6/+9
2025-01-11Rollup merge of #134030 - folkertdev:min-fn-align, r=workingjubileeMatthias Krüger-1/+5
add `-Zmin-function-alignment` tracking issue: https://github.com/rust-lang/rust/issues/82232 This PR adds the `-Zmin-function-alignment=<align>` flag, that specifies a minimum alignment for all* functions. ### Motivation This feature is requested by RfL [here](https://github.com/rust-lang/rust/issues/128830): > i.e. the equivalents of `-fmin-function-alignment` ([GCC](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fmin-function-alignment_003dn), Clang does not support it) / `-falign-functions` ([GCC](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-falign-functions), [Clang](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-falign-functions)). > > For the Linux kernel, the behavior wanted is that of GCC's `-fmin-function-alignment` and Clang's `-falign-functions`, i.e. align all functions, including cold functions. > > There is [`feature(fn_align)`](https://github.com/rust-lang/rust/issues/82232), but we need to do it globally. ### Behavior The `fn_align` feature does not have an RFC. It was decided at the time that it would not be necessary, but maybe we feel differently about that now? In any case, here are the semantics of this flag: - `-Zmin-function-alignment=<align>` specifies the minimum alignment of all* functions - the `#[repr(align(<align>))]` attribute can be used to override the function alignment on a per-function basis: when `-Zmin-function-alignment` is specified, the attribute's value is only used when it is higher than the value passed to `-Zmin-function-alignment`. - the target may decide to use a higher value (e.g. on x86_64 the minimum that LLVM generates is 16) - The highest supported alignment in rust is `2^29`: I checked a bunch of targets, and they all emit the `.p2align 29` directive for targets that align functions at all (some GPU stuff does not have function alignment). *: Only with `build-std` would the minimum alignment also be applied to `std` functions. --- cc `@ojeda` r? `@workingjubilee` you were active on the tracking issue
2025-01-10add `-Zmin-function-alignment`Folkert de Vries-1/+5
2025-01-10mir_transform: implement forced inliningDavid Wood-1/+3
Adds `#[rustc_force_inline]` which is similar to always inlining but reports an error if the inlining was not possible, and which always attempts to inline annotated items, regardless of optimisation levels. It can only be applied to free functions to guarantee that the MIR inliner will be able to resolve calls.
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-1/+1
2024-12-10codegen `#[naked]` functions using `global_asm!`Folkert-11/+3
2024-11-05Rollup merge of #132259 - mrkajetanp:branch-protection-pauth-lr, r=davidtwcoMatthias Krüger-1/+4
rustc_codegen_llvm: Add a new 'pc' option to branch-protection Add a new 'pc' option to -Z branch-protection for aarch64 that enables the use of PC as a diversifier in PAC branch protection code. When the pauth-lr target feature is enabled in combination with -Z branch-protection=pac-ret,pc, the new 9.5-a instructions (pacibsppc, retaasppc, etc) will be generated.
2024-10-31rustc_codegen_llvm: Add a new 'pc' option to branch-protectionKajetan Puchalski-1/+4
Add a new 'pc' option to -Z branch-protection for aarch64 that enables the use of PC as a diversifier in PAC branch protection code. When the pauth-lr target feature is enabled in combination with -Z branch-protection=pac-ret,pc, the new 9.5-a instructions (pacibsppc, retaasppc, etc) will be generated.
2024-10-31Remove support for `-Zprofile` (gcov-style coverage instrumentation)Zalathar-5/+0
2024-09-24codegen_ssa: consolidate tied feature checkingDavid Wood-22/+1
`rustc_codegen_llvm` and `rustc_codegen_gcc` duplicated logic for checking if tied target features were partially enabled. This commit consolidates these checks into `rustc_codegen_ssa` in the `codegen_fn_attrs` query, which also is run pre-monomorphisation for each function, which ensures that this check is run for unused functions, as would be expected.
2024-09-21remove `#[cmse_nonsecure_entry]`Folkert-3/+0
2024-09-19Reformat some comments.Nicholas Nethercote-3/+5
So they are less than 100 chars.
2024-09-06Do not request sanitizers for naked functionsNikita Popov-21/+25
Naked functions can only contain inline asm, so any instrumentation inserted by sanitizers is illegal. Don't request it. Fixes https://github.com/rust-lang/rust/issues/129224.
2024-08-27rustc_codegen_llvm: Filter out unavailable LLVM featuresKajetan Puchalski-3/+4
Convert to_llvm_features to return Option<LLVMFeature> so that it can return None if the requested feature is not available for the current LLVM version. Add match rules to filter out aarch64 features not available in LLVM 17.
2024-08-27rustc_target: Remove fpmr target featureKajetan Puchalski-0/+6
FEAT_FPMR has been removed from upstream LLVM as of LLVM 19. Remove the feature from the target features list and temporarily hack the LLVM codegen to always enable it until the minimum LLVM version is bumped to 19.
2024-08-16Add `warn(unreachable_pub)` to `rustc_codegen_llvm`.Nicholas Nethercote-10/+10
2024-08-07Rollup merge of #128679 - RalfJung:codegen-fn-attrs, r=nikicMatthias Krüger-1/+2
codegen: better centralize function declaration attribute computation For some reason, the codegen backend has two functions that compute which attributes a function declaration gets: `apply_attrs_llfn` and `attributes::from_fn_attrs`. They are called in different places, on entirely different layers of abstraction. To me the code seems cleaner if we centralize this entirely in `apply_attrs_llfn`, so that's what this PR does.
2024-08-07codegen: better centralize function attribute computationRalf Jung-1/+2
2024-08-07Hide implicit target features from diagnostics when possibleCaleb Zulawski-1/+1
2024-07-30Rollup merge of #128141 - nikic:aarch64-bti, r=DianQK,cuviperMatthias Krüger-3/+28
Set branch protection function attributes Since LLVM 19, it is necessary to set not only module flags, but also function attributes for branch protection on aarch64. See https://github.com/llvm/llvm-project/commit/e15d67cfc2e5775cc79281aa860f3ad3be628f39 for the relevant LLVM change. Fixes https://github.com/rust-lang/rust/issues/127829.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-5/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-24Set branch protection function attributesNikita Popov-3/+28
Since LLVM 19, it is necessary to set not only module flags, but also function attributes for branch protection on aarch64. See https://github.com/llvm/llvm-project/commit/e15d67cfc2e5775cc79281aa860f3ad3be628f39 for the relevant LLVM change.
2024-07-17rustc_codegen_llvm: properly passing backchain attribute to LLVM ...liushuyu-0/+14
... this is a special attribute that was made to be a target-feature in LLVM 18+, but in all previous versions, this "feature" is a naked attribute. We will have to handle this situation differently than all other target-features.
2024-07-11Remove extern "wasm" ABINikita Popov-13/+1
Remove the unstable `extern "wasm"` ABI (`wasm_abi` feature tracked in #83788). As discussed in https://github.com/rust-lang/rust/pull/127513#issuecomment-2220410679 and following, this ABI is a failed experiment that did not end up being used for anything. Keeping support for this ABI in LLVM 19 would require us to switch wasm targets to the `experimental-mv` ABI, which we do not want to do. It should be noted that `Abi::Wasm` was internally used for two things: The `-Z wasm-c-abi=legacy` ABI that is still used by default on some wasm targets, and the `extern "wasm"` ABI. Despite both being `Abi::Wasm` internally, they were not the same. An explicit `extern "wasm"` additionally enabled the `+multivalue` feature. I've opted to remove `Abi::Wasm` in this patch entirely, instead of keeping it as an ABI with only internal usage. Both `-Z wasm-c-abi` variants are now treated as part of the normal C ABI, just with different different treatment in adjust_for_foreign_abi.
2024-06-25Support `#[patchable_function_entries]`Matthew Maurer-3/+6
See [RFC](https://github.com/maurer/rust-rfcs/blob/patchable-function-entry/text/0000-patchable-function-entry.md) (yet to be numbered) TODO before submission: * Needs an RFC * Improve error reporting for malformed attributes
2024-06-25Support for -Z patchable-function-entryMatthew Maurer-0/+26
`-Z patchable-function-entry` works like `-fpatchable-function-entry` on clang/gcc. The arguments are total nop count and function offset. See MCP rust-lang/compiler-team#704
2024-06-23compiler(nfc): -Cforce-frame-pointers is a FramePointerJubilee Young-2/+3
2024-04-01Use the `Align` type when parsing alignment attributesbeetrees-1/+1
2024-02-11is_closure_likeMichael Goulet-1/+1
2024-01-30Remove `ffi_returns_twice` featureclubby789-3/+0
2024-01-09Rollup merge of #117744 - quininer:add-z-sync-uw, r=bjorn3Matthias Krüger-3/+4
Add -Zuse-sync-unwind Currently Rust uses async unwind by default, but async unwind will bring non-negligible size overhead. it would be nice to allow users to choose this. In addition, async unwind currently prevents LLVM from generate compact unwind for MachO, if one wishes to generate compact unwind for MachO, then also needs this flag.