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