]> git.lizzy.rs Git - rust.git/blob - tests/codegen/asm-may_unwind.rs
Auto merge of #106520 - ehuss:update-mdbook, r=Mark-Simulacrum
[rust.git] / tests / codegen / asm-may_unwind.rs
1 // compile-flags: -O
2 // only-x86_64
3
4 #![crate_type = "rlib"]
5 #![feature(asm_unwind)]
6
7 use std::arch::asm;
8
9 #[no_mangle]
10 pub extern "C" fn panicky() {}
11
12 struct Foo;
13
14 impl Drop for Foo {
15     fn drop(&mut self) {
16         println!();
17     }
18 }
19
20 // CHECK-LABEL: @asm_may_unwind
21 #[no_mangle]
22 pub unsafe fn asm_may_unwind() {
23     let _m = Foo;
24     // CHECK: invoke void asm sideeffect alignstack inteldialect unwind ""
25     asm!("", options(may_unwind));
26 }
27
28 // CHECK-LABEL: @asm_with_result_may_unwind
29 #[no_mangle]
30 pub unsafe fn asm_with_result_may_unwind() -> u64 {
31     let _m = Foo;
32     let res: u64;
33     // CHECK: [[RES:%[0-9]+]] = invoke i64 asm sideeffect alignstack inteldialect unwind
34     // CHECK-NEXT: to label %[[NORMALBB:[a-b0-9]+]]
35     asm!("mov {}, 1", out(reg) res, options(may_unwind));
36     // CHECK: [[NORMALBB]]:
37     // CHECK: ret i64 [[RES:%[0-9]+]]
38     res
39 }