xref: /llvm-project/llvm/test/DebugInfo/MIR/InstrRef/phi-on-stack-coalesced2.mir (revision d53425e2a33a0ff7336c86d3f668b1855c47a6de)
1# RUN: llc %s -o - -mtriple=x86_64-unknown-unknown \
2# RUN:    -experimental-debug-variable-locations \
3# RUN:    -start-before=phi-node-elimination -stop-after=virtregrewriter \
4# RUN:    | FileCheck %s
5#
6# Pass a PHI node into register allocation, and test that it is correctly
7# dropped.  In this test the desired value is an 8 bit copy of an argument,
8# but it's located in an upper subregister field. That coalesces back to the
9# whole argument, which is spilt to the stack.
10#
11# Currently, DBG_PHIs can't describe non-zero offsets in stack slots, therefore
12# no DBG_PHI should be emitted. (This means there is no value for that
13# instruction/operand number, and any DBG_INSTR_REF will become a
14# DBG_VALUE $noreg.
15
16--- |
17  ; ModuleID = 'promoted.ll'
18  source_filename = "test.c"
19  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
20  target triple = "x86_64-unknown-linux-gnu"
21
22  define dso_local i32 @foo(i32 %bar, i32 %baz) !dbg !7 {
23  entry:
24    ret i32 0, !dbg !19
25  }
26
27  declare dso_local i32 @ext(i32)
28
29  ; Function Attrs: nounwind readnone speculatable willreturn
30  declare void @llvm.dbg.value(metadata, metadata, metadata)
31
32  !llvm.dbg.cu = !{!0}
33  !llvm.module.flags = !{!3, !4, !5}
34  !llvm.ident = !{!6}
35
36  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
37  !1 = !DIFile(filename: "test.c", directory: ".")
38  !2 = !{}
39  !3 = !{i32 7, !"Dwarf Version", i32 4}
40  !4 = !{i32 2, !"Debug Info Version", i32 3}
41  !5 = !{i32 1, !"wchar_size", i32 4}
42  !6 = !{!"."}
43  !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
44  !8 = !DISubroutineType(types: !9)
45  !9 = !{!10, !10, !10}
46  !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
47  !11 = !DILocalVariable(name: "bar", arg: 1, scope: !7, file: !1, line: 2, type: !10)
48  !12 = !DILocation(line: 0, scope: !7)
49  !13 = !DILocalVariable(name: "baz", arg: 2, scope: !7, file: !1, line: 2, type: !10)
50  !14 = !DILocalVariable(name: "either", scope: !7, file: !1, line: 3, type: !10)
51  !15 = !DILocation(line: 4, column: 7, scope: !16)
52  !16 = distinct !DILexicalBlock(scope: !7, file: !1, line: 4, column: 7)
53  !17 = !DILocation(line: 4, column: 7, scope: !7)
54  !18 = !DILocation(line: 0, scope: !16)
55  !19 = !DILocation(line: 9, column: 3, scope: !7)
56
57...
58---
59name:            foo
60alignment:       16
61tracksRegLiveness: true
62debugInstrRef: true
63registers:
64  - { id: 0, class: gr8 }
65  - { id: 1, class: gr32_abcd }
66  - { id: 2, class: gr32_abcd }
67  - { id: 3, class: gr32 }
68  - { id: 4, class: gr32 }
69liveins:
70  - { reg: '$edi', virtual-reg: '%1' }
71  - { reg: '$esi', virtual-reg: '%2' }
72frameInfo:
73  maxAlignment:    1
74  adjustsStack:    true
75  hasCalls:        true
76machineFunctionInfo: {}
77body:             |
78  bb.0:
79    successors: %bb.2(0x50000000), %bb.1(0x30000000)
80    liveins: $edi, $esi
81
82    DBG_VALUE $edi, $noreg, !11, !DIExpression(), debug-location !12
83    DBG_VALUE $esi, $noreg, !13, !DIExpression(), debug-location !12
84    %2:gr32_abcd = COPY killed $esi
85    %1:gr32_abcd = COPY killed $edi
86    %5:gr8 = COPY %1.sub_8bit_hi
87    %6:gr8 = COPY %1.sub_8bit_hi
88    ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !15
89    %3:gr32 = MOV32r0 implicit-def dead $eflags
90    $edi = COPY killed %3, debug-location !15
91    CALL64pcrel32 @ext, csr_64, implicit $rsp, implicit $ssp, implicit killed $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15
92    ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !15
93    %4:gr32 = COPY killed $eax, debug-location !15
94    %10:gr32 = MOV32ri 0
95    %11:gr32 = MOV32ri 1
96    %12:gr32 = MOV32ri 2
97    %13:gr32 = MOV32ri 3
98    %14:gr32 = MOV32ri 4
99    %15:gr32 = MOV32ri 5
100    %16:gr32 = MOV32ri 6
101    %17:gr32 = MOV32ri 7
102    %18:gr32 = MOV32ri 8
103    %19:gr32 = MOV32ri 9
104    %20:gr32 = MOV32ri 10
105    %21:gr32 = MOV32ri 11
106    %22:gr32 = MOV32ri 12
107    %23:gr32 = MOV32ri 13
108    %24:gr32 = MOV32ri 14
109    TEST32rr killed %4, %4, implicit-def $eflags, debug-location !15
110    JCC_1 %bb.2, 5, implicit killed $eflags, debug-location !17
111    JMP_1 %bb.1, debug-location !17
112
113  bb.1:
114    %30:gr32 = MOV32ri 0
115    %31:gr32 = MOV32ri 1
116    %32:gr32 = MOV32ri 2
117    %33:gr32 = MOV32ri 3
118    %34:gr32 = MOV32ri 4
119    %35:gr32 = MOV32ri 5
120    %36:gr32 = MOV32ri 6
121    %37:gr32 = MOV32ri 7
122    %38:gr32 = MOV32ri 8
123    %39:gr32 = MOV32ri 9
124    %40:gr32 = MOV32ri 10
125    %41:gr32 = MOV32ri 11
126    %42:gr32 = MOV32ri 12
127    %43:gr32 = MOV32ri 13
128    %44:gr32 = MOV32ri 14
129
130    ; CHECK-LABEL: bb.2:
131  bb.2:
132    %0:gr8 = PHI %5, %bb.0, %6, %bb.1, debug-instr-number 1, debug-location !18
133    %50:gr32 = PHI %10, %bb.0, %30, %bb.1, debug-location !18
134    %51:gr32 = PHI %11, %bb.0, %31, %bb.1, debug-location !18
135    %52:gr32 = PHI %12, %bb.0, %32, %bb.1, debug-location !18
136    %53:gr32 = PHI %13, %bb.0, %33, %bb.1, debug-location !18
137    %54:gr32 = PHI %14, %bb.0, %34, %bb.1, debug-location !18
138    %55:gr32 = PHI %15, %bb.0, %35, %bb.1, debug-location !18
139    %56:gr32 = PHI %16, %bb.0, %36, %bb.1, debug-location !18
140    %57:gr32 = PHI %17, %bb.0, %37, %bb.1, debug-location !18
141    %58:gr32 = PHI %18, %bb.0, %38, %bb.1, debug-location !18
142    %59:gr32 = PHI %19, %bb.0, %39, %bb.1, debug-location !18
143    %60:gr32 = PHI %20, %bb.0, %40, %bb.1, debug-location !18
144    %61:gr32 = PHI %21, %bb.0, %41, %bb.1, debug-location !18
145    %62:gr32 = PHI %22, %bb.0, %42, %bb.1, debug-location !18
146    %63:gr32 = PHI %23, %bb.0, %43, %bb.1, debug-location !18
147    %64:gr32 = PHI %24, %bb.0, %44, %bb.1, debug-location !18
148
149    INLINEASM &"", 1, 12, %50, 12, %51, 12, %52, 12, %53, 12, %54, 12, %55, 12, %56, 12, %57, 12, %58, 12, %59, 12, %60, 12, %61, 12, %62, 12, %63, 12, %64
150    DBG_INSTR_REF !14, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !12
151    ; CHECK-NOT:  DBG_PHI
152    ; CHECK:      DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)
153    ; CHECK-NOT:  DBG_PHI
154    $eax = COPY killed %0, debug-location !19
155    RET 0, killed $eax, debug-location !19
156
157...
158