]> git.lizzy.rs Git - rust.git/blob - tests/codegen/naked-noinline.rs
Rollup merge of #107248 - erikdesjardins:addrspace, r=oli-obk
[rust.git] / tests / codegen / naked-noinline.rs
1 // Checks that naked functions are never inlined.
2 // compile-flags: -O -Zmir-opt-level=3
3 // needs-asm-support
4 // ignore-wasm32
5 #![crate_type = "lib"]
6 #![feature(naked_functions)]
7
8 use std::arch::asm;
9
10 #[naked]
11 #[no_mangle]
12 pub unsafe extern "C" fn f() {
13     // Check that f has naked and noinline attributes.
14     //
15     // CHECK:       define void @f() unnamed_addr [[ATTR:#[0-9]+]]
16     // CHECK-NEXT:  start:
17     // CHECK-NEXT:    call void asm
18     asm!("", options(noreturn));
19 }
20
21 #[no_mangle]
22 pub unsafe fn g() {
23     // Check that call to f is not inlined.
24     //
25     // CHECK-LABEL: define void @g()
26     // CHECK-NEXT:  start:
27     // CHECK-NEXT:    call void @f()
28     f();
29 }
30
31 // CHECK: attributes [[ATTR]] = { naked{{.*}}noinline{{.*}} }