about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-10-29 16:08:16 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-10-29 16:08:16 +0000
commitb1e705146a26f5b650360edf2ecf05fec1315c33 (patch)
tree10e14e7565054599f1f66d27302703fcd88cc53e
parent827a6d8d9f0b84fec8fd15c336d845a05435889d (diff)
downloadrust-b1e705146a26f5b650360edf2ecf05fec1315c33.tar.gz
rust-b1e705146a26f5b650360edf2ecf05fec1315c33.zip
Unconditionally handle int $$0x29 using a shim
-rw-r--r--src/inline_asm.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/inline_asm.rs b/src/inline_asm.rs
index 0517c609337..b2e27399055 100644
--- a/src/inline_asm.rs
+++ b/src/inline_asm.rs
@@ -45,6 +45,14 @@ pub(crate) fn codegen_inline_asm<'tcx>(
 ) {
     // FIXME add .eh_frame unwind info directives
 
+    // Used by panic_abort on Windows, but uses a syntax which only happens to work with
+    // asm!() by accident and breaks with the GNU assembler as well as global_asm!() for
+    // the LLVM backend.
+    if template[0] == InlineAsmTemplatePiece::String("int $$0x29".to_string()) {
+        fx.bcx.ins().trap(TrapCode::User(1));
+        return;
+    }
+
     if !asm_supported(fx.tcx) {
         if template.is_empty() {
             let destination_block = fx.get_block(destination.unwrap());
@@ -52,12 +60,6 @@ pub(crate) fn codegen_inline_asm<'tcx>(
             return;
         }
 
-        // Used by panic_abort
-        if template[0] == InlineAsmTemplatePiece::String("int $$0x29".to_string()) {
-            fx.bcx.ins().trap(TrapCode::User(1));
-            return;
-        }
-
         // Used by stdarch
         if template[0] == InlineAsmTemplatePiece::String("mov ".to_string())
             && matches!(