File tree Expand file tree Collapse file tree 4 files changed +95
-0
lines changed Expand file tree Collapse file tree 4 files changed +95
-0
lines changed Original file line number Diff line number Diff line change
1
+ // min-llvm-version: 13.0.0
2
+ // compile-flags: -O
3
+
4
+ #![ crate_type = "rlib" ]
5
+ #![ feature( asm, asm_unwind) ]
6
+
7
+ #[ no_mangle]
8
+ pub extern "C" fn panicky ( ) { }
9
+
10
+ struct Foo ;
11
+
12
+ impl Drop for Foo {
13
+ fn drop ( & mut self ) {
14
+ println ! ( ) ;
15
+ }
16
+ }
17
+
18
+ // CHECK-LABEL: @may_unwind
19
+ // CHECK: invoke void asm sideeffect alignstack unwind
20
+ #[ no_mangle]
21
+ pub unsafe fn may_unwind ( ) {
22
+ let _m = Foo ;
23
+ asm ! ( "" , options( may_unwind) ) ;
24
+ }
Original file line number Diff line number Diff line change
1
+ // min-llvm-version: 13.0.0
2
+ // only-aarch64
3
+ // run-pass
4
+ // needs-asm-support
5
+
6
+ #![ feature( asm, asm_unwind) ]
7
+
8
+ use std:: panic:: { catch_unwind, resume_unwind, AssertUnwindSafe } ;
9
+
10
+ struct Foo < ' a > ( & ' a mut bool ) ;
11
+
12
+ impl Drop for Foo < ' _ > {
13
+ fn drop ( & mut self ) {
14
+ * self . 0 = false ;
15
+ }
16
+ }
17
+
18
+ #[ no_mangle]
19
+ extern "C" fn panicky ( ) {
20
+ resume_unwind ( Box :: new ( ( ) ) ) ;
21
+ }
22
+
23
+ fn main ( ) {
24
+ let flag = & mut true ;
25
+ catch_unwind ( AssertUnwindSafe ( || {
26
+ let _foo = Foo ( flag) ;
27
+ unsafe { asm ! ( "bl _panicky" , options( may_unwind) ) } ;
28
+ } ) )
29
+ . expect_err ( "expected a panic" ) ;
30
+ assert_eq ! ( * flag, false ) ;
31
+ }
Original file line number Diff line number Diff line change
1
+ // min-llvm-version: 13.0.0
2
+ // run-pass
3
+ // needs-asm-support
4
+
5
+ #![ feature( asm, asm_unwind) ]
6
+
7
+ fn main ( ) {
8
+ unsafe { asm ! ( "" , options( may_unwind) ) } ;
9
+ }
Original file line number Diff line number Diff line change
1
+ // min-llvm-version: 13.0.0
2
+ // only-x86_64
3
+ // run-pass
4
+ // needs-asm-support
5
+
6
+ #![ feature( asm, asm_unwind) ]
7
+
8
+ use std:: panic:: { catch_unwind, resume_unwind, AssertUnwindSafe } ;
9
+
10
+ struct Foo < ' a > ( & ' a mut bool ) ;
11
+
12
+ impl Drop for Foo < ' _ > {
13
+ fn drop ( & mut self ) {
14
+ * self . 0 = false ;
15
+ }
16
+ }
17
+
18
+ #[ no_mangle]
19
+ extern "C" fn panicky ( ) {
20
+ resume_unwind ( Box :: new ( ( ) ) ) ;
21
+ }
22
+
23
+ fn main ( ) {
24
+ let flag = & mut true ;
25
+ catch_unwind ( AssertUnwindSafe ( || {
26
+ let _foo = Foo ( flag) ;
27
+ unsafe { asm ! ( "call panicky" , options( may_unwind) ) } ;
28
+ } ) )
29
+ . expect_err ( "expected a panic" ) ;
30
+ assert_eq ! ( * flag, false ) ;
31
+ }
You can’t perform that action at this time.
0 commit comments