about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/llvm_util.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-03-06 18:07:11 +0000
committerbors <bors@rust-lang.org>2022-03-06 18:07:11 +0000
commitc38b8a8c621e0c946af1b74f57bb8cc028e0060d (patch)
treee3d56978b77d614acf53f6723a009eac346fce4b /compiler/rustc_codegen_llvm/src/llvm_util.rs
parenta64180f67f148c0d13f30a8137dc4b8cc2b28757 (diff)
parent095d818e0c9c2428e11287e918c38bb6c487e6ed (diff)
downloadrust-c38b8a8c621e0c946af1b74f57bb8cc028e0060d.tar.gz
rust-c38b8a8c621e0c946af1b74f57bb8cc028e0060d.zip
Auto merge of #94579 - tmiasko:target-features, r=nagisa
Always include global target features in function attributes

This ensures that information about target features configured with
`-C target-feature=...` or detected with `-C target-cpu=native` is
retained for subsequent consumers of LLVM bitcode.

This is crucial for linker plugin LTO, since this information is not
conveyed to the plugin otherwise.

<details><summary>Additional test case demonstrating the issue</summary>

```rust
extern crate core;

#[inline]
#[target_feature(enable = "aes")]
unsafe fn f(a: u128, b: u128) -> u128 {
    use core::arch::x86_64::*;
    use core::mem::transmute;
    transmute(_mm_aesenc_si128(transmute(a), transmute(b)))
}

pub fn g(a: u128, b: u128) -> u128 {
    unsafe { f(a, b) }
}

fn main() {
    let mut args = std::env::args();
    let _ = args.next().unwrap();
    let a: u128 = args.next().unwrap().parse().unwrap();
    let b: u128 = args.next().unwrap().parse().unwrap();
    println!("{}", g(a, b));
}
```

```console
$ rustc --edition=2021 a.rs -Clinker-plugin-lto -Clink-arg=-fuse-ld=lld  -Ctarget-feature=+aes -O
...
  = note: LLVM ERROR: Cannot select: intrinsic %llvm.x86.aesni.aesenc
```

</details>

r? `@nagisa`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm_util.rs')
0 files changed, 0 insertions, 0 deletions