xref: /llvm-project/llvm/test/DebugInfo/MIR/InstrRef/x86-fixup-bw-inst-subreb.mir (revision 9f8544713ad8e57fb74cbfce3fbc7fff523e549f)
1# RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass x86-fixup-bw-insts %s -o - -experimental-debug-variable-locations | FileCheck  %s
2#
3# This test is a copy of llvm/test/CodeGen/X86/fixup-bw-inst.mir, with a few
4# test bodies removed. The pass promotes certain register operations to be
5# wider operations (such as loads and sign extensions), which has an instruction
6# encoding benefit. New instructions are created, and so should have a debug
7# instruction number substitution; but in addition a qualifiying subregister,
8# because the newly def'd register is a different size to the old one.
9#
10# Plain copies that get transformed are not tested for, as they should never
11# be instrumented. At a high level, copies do not define a value; they move
12# them.
13
14---
15# CHECK-LABEL: name: test1
16name:            test1
17alignment:       16
18tracksRegLiveness: true
19debugInstrRef: true
20liveins:
21  - { reg: '$rax' }
22# CHECK:     debugValueSubstitutions:
23# CHECK-NEXT - { srcinst: 1, srcop: 0, dstinst: 2, dstop: 0, subreg: 4 }
24## Subreg 4 -> sub_16bit
25body:             |
26  bb.0:
27    liveins: $rax
28
29    $ax = MOV16rm killed $rax, 1, $noreg, 0, $noreg, debug-instr-number 1
30    ; CHECK: $eax = MOVZX32rm16 killed $rax, {{.*}} debug-instr-number 2
31
32    RET64 $ax
33
34...
35---
36# CHECK-LABEL: name: test3
37name:            test3
38alignment:       16
39tracksRegLiveness: true
40debugInstrRef: true
41liveins:
42  - { reg: '$rdi' }
43# CHECK:     debugValueSubstitutions:
44# CHECK-NEXT - { srcinst: 1, srcop: 0, dstinst: 2, dstop: 0, subreg: 4 }
45## Subreg 4 -> sub_16bit
46body:             |
47  bb.0:
48    successors: %bb.1(0x30000000), %bb.2(0x50000000)
49    liveins: $rdi
50
51    TEST64rr $rdi, $rdi, implicit-def $eflags
52    JCC_1 %bb.1, 4, implicit $eflags
53
54  bb.2:
55    liveins: $rdi
56
57    $ax = MOV16rm killed $rdi, 1, $noreg, 0, $noreg, implicit-def $eax, debug-instr-number 1
58    ; CHECK: $eax = MOVZX32rm16 killed $rdi, {{.*}} debug-instr-number 2
59    $ax = KILL $ax, implicit killed $eax
60    RET64 $ax
61
62  bb.1:
63    $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
64    $ax = KILL $ax, implicit killed $eax
65    RET64 $ax
66
67...
68