2020-11-19 18:00:00 -06:00
|
|
|
// Checks that naked functions are never inlined.
|
2021-03-04 07:35:11 -06:00
|
|
|
// compile-flags: -O -Zmir-opt-level=3
|
2021-08-17 20:43:09 -05:00
|
|
|
// needs-asm-support
|
2020-11-19 18:00:00 -06:00
|
|
|
// ignore-wasm32
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
#![feature(naked_functions)]
|
|
|
|
|
2021-12-09 18:15:33 -06:00
|
|
|
use std::arch::asm;
|
|
|
|
|
2020-11-19 18:00:00 -06:00
|
|
|
#[naked]
|
|
|
|
#[no_mangle]
|
|
|
|
pub unsafe extern "C" fn f() {
|
2021-12-09 18:15:33 -06:00
|
|
|
// Check that f has naked and noinline attributes.
|
|
|
|
//
|
|
|
|
// CHECK: define void @f() unnamed_addr [[ATTR:#[0-9]+]]
|
|
|
|
// CHECK-NEXT: start:
|
|
|
|
// CHECK-NEXT: call void asm
|
2020-11-19 18:00:00 -06:00
|
|
|
asm!("", options(noreturn));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub unsafe fn g() {
|
2021-12-09 18:15:33 -06:00
|
|
|
// Check that call to f is not inlined.
|
|
|
|
//
|
|
|
|
// CHECK-LABEL: define void @g()
|
|
|
|
// CHECK-NEXT: start:
|
|
|
|
// CHECK-NEXT: call void @f()
|
2020-11-19 18:00:00 -06:00
|
|
|
f();
|
|
|
|
}
|
|
|
|
|
2022-07-06 21:07:52 -05:00
|
|
|
// CHECK: attributes [[ATTR]] = { naked{{.*}}noinline{{.*}} }
|