2021-11-13 20:08:12 -06:00
|
|
|
//@ compile-flags: -O
|
2021-12-03 16:53:31 -06:00
|
|
|
//@ only-x86_64
|
2021-11-13 20:08:12 -06:00
|
|
|
|
|
|
|
#![crate_type = "rlib"]
|
2021-12-09 18:15:33 -06:00
|
|
|
#![feature(asm_unwind)]
|
|
|
|
|
|
|
|
use std::arch::asm;
|
2021-11-13 20:08:12 -06:00
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn panicky() {}
|
|
|
|
|
|
|
|
struct Foo;
|
|
|
|
|
|
|
|
impl Drop for Foo {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
println!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-09 17:16:38 -05:00
|
|
|
// CHECK-LABEL: @asm_may_unwind
|
2021-11-13 20:08:12 -06:00
|
|
|
#[no_mangle]
|
2022-04-09 17:16:38 -05:00
|
|
|
pub unsafe fn asm_may_unwind() {
|
2021-11-13 20:08:12 -06:00
|
|
|
let _m = Foo;
|
2021-11-28 12:35:31 -06:00
|
|
|
// CHECK: invoke void asm sideeffect alignstack inteldialect unwind ""
|
2021-11-13 20:08:12 -06:00
|
|
|
asm!("", options(may_unwind));
|
|
|
|
}
|
2022-04-09 17:16:38 -05:00
|
|
|
|
|
|
|
// CHECK-LABEL: @asm_with_result_may_unwind
|
|
|
|
#[no_mangle]
|
|
|
|
pub unsafe fn asm_with_result_may_unwind() -> u64 {
|
|
|
|
let _m = Foo;
|
|
|
|
let res: u64;
|
|
|
|
// CHECK: [[RES:%[0-9]+]] = invoke i64 asm sideeffect alignstack inteldialect unwind
|
|
|
|
// CHECK-NEXT: to label %[[NORMALBB:[a-b0-9]+]]
|
|
|
|
asm!("mov {}, 1", out(reg) res, options(may_unwind));
|
|
|
|
// CHECK: [[NORMALBB]]:
|
|
|
|
// CHECK: ret i64 [[RES:%[0-9]+]]
|
|
|
|
res
|
|
|
|
}
|