about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2024-10-11 00:23:32 +0100
committerGary Guo <gary@garyguo.net>2024-11-24 14:18:10 +0000
commitb8df869ebb9219b98ca798aacb16c9be3f84496b (patch)
tree387e3bf6c0ba767d6e9ec9e463925a5f91b9de98 /tests/codegen
parentf5d18576856ef45d1e47de79889ae7db9d1afa29 (diff)
downloadrust-b8df869ebb9219b98ca798aacb16c9be3f84496b.tar.gz
rust-b8df869ebb9219b98ca798aacb16c9be3f84496b.zip
Fix asm goto with outputs
When outputs are used together with labels, they are considered
to be written for all destinations, not only when falling through.
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/asm/goto.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/tests/codegen/asm/goto.rs b/tests/codegen/asm/goto.rs
index e522d0da5b4..0e69c4d5840 100644
--- a/tests/codegen/asm/goto.rs
+++ b/tests/codegen/asm/goto.rs
@@ -6,17 +6,6 @@
 
 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_goto
 #[no_mangle]
 pub unsafe fn asm_goto() {
@@ -38,6 +27,19 @@ pub unsafe fn asm_goto_with_outputs() -> u64 {
     out
 }
 
+// CHECK-LABEL: @asm_goto_with_outputs_use_in_label
+#[no_mangle]
+pub unsafe fn asm_goto_with_outputs_use_in_label() -> u64 {
+    let out: u64;
+    // CHECK: [[RES:%[0-9]+]] = callbr i64 asm sideeffect alignstack inteldialect "
+    // CHECK-NEXT: to label %[[FALLTHROUGHBB:[a-b0-9]+]] [label %[[JUMPBB:[a-b0-9]+]]]
+    asm!("{} /* {} */", out(reg) out, label { return out; });
+    // CHECK: [[JUMPBB]]:
+    // CHECK-NEXT: [[RET:%.+]] = phi i64 [ 1, %[[FALLTHROUGHBB]] ], [ [[RES]], %start ]
+    // CHECK-NEXT: ret i64 [[RET]]
+    1
+}
+
 // CHECK-LABEL: @asm_goto_noreturn
 #[no_mangle]
 pub unsafe fn asm_goto_noreturn() -> u64 {