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)]
|
|
|
|
|
2024-09-05 06:45:26 -05:00
|
|
|
use std::arch::naked_asm;
|
2021-12-09 18:15:33 -06:00
|
|
|
|
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.
|
|
|
|
//
|
2023-05-23 08:26:31 -05:00
|
|
|
// CHECK: define {{(dso_local )?}}void @f() unnamed_addr [[ATTR:#[0-9]+]]
|
2021-12-09 18:15:33 -06:00
|
|
|
// CHECK-NEXT: start:
|
|
|
|
// CHECK-NEXT: call void asm
|
2024-09-05 06:45:26 -05:00
|
|
|
naked_asm!("");
|
2020-11-19 18:00:00 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub unsafe fn g() {
|
2021-12-09 18:15:33 -06:00
|
|
|
// Check that call to f is not inlined.
|
|
|
|
//
|
2023-05-23 08:26:31 -05:00
|
|
|
// CHECK-LABEL: define {{(dso_local )?}}void @g()
|
2021-12-09 18:15:33 -06:00
|
|
|
// 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{{.*}} }
|