[llvm] 376aa74 - [RegAllocFast] Introduce test for PR131350 (NFC)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 24 01:23:47 PDT 2025


Author: Antonio Frighetto
Date: 2025-03-24T09:19:53+01:00
New Revision: 376aa741b59f9d6a44049f007d29fca832f8a4bf

URL: https://github.com/llvm/llvm-project/commit/376aa741b59f9d6a44049f007d29fca832f8a4bf
DIFF: https://github.com/llvm/llvm-project/commit/376aa741b59f9d6a44049f007d29fca832f8a4bf.diff

LOG: [RegAllocFast] Introduce test for PR131350 (NFC)

Added: 
    llvm/test/CodeGen/X86/regallocfast-callbr-asm-spills-after-reload.mir

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/regallocfast-callbr-asm-spills-after-reload.mir b/llvm/test/CodeGen/X86/regallocfast-callbr-asm-spills-after-reload.mir
new file mode 100644
index 0000000000000..ffc4f8510c8b4
--- /dev/null
+++ b/llvm/test/CodeGen/X86/regallocfast-callbr-asm-spills-after-reload.mir
@@ -0,0 +1,68 @@
+# NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+# RUN: llc -mtriple=x86_64-- -run-pass=regallocfast -o - %s | FileCheck %s
+# RUN: llc -mtriple=x86_64-- -passes=regallocfast -o - %s | FileCheck %s
+
+...
+---
+name:            callbr-asm-spills-after-reload
+alignment:       16
+tracksRegLiveness: true
+registers:
+  - { id: 0, class: gr64, preferred-register: '', flags: [  ] }
+  - { id: 1, class: gr32, preferred-register: '', flags: [  ] }
+  - { id: 2, class: gr64, preferred-register: '', flags: [  ] }
+liveins:
+  - { reg: '$rdi', virtual-reg: '%2' }
+frameInfo:
+  isFrameAddressTaken: false
+  stackSize:       0
+  offsetAdjustment: 0
+  maxAlignment:    8
+  adjustsStack:    false
+  hasCalls:        false
+fixedStack:      []
+stack:
+  - { id: 0, type: default, offset: 0, size: 8, alignment: 8,
+      stack-id: default, callee-saved-register: '', callee-saved-restored: true }
+body:             |
+  bb.0.entry:
+    successors: %bb.1(0x40000000), %bb.3(0x40000000)
+    liveins: $rdi
+
+    %2:gr64 = COPY $rdi
+    %3:gr64 = COPY killed %2
+    MOV64mr %stack.0, 1, $noreg, 0, $noreg, %3 :: (store (s64))
+    %0:gr64 = MOV64rm %stack.0, 1, $noreg, 0, $noreg :: (dereferenceable load (s64))
+    %6:gr32 = MOV32rm %0, 1, $noreg, 0, $noreg :: (load (s32))
+    %5:gr32_norex2 = COPY %6
+    %4:gr32_norex2 = COPY %5
+    INLINEASM_BR &"  subl $$11, $0;  cmpl $$11, $0; je ${2:l};", 0 /* attdialect */, 2686986 /* regdef:GR32_NOREX2 */, def %4, 2147483657 /* reguse tiedto:$0 */, %4(tied-def 3), 13 /* imm */, %bb.3, 12 /* clobber */, implicit-def early-clobber $df, 12 /* clobber */, implicit-def early-clobber $fpsw, 12 /* clobber */, implicit-def early-clobber $eflags
+    %1:gr32 = COPY %4
+    JMP_1 %bb.1
+
+  bb.1:
+    successors: %bb.2(0x80000000)
+
+    ; CHECK:      $rax = MOV64rm %stack.3, 1, $noreg, 0, $noreg :: (load (s64) from %stack.3)
+    ; CHECK-NEXT: $ecx = MOV32rm %stack.1, 1, $noreg, 0, $noreg :: (load (s32) from %stack.1)
+    ; CHECK-NEXT: MOV32mr renamable $rax, 1, $noreg, 0, $noreg, renamable $ecx :: (store (s32))
+    MOV32mr %0, 1, $noreg, 0, $noreg, %1 :: (store (s32))
+
+  bb.2:
+    RET64
+
+  bb.3 (machine-block-address-taken, inlineasm-br-indirect-target):
+    successors: %bb.2(0x80000000)
+
+    ; FIXME: This is a miscompilation, as, despite spilling the value modified by the inlineasm_br,
+    ; the reload emitted still reads from an uninitialized stack slot.
+    ; CHECK:      $ecx = MOV32rm %stack.2, 1, $noreg, 0, $noreg :: (load (s32) from %stack.2)
+    ; CHECK-NEXT: MOV32mr %stack.2, 1, $noreg, 0, $noreg, $eax :: (store (s32) into %stack.2)
+    ; CHECK-NEXT: $rax = MOV64rm %stack.3, 1, $noreg, 0, $noreg :: (load (s64) from %stack.3)
+    ; CHECK-NEXT: MOV32mr renamable $rax, 1, $noreg, 0, $noreg, killed renamable $ecx :: (store (s32))
+    ; CHECK-NEXT: JMP_1 %bb.2
+    %7:gr32 = COPY %4
+    MOV32mr %0, 1, $noreg, 0, $noreg, %7 :: (store (s32))
+    JMP_1 %bb.2
+
+...


        


More information about the llvm-commits mailing list