]> git.lizzy.rs Git - rust.git/blob - tests/codegen/target-feature-overrides.rs
Rollup merge of #107700 - jyn514:tools-builder, r=Mark-Simulacrum
[rust.git] / tests / codegen / target-feature-overrides.rs
1 // revisions: COMPAT INCOMPAT
2 // needs-llvm-components: x86
3 // compile-flags: --target=x86_64-unknown-linux-gnu -Copt-level=3
4 // [COMPAT] compile-flags: -Ctarget-feature=+avx2,+avx
5 // [INCOMPAT] compile-flags: -Ctarget-feature=-avx2,-avx
6
7 // See also tests/assembly/target-feature-multiple.rs
8 #![feature(no_core, lang_items)]
9 #![crate_type = "lib"]
10 #![no_core]
11
12
13 #[lang = "sized"]
14 trait Sized {}
15 #[lang = "copy"]
16 trait Copy {}
17
18 extern "C" {
19     fn peach() -> u32;
20 }
21
22 #[inline]
23 #[target_feature(enable = "avx")]
24 #[no_mangle]
25 pub unsafe fn apple() -> u32 {
26 // CHECK-LABEL: @apple()
27 // CHECK-SAME: [[APPLEATTRS:#[0-9]+]] {
28 // CHECK: {{.*}}call{{.*}}@peach
29     peach()
30 }
31
32 // target features same as global
33 #[no_mangle]
34 pub unsafe fn banana() -> u32 {
35 // CHECK-LABEL: @banana()
36 // CHECK-SAME: [[BANANAATTRS:#[0-9]+]] {
37 // COMPAT: {{.*}}call{{.*}}@peach
38 // INCOMPAT: {{.*}}call{{.*}}@apple
39     apple() // Compatible for inline in COMPAT revision and can't be inlined in INCOMPAT
40 }
41
42 // CHECK: attributes [[APPLEATTRS]]
43 // COMPAT-SAME: "target-features"="+avx2,+avx,+avx"
44 // INCOMPAT-SAME: "target-features"="-avx2,-avx,+avx"
45 // CHECK: attributes [[BANANAATTRS]]
46 // COMPAT-SAME: "target-features"="+avx2,+avx"
47 // INCOMPAT-SAME: "target-features"="-avx2,-avx"