]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/naked-noinline.rs
Create rustdoc_internals feature gate
[rust.git] / src / test / 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(asm)]
7 #![feature(naked_functions)]
8
9 #[inline(always)]
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{{.*}} }