]> git.lizzy.rs Git - rust.git/blob - tests/codegen/naked-functions.rs
Rollup merge of #107194 - xfix:remove-slice-internals-dependency-in-rustc-ast, r...
[rust.git] / tests / codegen / naked-functions.rs
1 // compile-flags: -C no-prepopulate-passes -Copt-level=0
2 // needs-asm-support
3 // only-x86_64
4
5 #![crate_type = "lib"]
6 #![feature(naked_functions)]
7 use std::arch::asm;
8
9 // CHECK: Function Attrs: naked
10 // CHECK-NEXT: define{{.*}}void @naked_empty()
11 #[no_mangle]
12 #[naked]
13 pub unsafe extern "C" fn naked_empty() {
14     // CHECK-NEXT: {{.+}}:
15     // CHECK-NEXT: call void asm
16     // CHECK-NEXT: unreachable
17     asm!("ret",
18          options(noreturn));
19 }
20
21 // CHECK: Function Attrs: naked
22 // CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 %a, i64 %b)
23 #[no_mangle]
24 #[naked]
25 pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
26     // CHECK-NEXT: {{.+}}:
27     // CHECK-NEXT: call void asm
28     // CHECK-NEXT: unreachable
29     asm!("lea rax, [rdi + rsi]",
30          "ret",
31          options(noreturn));
32 }