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 1, 0
12 # CHECK: DBG_INSTR_REF 2, 0
15 # CHECK: DBG_INSTR_REF 3, 0
16 # CHECK-NEXT: CALL64pcrel32
18 # CHECK: DBG_INSTR_REF 4, 0
22 # The fast register allocator puts some spills in -- these are no-ops as far
23 # as the slot indexes are concerned. It doesn't matter which side of spills
24 # the DBG_INSTR_REF lands on.
26 # FASTREG-LABEL: bb.0:
27 # FASTREG-DAG: DBG_INSTR_REF 1, 0
28 # FASTREG-DAG: MOV64mr
29 # FASTREG-DAG: MOV32mr
31 # FASTREG-LABEL: bb.1:
32 # FASTREG: DBG_INSTR_REF 2, 0
34 # FASTREG-LABEL: bb.2:
35 # FASTREG: DBG_INSTR_REF 3, 0
36 # FASTREG-NEXT: CALL64pcrel32
37 # FASTREG-LABEL: bb.3:
38 # FASTREG-DAG: MOV32rm
39 # FASTREG-DAG: DBG_INSTR_REF 4, 0
40 # FASTREG-DAG: MOV32mr
42 # FASTREG-LABEL: bb.4:
43 # FASTREG: DBG_INSTR_REF 5, 0
48 source_filename = "tmp.ll"
49 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
51 %struct.a = type { i32 }
53 ; Function Attrs: nounwind ssp
54 define i32 @bar() !dbg !4 {
60 ; Function Attrs: nounwind readnone speculatable willreturn
61 declare void @llvm.dbg.value(metadata, metadata, metadata)
64 !llvm.module.flags = !{!3}
66 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "asdf", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)
67 !1 = !DIFile(filename: "bar.c", directory: "asdf")
69 !3 = !{i32 1, !"Debug Info Version", i32 3}
70 !4 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 5, type: !5, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
71 !5 = !DISubroutineType(types: !6)
73 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
75 !9 = !DILocalVariable(name: "b", arg: 1, scope: !4, file: !1, line: 5, type: !10)
76 !10 = !DIDerivedType(tag: DW_TAG_pointer_type, scope: !0, baseType: !11, size: 64, align: 64)
77 !11 = !DICompositeType(tag: DW_TAG_structure_type, name: "a", scope: !0, file: !1, line: 1, size: 32, align: 32, elements: !12)
79 !13 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !1, file: !1, line: 2, baseType: !7, size: 32, align: 32)
80 !14 = !DILocalVariable(name: "x", scope: !15, file: !1, line: 6, type: !7)
81 !15 = distinct !DILexicalBlock(scope: !4, file: !1, line: 5, column: 22)
82 !16 = !DILocation(line: 5, column: 19, scope: !4)
83 !17 = !DILocation(line: 6, column: 14, scope: !15)
84 !18 = !DILocation(line: 8, column: 2, scope: !15)
85 !19 = !DILocation(line: 7, column: 2, scope: !15)
91 tracksRegLiveness: true
93 - { id: 0, class: gr64 }
94 - { id: 1, class: gr32 }
95 - { id: 2, class: gr64 }
96 - { id: 3, class: gr64 }
97 - { id: 4, class: gr32 }
98 - { id: 5, class: gr32 }
99 - { id: 6, class: gr32 }
100 - { id: 7, class: gr32 }
102 - { reg: '$rdi', virtual-reg: '%2' }
103 - { reg: '$esi', virtual-reg: '%4' }
106 machineFunctionInfo: {}
113 %3:gr64 = COPY killed %2
114 %5:gr32 = COPY killed %4
115 DBG_INSTR_REF 1, 0, !9, !DIExpression(), debug-location !16
119 DBG_INSTR_REF 2, 0, !9, !DIExpression(), debug-location !16
123 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !19
124 $edi = COPY %6, debug-location !19
125 $al = MOV8ri 0, debug-location !19
126 DBG_INSTR_REF 3, 0, !9, !DIExpression(), debug-location !16
127 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit $edi, implicit-def $eax, debug-location !19
128 ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !19
129 %7:gr32 = COPY $eax, debug-location !19
133 %6:gr32 = MOV32rm %3, 1, $noreg, 0, $noreg, debug-location !17
134 DBG_INSTR_REF 4, 0, !9, !DIExpression(), debug-location !16
138 $eax = COPY %5, debug-location !18
139 DBG_INSTR_REF 5, 0, !9, !DIExpression(), debug-location !16
140 RETQ implicit $eax, debug-location !18