1 # RUN: llc -start-after=phi-node-elimination -stop-after=virtregrewriter %s -mtriple=x86_64-unknown-unknown -o - -experimental-debug-variable-locations | FileCheck %s
2 # RUN: llc -O0 -start-after=phi-node-elimination -stop-after=regallocfast %s -mtriple=x86_64-unknown-unknown -o - -experimental-debug-variable-locations | FileCheck %s --check-prefix=FASTREG
4 # Test that DBG_INSTR_REFs can pass through livedebugvariables to the end of
5 # regalloc without problem. Program body copied from
6 # livedebugvars-crossbb-interval.mir.
9 # CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)
10 # CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0), dbg-instr-ref(2, 0)
13 # CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(2, 0)
14 # CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(2, 0), dbg-instr-ref(3, 0)
17 # CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(3, 0)
18 # CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(3, 0), dbg-instr-ref(4, 0)
19 # CHECK-NEXT: CALL64pcrel32
21 # CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(4, 0)
22 # CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(4, 0), dbg-instr-ref(5, 0)
26 # The fast register allocator puts some spills in -- these are no-ops as far
27 # as the slot indexes are concerned. It doesn't matter which side of spills
28 # the DBG_INSTR_REF lands on.
30 # FASTREG-LABEL: bb.0:
31 # FASTREG-DAG: DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)
32 # FASTREG-DAG: DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0), dbg-instr-ref(2, 0)
33 # FASTREG-DAG: MOV64mr
34 # FASTREG-DAG: MOV32mr
36 # FASTREG-LABEL: bb.1:
37 # FASTREG: DBG_INSTR_REF {{.+}}, dbg-instr-ref(2, 0)
38 # FASTREG-DAG: DBG_INSTR_REF {{.+}}, dbg-instr-ref(2, 0), dbg-instr-ref(3, 0)
40 # FASTREG-LABEL: bb.2:
41 # FASTREG: DBG_INSTR_REF {{.+}}, dbg-instr-ref(3, 0)
42 # FASTREG-DAG: DBG_INSTR_REF {{.+}}, dbg-instr-ref(3, 0), dbg-instr-ref(4, 0)
43 # FASTREG-NEXT: CALL64pcrel32
44 # FASTREG-LABEL: bb.3:
45 # FASTREG-DAG: MOV32rm
46 # FASTREG-DAG: DBG_INSTR_REF {{.+}}, dbg-instr-ref(4, 0)
47 # FASTREG-DAG: DBG_INSTR_REF {{.+}}, dbg-instr-ref(4, 0), dbg-instr-ref(5, 0)
48 # FASTREG-DAG: MOV32mr
50 # FASTREG-LABEL: bb.4:
51 # FASTREG: DBG_INSTR_REF {{.+}}, dbg-instr-ref(5, 0)
52 # FASTREG-DAG: DBG_INSTR_REF {{.+}}, dbg-instr-ref(5, 0), dbg-instr-ref(1, 0)
57 source_filename = "tmp.ll"
58 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
60 %struct.a = type { i32 }
62 ; Function Attrs: nounwind ssp
63 define i32 @bar() !dbg !4 {
69 ; Function Attrs: nounwind readnone speculatable willreturn
70 declare void @llvm.dbg.value(metadata, metadata, metadata)
73 !llvm.module.flags = !{!3}
75 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "asdf", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)
76 !1 = !DIFile(filename: "bar.c", directory: "asdf")
78 !3 = !{i32 1, !"Debug Info Version", i32 3}
79 !4 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 5, type: !5, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
80 !5 = !DISubroutineType(types: !6)
82 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
84 !9 = !DILocalVariable(name: "b", arg: 1, scope: !4, file: !1, line: 5, type: !10)
85 !10 = !DIDerivedType(tag: DW_TAG_pointer_type, scope: !0, baseType: !11, size: 64, align: 64)
86 !11 = !DICompositeType(tag: DW_TAG_structure_type, name: "a", scope: !0, file: !1, line: 1, size: 32, align: 32, elements: !12)
88 !13 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !1, file: !1, line: 2, baseType: !7, size: 32, align: 32)
89 !14 = !DILocalVariable(name: "x", scope: !15, file: !1, line: 6, type: !7)
90 !15 = distinct !DILexicalBlock(scope: !4, file: !1, line: 5, column: 22)
91 !16 = !DILocation(line: 5, column: 19, scope: !4)
92 !17 = !DILocation(line: 6, column: 14, scope: !15)
93 !18 = !DILocation(line: 8, column: 2, scope: !15)
94 !19 = !DILocation(line: 7, column: 2, scope: !15)
95 !29 = !DILocalVariable(name: "c", scope: !4, file: !1, line: 5, type: !10)
101 tracksRegLiveness: true
104 - { id: 0, class: gr64 }
105 - { id: 1, class: gr32 }
106 - { id: 2, class: gr64 }
107 - { id: 3, class: gr64 }
108 - { id: 4, class: gr32 }
109 - { id: 5, class: gr32 }
110 - { id: 6, class: gr32 }
111 - { id: 7, class: gr32 }
113 - { reg: '$rdi', virtual-reg: '%2' }
114 - { reg: '$esi', virtual-reg: '%4' }
117 machineFunctionInfo: {}
124 %3:gr64 = COPY killed %2
125 %5:gr32 = COPY killed %4
126 DBG_INSTR_REF !9, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !16
127 DBG_INSTR_REF !29, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), dbg-instr-ref(1, 0), dbg-instr-ref(2, 0), debug-location !16
131 DBG_INSTR_REF !9, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(2, 0), debug-location !16
132 DBG_INSTR_REF !29, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), dbg-instr-ref(2, 0), dbg-instr-ref(3, 0), debug-location !16
136 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !19
137 $edi = COPY %6, debug-location !19
138 $al = MOV8ri 0, debug-location !19
139 DBG_INSTR_REF !9, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(3, 0), debug-location !16
140 DBG_INSTR_REF !29, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), dbg-instr-ref(3, 0), dbg-instr-ref(4, 0), debug-location !16
141 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit $edi, implicit-def $eax, debug-location !19
142 ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !19
143 %7:gr32 = COPY $eax, debug-location !19
147 %6:gr32 = MOV32rm %3, 1, $noreg, 0, $noreg, debug-location !17
148 DBG_INSTR_REF !9, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(4, 0), debug-location !16
149 DBG_INSTR_REF !29, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), dbg-instr-ref(4, 0), dbg-instr-ref(5, 0), debug-location !16
153 $eax = COPY %5, debug-location !18
154 DBG_INSTR_REF !9, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(5, 0), debug-location !16
155 DBG_INSTR_REF !29, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), dbg-instr-ref(5, 0), dbg-instr-ref(1, 0), debug-location !16
156 RET64 implicit $eax, debug-location !18