rust/tests/codegen/naked-functions.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
839 B
Rust
Raw Normal View History

2022-12-30 14:11:30 -06:00
// compile-flags: -C no-prepopulate-passes -Copt-level=0
// needs-asm-support
// only-x86_64
2016-03-21 15:13:50 -05:00
#![crate_type = "lib"]
#![feature(naked_functions)]
use std::arch::asm;
2016-03-21 15:13:50 -05:00
// CHECK: Function Attrs: naked
// CHECK-NEXT: define{{.*}}void @naked_empty()
2016-03-21 15:13:50 -05:00
#[no_mangle]
#[naked]
pub unsafe extern "C" fn naked_empty() {
// CHECK-NEXT: {{.+}}:
// CHECK-NEXT: call void asm
// CHECK-NEXT: unreachable
asm!("ret",
options(noreturn));
2016-03-21 15:13:50 -05:00
}
// CHECK: Function Attrs: naked
2022-12-30 14:11:30 -06:00
// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 %a, i64 %b)
2016-03-21 15:13:50 -05:00
#[no_mangle]
#[naked]
pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
// CHECK-NEXT: {{.+}}:
// CHECK-NEXT: call void asm
// CHECK-NEXT: unreachable
asm!("lea rax, [rdi + rsi]",
"ret",
options(noreturn));
2016-03-21 15:13:50 -05:00
}