1 # RUN: llc -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
2 # RUN: llc -force-instr-ref-livedebugvalues=1 -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
4 #extern void fn1 (int, int, int);
5 #__attribute__((noinline))
7 #fn2 (int a, int b, int c) {
19 # CHECK: ![[ARG_C:.*]] = !DILocalVariable(name: "c"
21 # CHECK: DBG_VALUE $edx, $noreg, ![[ARG_C]], !DIExpression(DW_OP_LLVM_entry_value, 1)
22 # CHECK: bb.1.if.then:
23 # CHECK: DBG_VALUE $edx, $noreg, ![[ARG_C]], !DIExpression(DW_OP_LLVM_entry_value, 1)
24 # CHECK: bb.2.if.else:
25 # CHECK: DBG_VALUE $edx, $noreg, ![[ARG_C]], !DIExpression(DW_OP_LLVM_entry_value, 1)
27 # CHECK: DBG_VALUE $edx, $noreg, ![[ARG_C]], !DIExpression(DW_OP_LLVM_entry_value, 1)
31 source_filename = "test.c"
32 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
33 target triple = "x86_64-unknown-linux-gnu"
35 ; Function Attrs: noinline nounwind uwtable
36 define dso_local i32 @fn2(i32 %a, i32 %b, i32 %c) local_unnamed_addr !dbg !12 {
38 call void @llvm.dbg.value(metadata i32 %a, metadata !16, metadata !DIExpression()), !dbg !20
39 call void @llvm.dbg.value(metadata i32 %b, metadata !17, metadata !DIExpression()), !dbg !20
40 call void @llvm.dbg.value(metadata i32 %c, metadata !18, metadata !DIExpression()), !dbg !20
41 %add = add nsw i32 %a, 2, !dbg !21
42 call void @llvm.dbg.value(metadata i32 %add, metadata !19, metadata !DIExpression()), !dbg !20
43 tail call void @fn1(i32 5, i32 6, i32 %add), !dbg !22
44 %cmp = icmp slt i32 %b, 17, !dbg !23
45 br i1 %cmp, label %if.then, label %if.else, !dbg !25
47 if.then: ; preds = %entry
48 %add1 = add nsw i32 %b, 7, !dbg !26
49 call void @llvm.dbg.value(metadata i32 %add1, metadata !17, metadata !DIExpression()), !dbg !20
50 tail call void @fn1(i32 5, i32 %add1, i32 %add), !dbg !28
51 br label %if.end, !dbg !29
53 if.else: ; preds = %entry
54 %add2 = add nuw nsw i32 %b, 1, !dbg !30
55 call void @llvm.dbg.value(metadata i32 %add2, metadata !17, metadata !DIExpression()), !dbg !20
56 tail call void @fn1(i32 1, i32 %add2, i32 %add), !dbg !32
59 if.end: ; preds = %if.else, %if.then
60 %b.addr.0 = phi i32 [ %add1, %if.then ], [ %add2, %if.else ], !dbg !33
61 call void @llvm.dbg.value(metadata i32 %b.addr.0, metadata !17, metadata !DIExpression()), !dbg !20
62 ret i32 %b.addr.0, !dbg !34
65 declare !dbg !4 dso_local void @fn1(i32, i32, i32) local_unnamed_addr
67 ; Function Attrs: nounwind readnone speculatable willreturn
68 declare void @llvm.dbg.value(metadata, metadata, metadata)
71 !llvm.module.flags = !{!8, !9, !10}
74 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
75 !1 = !DIFile(filename: "test.c", directory: "/")
78 !4 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
79 !5 = !DISubroutineType(types: !6)
80 !6 = !{null, !7, !7, !7}
81 !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
82 !8 = !{i32 2, !"Dwarf Version", i32 4}
83 !9 = !{i32 2, !"Debug Info Version", i32 3}
84 !10 = !{i32 1, !"wchar_size", i32 4}
85 !11 = !{!"clang version 10.0.0"}
86 !12 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 5, type: !13, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)
87 !13 = !DISubroutineType(types: !14)
88 !14 = !{!7, !7, !7, !7}
89 !15 = !{!16, !17, !18, !19}
90 !16 = !DILocalVariable(name: "a", arg: 1, scope: !12, file: !1, line: 5, type: !7)
91 !17 = !DILocalVariable(name: "b", arg: 2, scope: !12, file: !1, line: 5, type: !7)
92 !18 = !DILocalVariable(name: "c", arg: 3, scope: !12, file: !1, line: 5, type: !7)
93 !19 = !DILocalVariable(name: "q", scope: !12, file: !1, line: 7, type: !7)
94 !20 = !DILocation(line: 0, scope: !12)
95 !21 = !DILocation(line: 7, column: 15, scope: !12)
96 !22 = !DILocation(line: 9, column: 5, scope: !12)
97 !23 = !DILocation(line: 11, column: 11, scope: !24)
98 !24 = distinct !DILexicalBlock(scope: !12, file: !1, line: 11, column: 9)
99 !25 = !DILocation(line: 11, column: 9, scope: !12)
100 !26 = !DILocation(line: 12, column: 13, scope: !27)
101 !27 = distinct !DILexicalBlock(scope: !24, file: !1, line: 11, column: 17)
102 !28 = !DILocation(line: 13, column: 8, scope: !27)
103 !29 = !DILocation(line: 14, column: 5, scope: !27)
104 !30 = !DILocation(line: 15, column: 13, scope: !31)
105 !31 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 12)
106 !32 = !DILocation(line: 16, column: 7, scope: !31)
107 !33 = !DILocation(line: 0, scope: !24)
108 !34 = !DILocation(line: 19, column: 5, scope: !12)
116 successors: %bb.1(0x40000000), %bb.2(0x40000000)
117 liveins: $edi, $esi, $rbp, $rbx
119 DBG_VALUE $edi, $noreg, !16, !DIExpression(), debug-location !20
120 DBG_VALUE $esi, $noreg, !17, !DIExpression(), debug-location !20
121 DBG_VALUE $edx, $noreg, !18, !DIExpression(), debug-location !20
122 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
123 CFI_INSTRUCTION def_cfa_offset 16
124 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
125 CFI_INSTRUCTION def_cfa_offset 24
126 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
127 CFI_INSTRUCTION def_cfa_offset 32
128 CFI_INSTRUCTION offset $rbx, -24
129 CFI_INSTRUCTION offset $rbp, -16
131 DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20
133 DBG_VALUE $ebp, $noreg, !16, !DIExpression(), debug-location !20
134 renamable $ebp = nsw ADD32ri8 killed renamable $ebp, 2, implicit-def dead $eflags, debug-location !21
135 DBG_VALUE $ebp, $noreg, !19, !DIExpression(), debug-location !20
136 $edi = MOV32ri 5, debug-location !22
137 $esi = MOV32ri 6, debug-location !22
138 $edx = MOV32rr $ebp, debug-location !22
139 CALL64pcrel32 @fn1, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit killed $edx, implicit-def $rsp, implicit-def $ssp, debug-location !22
140 CMP32ri8 renamable $ebx, 16, implicit-def $eflags, debug-location !23
141 JCC_1 %bb.2, 15, implicit killed $eflags, debug-location !25
144 successors: %bb.3(0x80000000)
147 renamable $ebx = nsw ADD32ri8 killed renamable $ebx, 7, implicit-def dead $eflags, debug-location !26
148 DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20
149 $edi = MOV32ri 5, debug-location !28
153 successors: %bb.3(0x80000000)
156 renamable $ebx = nuw nsw ADD32ri8 killed renamable $ebx, 1, implicit-def dead $eflags, debug-location !30
157 DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20
158 $edi = MOV32ri 1, debug-location !32
161 liveins: $ebx, $edi, $ebp
163 $esi = MOV32rr $ebx, debug-location !33
164 $edx = MOV32rr killed $ebp, debug-location !33
165 CALL64pcrel32 @fn1, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit killed $edx, implicit-def $rsp, implicit-def $ssp, debug-location !33
166 DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20
167 $eax = MOV32rr killed $ebx, debug-location !34
168 $rsp = frame-destroy ADD64ri8 $rsp, 8, implicit-def dead $eflags, debug-location !34
169 CFI_INSTRUCTION def_cfa_offset 24, debug-location !34
170 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !34
171 CFI_INSTRUCTION def_cfa_offset 16, debug-location !34
172 $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !34
173 CFI_INSTRUCTION def_cfa_offset 8, debug-location !34
174 RETQ killed $eax, debug-location !34