2020-09-03 19:00:00 -05:00
|
|
|
// Checks that only functions with compatible attributes are inlined.
|
|
|
|
// only-x86_64
|
2023-10-19 19:00:00 -05:00
|
|
|
// compile-flags: -Cpanic=abort
|
2020-09-03 19:00:00 -05:00
|
|
|
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
#![feature(no_sanitize)]
|
2023-03-02 06:41:17 -06:00
|
|
|
#![feature(target_feature_11)]
|
2020-11-10 18:00:00 -06:00
|
|
|
#![feature(c_variadic)]
|
2020-09-03 19:00:00 -05:00
|
|
|
|
2023-10-19 19:00:00 -05:00
|
|
|
#[inline]
|
|
|
|
#[target_feature(enable = "sse2")]
|
|
|
|
unsafe fn sse2() {}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn nop() {}
|
|
|
|
|
|
|
|
// CHECK-LABEL: fn f0()
|
|
|
|
// CHECK: bb0: {
|
|
|
|
// CHECK-NEXT: return;
|
2020-09-03 19:00:00 -05:00
|
|
|
#[target_feature(enable = "sse2")]
|
2023-10-19 19:00:00 -05:00
|
|
|
pub unsafe fn f0() {
|
|
|
|
sse2();
|
2020-09-03 19:00:00 -05:00
|
|
|
}
|
|
|
|
|
2023-10-19 19:00:00 -05:00
|
|
|
// CHECK-LABEL: fn f1()
|
|
|
|
// CHECK: bb0: {
|
|
|
|
// CHECK-NEXT: sse2()
|
|
|
|
pub unsafe fn f1() {
|
|
|
|
sse2();
|
2020-09-03 19:00:00 -05:00
|
|
|
}
|
|
|
|
|
2023-10-19 19:00:00 -05:00
|
|
|
// CHECK-LABEL: fn f2()
|
|
|
|
// CHECK: bb0: {
|
2023-10-19 19:00:00 -05:00
|
|
|
// CHECK-NEXT: nop()
|
2023-10-19 19:00:00 -05:00
|
|
|
#[target_feature(enable = "avx")]
|
|
|
|
pub unsafe fn f2() {
|
|
|
|
nop();
|
|
|
|
}
|
|
|
|
|
2023-10-19 19:00:00 -05:00
|
|
|
#[inline]
|
|
|
|
#[no_sanitize(address)]
|
|
|
|
pub unsafe fn no_sanitize() {}
|
|
|
|
|
|
|
|
// CHECK-LABEL: fn inlined_no_sanitize()
|
|
|
|
// CHECK: bb0: {
|
|
|
|
// CHECK-NEXT: return;
|
2020-09-03 19:00:00 -05:00
|
|
|
#[no_sanitize(address)]
|
|
|
|
pub unsafe fn inlined_no_sanitize() {
|
|
|
|
no_sanitize();
|
|
|
|
}
|
|
|
|
|
2023-10-19 19:00:00 -05:00
|
|
|
// CHECK-LABEL: fn not_inlined_no_sanitize()
|
|
|
|
// CHECK: bb0: {
|
|
|
|
// CHECK-NEXT: no_sanitize()
|
2020-09-03 19:00:00 -05:00
|
|
|
pub unsafe fn not_inlined_no_sanitize() {
|
|
|
|
no_sanitize();
|
|
|
|
}
|
|
|
|
|
2023-10-19 19:00:00 -05:00
|
|
|
// CHECK-LABEL: fn not_inlined_c_variadic()
|
|
|
|
// CHECK: bb0: {
|
|
|
|
// CHECK-NEXT: StorageLive(_1)
|
|
|
|
// CHECK-NEXT: _1 = sum
|
2020-11-10 18:00:00 -06:00
|
|
|
pub unsafe fn not_inlined_c_variadic() {
|
2023-10-19 19:00:00 -05:00
|
|
|
let _ = sum(4u32, 4u32, 30u32, 200u32, 1000u32);
|
2020-11-10 18:00:00 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline(always)]
|
2023-10-19 19:00:00 -05:00
|
|
|
#[no_mangle]
|
2020-11-10 18:00:00 -06:00
|
|
|
unsafe extern "C" fn sum(n: u32, mut vs: ...) -> u32 {
|
|
|
|
let mut s = 0;
|
|
|
|
let mut i = 0;
|
|
|
|
while i != n {
|
|
|
|
s += vs.arg::<u32>();
|
|
|
|
i += 1;
|
|
|
|
}
|
|
|
|
s
|
|
|
|
}
|