2024-02-22 12:10:29 +00:00
|
|
|
//@ revisions: COMPAT INCOMPAT
|
|
|
|
//@ needs-llvm-components: x86
|
|
|
|
//@ compile-flags: --target=x86_64-unknown-linux-gnu -Copt-level=3
|
2024-08-04 15:32:17 -04:00
|
|
|
//@ [COMPAT] compile-flags: -Ctarget-feature=+avx2
|
2024-02-22 12:10:29 +00:00
|
|
|
//@ [INCOMPAT] compile-flags: -Ctarget-feature=-avx2,-avx
|
2021-03-13 15:29:39 +02:00
|
|
|
|
2023-01-05 09:45:44 +01:00
|
|
|
// See also tests/assembly/target-feature-multiple.rs
|
2021-03-13 15:29:39 +02:00
|
|
|
#![feature(no_core, lang_items)]
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
#![no_core]
|
|
|
|
|
|
|
|
#[lang = "sized"]
|
|
|
|
trait Sized {}
|
|
|
|
#[lang = "copy"]
|
|
|
|
trait Copy {}
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
fn peach() -> u32;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
#[target_feature(enable = "avx")]
|
|
|
|
#[no_mangle]
|
|
|
|
pub unsafe fn apple() -> u32 {
|
2024-05-29 14:11:20 +10:00
|
|
|
// CHECK-LABEL: @apple()
|
|
|
|
// CHECK-SAME: [[APPLEATTRS:#[0-9]+]] {
|
|
|
|
// CHECK: {{.*}}call{{.*}}@peach
|
2021-03-13 15:29:39 +02:00
|
|
|
peach()
|
|
|
|
}
|
|
|
|
|
2022-03-03 00:00:00 +00:00
|
|
|
// target features same as global
|
2021-03-13 15:29:39 +02:00
|
|
|
#[no_mangle]
|
|
|
|
pub unsafe fn banana() -> u32 {
|
2024-05-29 14:11:20 +10:00
|
|
|
// CHECK-LABEL: @banana()
|
|
|
|
// CHECK-SAME: [[BANANAATTRS:#[0-9]+]] {
|
|
|
|
// COMPAT: {{.*}}call{{.*}}@peach
|
|
|
|
// INCOMPAT: {{.*}}call{{.*}}@apple
|
2021-03-13 15:29:39 +02:00
|
|
|
apple() // Compatible for inline in COMPAT revision and can't be inlined in INCOMPAT
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: attributes [[APPLEATTRS]]
|
2024-08-04 15:32:17 -04:00
|
|
|
// COMPAT-SAME: "target-features"="+avx,+avx2,{{.*}}"
|
2024-07-26 11:27:21 -04:00
|
|
|
// INCOMPAT-SAME: "target-features"="-avx2,-avx,+avx,{{.*}}"
|
2021-03-13 15:29:39 +02:00
|
|
|
// CHECK: attributes [[BANANAATTRS]]
|
2024-08-04 15:32:17 -04:00
|
|
|
// COMPAT-SAME: "target-features"="+avx,+avx2,{{.*}}"
|
2022-03-03 00:00:00 +00:00
|
|
|
// INCOMPAT-SAME: "target-features"="-avx2,-avx"
|