File: may_unwind.rs

package info (click to toggle)
rustc-web 1.85.0%2Bdfsg3-1~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,759,988 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,056; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (39 lines) | stat: -rw-r--r-- 870 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//@ compile-flags: -O
//@ only-x86_64

#![crate_type = "rlib"]
#![feature(asm_unwind)]

use std::arch::asm;

#[no_mangle]
pub extern "C" fn panicky() {}

struct Foo;

impl Drop for Foo {
    fn drop(&mut self) {
        println!();
    }
}

// CHECK-LABEL: @asm_may_unwind
#[no_mangle]
pub unsafe fn asm_may_unwind() {
    let _m = Foo;
    // CHECK: invoke void asm sideeffect alignstack inteldialect unwind ""
    asm!("", options(may_unwind));
}

// 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
}