2020-11-19 18:00:00 -06:00
|
|
|
// Checks that naked functions are never inlined.
|
2024-02-22 06:10:29 -06:00
|
|
|
//@ compile-flags: -O -Zmir-opt-level=3
|
|
|
|
//@ needs-asm-support
|
|
|
|
//@ ignore-wasm32
|
2020-11-19 18:00:00 -06:00
|
|
|
#![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{{.*}} }
|