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