1 # RUN: llc -start-after=phi-node-elimination -stop-after=virtregrewriter %s -mtriple=x86_64-unknown-unknown -o - | FileCheck %s
3 # Test that when a livedebugvars interval crosses a basic block boundary,
4 # DBG_VALUEs are created in each covered basic block. In the IR below, control
5 # flow moves from the bottom upwards, and the DBG_VALUEs from the entry block
6 # to bb.1 become a single range. Check that they're transformed back into two
7 # DBG_VALUEs after regalloc.
9 # These checks look at the entry and bb.1 blocks, and ensure that there is a
12 # CHECK: ![[VARNUM:[0-9]+]] = !DILocalVariable(name: "b",
13 # CHECK-LABEL: name: bar
14 # CHECK-LABEL: bb.0.entry:
15 # CHECK: DBG_VALUE $[[SOMEREG:[a-z]+]], $noreg, ![[VARNUM]], !DIExpression()
16 # CHECK-NEXT: JMP_1 %bb.3
17 # CHECK-LABEL: bb.1.bb1:
18 # CHECK: DBG_VALUE $[[SOMEREG]], $noreg, ![[VARNUM]], !DIExpression()
19 # CHECK-NEXT: JMP_1 %bb.4
23 source_filename = "tmp.ll"
24 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
26 %struct.a = type { i32 }
28 ; Function Attrs: nounwind ssp
29 define i32 @bar(%struct.a* nocapture %b, i32 %shoes) !dbg !4 {
31 tail call void @llvm.dbg.value(metadata i32 %shoes, metadata !9, metadata !DIExpression()), !dbg !16
32 %tmp1 = getelementptr inbounds %struct.a, %struct.a* %b, i64 0, i32 0, !dbg !17
36 tail call void @llvm.dbg.value(metadata i32 %shoes, metadata !9, metadata !DIExpression()), !dbg !16
37 %add = add nsw i32 %tmp2, 1, !dbg !18
41 tail call void @llvm.dbg.value(metadata i32 %tmp2, metadata !14, metadata !DIExpression()), !dbg !17
42 %call = tail call i32 (...) @foo(i32 %tmp2), !dbg !19
46 %tmp2 = load i32, i32* %tmp1, align 4, !dbg !17
50 ret i32 %shoes, !dbg !18
55 ; Function Attrs: nounwind readnone speculatable willreturn
56 declare void @llvm.dbg.value(metadata, metadata, metadata)
58 ; Function Attrs: nounwind
59 declare void @llvm.stackprotector(i8*, i8**)
62 !llvm.module.flags = !{!3}
64 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 2.9 (trunk 122997)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)
65 !1 = !DIFile(filename: "bar.c", directory: "/private/tmp")
67 !3 = !{i32 1, !"Debug Info Version", i32 3}
68 !4 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 5, type: !5, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
69 !5 = !DISubroutineType(types: !6)
71 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
73 !9 = !DILocalVariable(name: "b", arg: 1, scope: !4, file: !1, line: 5, type: !10)
74 !10 = !DIDerivedType(tag: DW_TAG_pointer_type, scope: !0, baseType: !11, size: 64, align: 64)
75 !11 = !DICompositeType(tag: DW_TAG_structure_type, name: "a", scope: !0, file: !1, line: 1, size: 32, align: 32, elements: !12)
77 !13 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !1, file: !1, line: 2, baseType: !7, size: 32, align: 32)
78 !14 = !DILocalVariable(name: "x", scope: !15, file: !1, line: 6, type: !7)
79 !15 = distinct !DILexicalBlock(scope: !4, file: !1, line: 5, column: 22)
80 !16 = !DILocation(line: 5, column: 19, scope: !4)
81 !17 = !DILocation(line: 6, column: 14, scope: !15)
82 !18 = !DILocation(line: 8, column: 2, scope: !15)
83 !19 = !DILocation(line: 7, column: 2, scope: !15)
89 tracksRegLiveness: true
91 - { id: 0, class: gr64 }
92 - { id: 1, class: gr32 }
93 - { id: 2, class: gr64 }
94 - { id: 3, class: gr64 }
95 - { id: 4, class: gr32 }
96 - { id: 5, class: gr32 }
97 - { id: 6, class: gr32 }
98 - { id: 7, class: gr32 }
100 - { reg: '$rdi', virtual-reg: '%2' }
101 - { reg: '$esi', virtual-reg: '%4' }
104 machineFunctionInfo: {}
111 %3:gr64 = COPY killed %2
112 %5:gr32 = COPY killed %4
113 DBG_VALUE %5, $noreg, !9, !DIExpression(), debug-location !16
117 DBG_VALUE %5, $noreg, !9, !DIExpression(), debug-location !16
121 DBG_VALUE %6, $noreg, !14, !DIExpression(), debug-location !17
122 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !19
123 $edi = COPY %6, debug-location !19
124 $al = MOV8ri 0, debug-location !19
125 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit $edi, implicit-def $eax, debug-location !19
126 ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !19
127 %7:gr32 = COPY $eax, debug-location !19
131 %6:gr32 = MOV32rm %3, 1, $noreg, 0, $noreg, debug-location !17 :: (load 4 from %ir.tmp1)
135 $eax = COPY %5, debug-location !18
136 RETQ implicit $eax, debug-location !18