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