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