about summary refs log tree commit diff
path: root/tests/codegen/asm/goto.rs
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2024-10-11 00:26:21 +0100
committerGary Guo <gary@garyguo.net>2024-11-24 14:18:10 +0000
commit73f8309300bce03e62c8a49e8a06b884175b5f88 (patch)
tree9c1feb6758ff77c142f728542c054c539cbcdc6e /tests/codegen/asm/goto.rs
parentb8df869ebb9219b98ca798aacb16c9be3f84496b (diff)
downloadrust-73f8309300bce03e62c8a49e8a06b884175b5f88.tar.gz
rust-73f8309300bce03e62c8a49e8a06b884175b5f88.zip
Support use of asm goto with outputs and `options(noreturn)`
When labels are present, the `noreturn` option really means that asm block
won't fallthrough -- if labels are present, then outputs can still be
meaningfully used.
Diffstat (limited to 'tests/codegen/asm/goto.rs')
-rw-r--r--tests/codegen/asm/goto.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/codegen/asm/goto.rs b/tests/codegen/asm/goto.rs
index 0e69c4d5840..3193d3aa145 100644
--- a/tests/codegen/asm/goto.rs
+++ b/tests/codegen/asm/goto.rs
@@ -43,11 +43,21 @@ pub unsafe fn asm_goto_with_outputs_use_in_label() -> u64 {
 // CHECK-LABEL: @asm_goto_noreturn
 #[no_mangle]
 pub unsafe fn asm_goto_noreturn() -> u64 {
-    let out: u64;
     // CHECK: callbr void asm sideeffect alignstack inteldialect "
     // CHECK-NEXT: to label %unreachable [label %[[JUMPBB:[a-b0-9]+]]]
     asm!("jmp {}", label { return 1; }, options(noreturn));
     // CHECK: [[JUMPBB]]:
     // CHECK-NEXT: ret i64 1
+}
+
+// CHECK-LABEL: @asm_goto_noreturn_with_outputs
+#[no_mangle]
+pub unsafe fn asm_goto_noreturn_with_outputs() -> 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!("mov {}, 1", "jmp {}", out(reg) out, label { return out; });
+    // CHECK: [[JUMPBB]]:
+    // CHECK-NEXT: ret i64 [[RES]]
     out
 }