about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-19 06:57:59 +0000
committerbors <bors@rust-lang.org>2022-05-19 06:57:59 +0000
commit67a9bcb31b85e87cc8bb327022632e48a0ca64a8 (patch)
treeae2039ac8b0a9ce6bc74ed1982ab4eafe26b8d17 /src/test
parent50872bdb99c96716ee50a3b9613c395302b99767 (diff)
parentaf7f53d6d0f05b953d9364ae81339f6e185a9957 (diff)
downloadrust-67a9bcb31b85e87cc8bb327022632e48a0ca64a8.tar.gz
rust-67a9bcb31b85e87cc8bb327022632e48a0ca64a8.zip
Auto merge of #97103 - luqmana:asm-unwind-cleanup, r=Amanieu,tmiasko
Update MIR passes to handle unwinding Inline Asm

Some more follow up fixes from https://github.com/rust-lang/rust/pull/95864#issuecomment-1094165398

r? `@Amanieu`
Diffstat (limited to 'src/test')
-rw-r--r--src/test/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir24
-rw-r--r--src/test/mir-opt/asm_unwind_panic_abort.rs16
2 files changed, 40 insertions, 0 deletions
diff --git a/src/test/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir b/src/test/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir
new file mode 100644
index 00000000000..44d722d6f9b
--- /dev/null
+++ b/src/test/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir
@@ -0,0 +1,24 @@
+// MIR for `main` after AbortUnwindingCalls
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/asm_unwind_panic_abort.rs:12:11: 12:11
+    let _1: ();                          // in scope 0 at $DIR/asm_unwind_panic_abort.rs:14:9: 14:49
+    scope 1 {
+    }
+
+    bb0: {
+        StorageLive(_1);                 // scope 1 at $DIR/asm_unwind_panic_abort.rs:14:9: 14:49
+        _1 = const ();                   // scope 1 at $DIR/asm_unwind_panic_abort.rs:14:9: 14:49
+        asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind: bb2]; // scope 1 at $DIR/asm_unwind_panic_abort.rs:14:9: 14:49
+    }
+
+    bb1: {
+        StorageDead(_1);                 // scope 1 at $DIR/asm_unwind_panic_abort.rs:14:48: 14:49
+        _0 = const ();                   // scope 1 at $DIR/asm_unwind_panic_abort.rs:13:5: 15:6
+        return;                          // scope 0 at $DIR/asm_unwind_panic_abort.rs:16:2: 16:2
+    }
+
+    bb2 (cleanup): {
+        abort;                           // scope 0 at $DIR/asm_unwind_panic_abort.rs:12:1: 16:2
+    }
+}
diff --git a/src/test/mir-opt/asm_unwind_panic_abort.rs b/src/test/mir-opt/asm_unwind_panic_abort.rs
new file mode 100644
index 00000000000..8201d54348a
--- /dev/null
+++ b/src/test/mir-opt/asm_unwind_panic_abort.rs
@@ -0,0 +1,16 @@
+//! Tests that unwinding from an asm block is caught and forced to abort
+//! when `-C panic=abort`.
+
+// min-llvm-version: 13.0.0
+// only-x86_64
+// compile-flags: -C panic=abort
+// no-prefer-dynamic
+
+#![feature(asm_unwind)]
+
+// EMIT_MIR asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir
+fn main() {
+    unsafe {
+        std::arch::asm!("", options(may_unwind));
+    }
+}