2022-12-30 20:11:30 +00:00
|
|
|
// compile-flags: -C no-prepopulate-passes -Copt-level=0
|
2022-01-21 00:00:00 +00:00
|
|
|
// needs-asm-support
|
|
|
|
// only-x86_64
|
2016-03-21 20:13:50 +00:00
|
|
|
|
|
|
|
#![crate_type = "lib"]
|
2016-08-24 03:36:37 +00:00
|
|
|
#![feature(naked_functions)]
|
2022-01-21 00:00:00 +00:00
|
|
|
use std::arch::asm;
|
2016-03-21 20:13:50 +00:00
|
|
|
|
2018-09-26 16:19:55 +00:00
|
|
|
// CHECK: Function Attrs: naked
|
2021-03-27 22:11:24 +00:00
|
|
|
// CHECK-NEXT: define{{.*}}void @naked_empty()
|
2016-03-21 20:13:50 +00:00
|
|
|
#[no_mangle]
|
|
|
|
#[naked]
|
2022-01-21 00:00:00 +00:00
|
|
|
pub unsafe extern "C" fn naked_empty() {
|
2017-03-08 18:08:09 +00:00
|
|
|
// CHECK-NEXT: {{.+}}:
|
2022-01-21 00:00:00 +00:00
|
|
|
// CHECK-NEXT: call void asm
|
|
|
|
// CHECK-NEXT: unreachable
|
|
|
|
asm!("ret",
|
|
|
|
options(noreturn));
|
2016-03-21 20:13:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-26 16:19:55 +00:00
|
|
|
// CHECK: Function Attrs: naked
|
2022-12-30 20:11:30 +00:00
|
|
|
// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 %a, i64 %b)
|
2016-03-21 20:13:50 +00:00
|
|
|
#[no_mangle]
|
|
|
|
#[naked]
|
2022-01-21 00:00:00 +00:00
|
|
|
pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
|
2017-03-08 18:08:09 +00:00
|
|
|
// CHECK-NEXT: {{.+}}:
|
2022-01-21 00:00:00 +00:00
|
|
|
// CHECK-NEXT: call void asm
|
|
|
|
// CHECK-NEXT: unreachable
|
|
|
|
asm!("lea rax, [rdi + rsi]",
|
|
|
|
"ret",
|
|
|
|
options(noreturn));
|
2016-03-21 20:13:50 +00:00
|
|
|
}
|