blob: a7f311c4c09d784f4e1d1f119f1eb0dbe3fdc0ef [file] [log] [blame]
Justin Lebarc75d5662016-02-19 00:18:46 +00001# RUN: llc -run-pass=livedebugvalues -march=x86-64 -o /dev/null %s 2>&1 | FileCheck %s
Vikram TV859ad292015-12-16 11:09:48 +00002
3# Test the extension of debug ranges from 3 predecessors.
4# Generated from the source file LiveDebugValues-3preds.c:
5# #include <stdio.h>
6# int add(int x, int y, int z, int a) {
7# int i;
8# for (i = 0; i < x * y; i++) {
9# if (i < x) {
10# a = a * x;
11# break;
12# }
13# if (i < y) {
14# a = a * y;
15# break;
16# }
17# if (i < z) {
18# a = a * z;
19# break;
20# }
21# }
22# return a;
23# }
24# with clang -g -O1 -c -emit-llvm LiveDebugValues-3preds.c -S -o live-debug-values-3preds.ll
25# then llc -stop-after stackmap-liveness live-debug-values-3preds.ll -o /dev/null > live-debug-values-3preds.mir
26
27# DBG_VALUE for variables "x", "y" and "z" are extended into BB#9 from its
28# predecessors BB#0, BB#2 and BB#8.
29# CHECK: bb.9.for.end:
30# CHECK: DBG_VALUE debug-use %edx, debug-use _, !11, !17, debug-location !21
31# CHECK-NEXT: DBG_VALUE debug-use %esi, debug-use _, !10, !17, debug-location !19
32# CHECK-NEXT: DBG_VALUE debug-use %edi, debug-use _, !9, !17, debug-location !18
33
34
35--- |
36 ; ModuleID = 'live-debug-values-3preds.ll'
37 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
38 target triple = "x86_64-unknown-linux-gnu"
39
40 ; Function Attrs: norecurse nounwind readnone uwtable
41 define i32 @add(i32 %x, i32 %y, i32 %z, i32 %a) #0 !dbg !4 {
42 entry:
43 tail call void @llvm.dbg.value(metadata i32 %x, i64 0, metadata !9, metadata !17), !dbg !18
44 tail call void @llvm.dbg.value(metadata i32 %y, i64 0, metadata !10, metadata !17), !dbg !19
45 tail call void @llvm.dbg.value(metadata i32 %z, i64 0, metadata !11, metadata !17), !dbg !21
46 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !12, metadata !17), !dbg !23
47 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !13, metadata !17), !dbg !25
48 %mul = mul nsw i32 %y, %x, !dbg !26
49 %cmp.24 = icmp sgt i32 %mul, 0, !dbg !30
50 br i1 %cmp.24, label %for.body.preheader, label %for.end, !dbg !31
51
52 for.body.preheader: ; preds = %entry
53 br label %for.body, !dbg !32
54
55 for.cond: ; preds = %if.end.6
56 %cmp = icmp slt i32 %inc, %mul, !dbg !30
57 br i1 %cmp, label %for.body, label %for.end, !dbg !31
58
59 for.body: ; preds = %for.cond, %for.body.preheader
60 %i.025 = phi i32 [ %inc, %for.cond ], [ 0, %for.body.preheader ]
61 %0 = icmp sgt i32 %x, 0
62 br i1 %0, label %if.then, label %if.end, !dbg !35
63
64 if.then: ; preds = %for.body
65 %mul2 = mul nsw i32 %a, %x, !dbg !36
66 tail call void @llvm.dbg.value(metadata i32 %mul2, i64 0, metadata !12, metadata !17), !dbg !23
67 br label %for.end, !dbg !38
68
69 if.end: ; preds = %for.body
70 %1 = icmp sgt i32 %y, 0
71 br i1 %1, label %if.then.4, label %if.end.6, !dbg !39
72
73 if.then.4: ; preds = %if.end
74 %mul5 = mul nsw i32 %a, %y, !dbg !40
75 tail call void @llvm.dbg.value(metadata i32 %mul5, i64 0, metadata !12, metadata !17), !dbg !23
76 br label %for.end, !dbg !43
77
78 if.end.6: ; preds = %if.end
79 %2 = icmp sgt i32 %z, 0
80 %inc = add nuw nsw i32 %i.025, 1, !dbg !44
81 tail call void @llvm.dbg.value(metadata i32 %inc, i64 0, metadata !13, metadata !17), !dbg !25
82 br i1 %2, label %if.then.8, label %for.cond, !dbg !45
83
84 if.then.8: ; preds = %if.end.6
85 %mul9 = mul nsw i32 %a, %z, !dbg !46
86 tail call void @llvm.dbg.value(metadata i32 %mul9, i64 0, metadata !12, metadata !17), !dbg !23
87 br label %for.end, !dbg !49
88
89 for.end: ; preds = %for.cond, %if.then.8, %if.then.4, %if.then, %entry
90 %a.addr.0 = phi i32 [ %mul2, %if.then ], [ %mul5, %if.then.4 ], [ %mul9, %if.then.8 ], [ %a, %entry ], [ %a, %for.cond ]
91 ret i32 %a.addr.0, !dbg !50
92 }
93
94 ; Function Attrs: nounwind readnone
95 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
96
97 attributes #0 = { norecurse nounwind readnone uwtable }
98 attributes #1 = { nounwind readnone }
99
100 !llvm.dbg.cu = !{!0}
101 !llvm.module.flags = !{!14, !15}
102 !llvm.ident = !{!16}
103
104 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 253049) ", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)
105 !1 = !DIFile(filename: "LiveDebugValues-3preds.c", directory: "/home/vt/julia/test/tvvikram")
106 !2 = !{}
107 !3 = !{!4}
108 !4 = distinct !DISubprogram(name: "add", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, variables: !8)
109 !5 = !DISubroutineType(types: !6)
110 !6 = !{!7, !7, !7, !7, !7}
111 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
112 !8 = !{!9, !10, !11, !12, !13}
113 !9 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !1, line: 1, type: !7)
114 !10 = !DILocalVariable(name: "y", arg: 2, scope: !4, file: !1, line: 1, type: !7)
115 !11 = !DILocalVariable(name: "z", arg: 3, scope: !4, file: !1, line: 1, type: !7)
116 !12 = !DILocalVariable(name: "a", arg: 4, scope: !4, file: !1, line: 1, type: !7)
117 !13 = !DILocalVariable(name: "i", scope: !4, file: !1, line: 2, type: !7)
118 !14 = !{i32 2, !"Dwarf Version", i32 4}
119 !15 = !{i32 2, !"Debug Info Version", i32 3}
120 !16 = !{!"clang version 3.8.0 (trunk 253049) "}
121 !17 = !DIExpression()
122 !18 = !DILocation(line: 1, column: 13, scope: !4)
123 !19 = !DILocation(line: 1, column: 20, scope: !20)
124 !20 = !DILexicalBlockFile(scope: !4, file: !1, discriminator: 1)
125 !21 = !DILocation(line: 1, column: 27, scope: !22)
126 !22 = !DILexicalBlockFile(scope: !4, file: !1, discriminator: 2)
127 !23 = !DILocation(line: 1, column: 34, scope: !24)
128 !24 = !DILexicalBlockFile(scope: !4, file: !1, discriminator: 3)
129 !25 = !DILocation(line: 2, column: 7, scope: !20)
130 !26 = !DILocation(line: 3, column: 21, scope: !27)
131 !27 = !DILexicalBlockFile(scope: !28, file: !1, discriminator: 1)
132 !28 = distinct !DILexicalBlock(scope: !29, file: !1, line: 3, column: 3)
133 !29 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3, column: 3)
134 !30 = !DILocation(line: 3, column: 17, scope: !27)
135 !31 = !DILocation(line: 3, column: 3, scope: !27)
136 !32 = !DILocation(line: 4, column: 11, scope: !33)
137 !33 = distinct !DILexicalBlock(scope: !34, file: !1, line: 4, column: 9)
138 !34 = distinct !DILexicalBlock(scope: !28, file: !1, line: 3, column: 31)
139 !35 = !DILocation(line: 4, column: 9, scope: !34)
140 !36 = !DILocation(line: 5, column: 13, scope: !37)
141 !37 = distinct !DILexicalBlock(scope: !33, file: !1, line: 4, column: 16)
142 !38 = !DILocation(line: 6, column: 7, scope: !37)
143 !39 = !DILocation(line: 8, column: 9, scope: !34)
144 !40 = !DILocation(line: 9, column: 13, scope: !41)
145 !41 = distinct !DILexicalBlock(scope: !42, file: !1, line: 8, column: 16)
146 !42 = distinct !DILexicalBlock(scope: !34, file: !1, line: 8, column: 9)
147 !43 = !DILocation(line: 10, column: 7, scope: !41)
148 !44 = !DILocation(line: 3, column: 27, scope: !28)
149 !45 = !DILocation(line: 12, column: 9, scope: !34)
150 !46 = !DILocation(line: 13, column: 13, scope: !47)
151 !47 = distinct !DILexicalBlock(scope: !48, file: !1, line: 12, column: 16)
152 !48 = distinct !DILexicalBlock(scope: !34, file: !1, line: 12, column: 9)
153 !49 = !DILocation(line: 14, column: 7, scope: !47)
154 !50 = !DILocation(line: 17, column: 3, scope: !4)
155
156...
157---
158name: add
159alignment: 4
160exposesReturnsTwice: false
161hasInlineAsm: false
Derek Schuffad154c82016-03-28 17:05:30 +0000162allVRegsAllocated: true
Vikram TV859ad292015-12-16 11:09:48 +0000163isSSA: false
164tracksRegLiveness: true
165tracksSubRegLiveness: false
166liveins:
167 - { reg: '%edi' }
168 - { reg: '%esi' }
169 - { reg: '%edx' }
170 - { reg: '%ecx' }
171frameInfo:
172 isFrameAddressTaken: false
173 isReturnAddressTaken: false
174 hasStackMap: false
175 hasPatchPoint: false
176 stackSize: 0
177 offsetAdjustment: 0
178 maxAlignment: 0
179 adjustsStack: false
180 hasCalls: false
181 maxCallFrameSize: 0
182 hasOpaqueSPAdjustment: false
183 hasVAStart: false
184 hasMustTailInVarArgFunc: false
185body: |
186 bb.0.entry:
187 successors: %bb.1.for.body.preheader(20), %bb.9.for.end(12)
188 liveins: %ecx, %edi, %edx, %esi
189
190 DBG_VALUE debug-use %edi, debug-use _, !9, !17, debug-location !18
191 DBG_VALUE debug-use %esi, debug-use _, !10, !17, debug-location !19
192 DBG_VALUE debug-use %edx, debug-use _, !11, !17, debug-location !21
193 DBG_VALUE debug-use %ecx, debug-use _, !12, !17, debug-location !23
194 DBG_VALUE 0, 0, !13, !17, debug-location !25
195 %r8d = MOV32rr %esi, debug-location !26
196 %r8d = IMUL32rr killed %r8d, %edi, implicit-def dead %eflags, debug-location !26
197 TEST32rr %r8d, %r8d, implicit-def %eflags, debug-location !31
198 JLE_1 %bb.9.for.end, implicit %eflags
199
200 bb.1.for.body.preheader:
201 successors: %bb.3.for.body(0)
202 liveins: %ecx, %edi, %edx, %esi, %r8d
203
204 DBG_VALUE debug-use %edi, debug-use _, !9, !17, debug-location !18
205 DBG_VALUE debug-use %esi, debug-use _, !10, !17, debug-location !19
206 DBG_VALUE debug-use %edx, debug-use _, !11, !17, debug-location !21
207 DBG_VALUE debug-use %ecx, debug-use _, !12, !17, debug-location !23
208 DBG_VALUE 0, 0, !13, !17, debug-location !25
209 %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
210
211 bb.3.for.body (align 4):
212 successors: %bb.4.if.then(4), %bb.5.if.end(124)
213 liveins: %eax, %ecx, %edi, %edx, %esi, %r8d
214
215 DBG_VALUE debug-use %edi, debug-use _, !9, !17, debug-location !18
216 DBG_VALUE debug-use %esi, debug-use _, !10, !17, debug-location !19
217 DBG_VALUE debug-use %edx, debug-use _, !11, !17, debug-location !21
218 DBG_VALUE debug-use %ecx, debug-use _, !12, !17, debug-location !23
219 DBG_VALUE 0, 0, !13, !17, debug-location !25
220 TEST32rr %edi, %edi, implicit-def %eflags, debug-location !35
221 JG_1 %bb.4.if.then, implicit %eflags
222
223 bb.5.if.end:
224 successors: %bb.6.if.then.4(4), %bb.7.if.end.6(124)
225 liveins: %eax, %ecx, %edi, %edx, %esi, %r8d
226
227 DBG_VALUE debug-use %edi, debug-use _, !9, !17, debug-location !18
228 DBG_VALUE debug-use %esi, debug-use _, !10, !17, debug-location !19
229 DBG_VALUE debug-use %edx, debug-use _, !11, !17, debug-location !21
230 DBG_VALUE debug-use %ecx, debug-use _, !12, !17, debug-location !23
231 DBG_VALUE 0, 0, !13, !17, debug-location !25
232 TEST32rr %esi, %esi, implicit-def %eflags, debug-location !39
233 JG_1 %bb.6.if.then.4, implicit %eflags
234
235 bb.7.if.end.6:
236 successors: %bb.8.if.then.8(4), %bb.2.for.cond(124)
237 liveins: %eax, %ecx, %edi, %edx, %esi, %r8d
238
239 DBG_VALUE debug-use %edi, debug-use _, !9, !17, debug-location !18
240 DBG_VALUE debug-use %esi, debug-use _, !10, !17, debug-location !19
241 DBG_VALUE debug-use %edx, debug-use _, !11, !17, debug-location !21
242 DBG_VALUE debug-use %ecx, debug-use _, !12, !17, debug-location !23
243 DBG_VALUE 0, 0, !13, !17, debug-location !25
244 TEST32rr %edx, %edx, implicit-def %eflags, debug-location !45
245 JG_1 %bb.8.if.then.8, implicit %eflags
246
247 bb.2.for.cond:
248 successors: %bb.3.for.body(124), %bb.9.for.end(4)
249 liveins: %eax, %ecx, %edi, %edx, %esi, %r8d
250
251 DBG_VALUE debug-use %edi, debug-use _, !9, !17, debug-location !18
252 DBG_VALUE debug-use %esi, debug-use _, !10, !17, debug-location !19
253 DBG_VALUE debug-use %edx, debug-use _, !11, !17, debug-location !21
254 DBG_VALUE debug-use %ecx, debug-use _, !12, !17, debug-location !23
255 DBG_VALUE 0, 0, !13, !17, debug-location !25
256 %eax = INC32r killed %eax, implicit-def dead %eflags, debug-location !44
257 DBG_VALUE debug-use %eax, debug-use _, !13, !17, debug-location !25
258 CMP32rr %eax, %r8d, implicit-def %eflags, debug-location !31
259 JL_1 %bb.3.for.body, implicit %eflags
260 JMP_1 %bb.9.for.end
261
262 bb.4.if.then:
263 liveins: %ecx, %edi
264
265 DBG_VALUE debug-use %edi, debug-use _, !9, !17, debug-location !18
266 DBG_VALUE debug-use %ecx, debug-use _, !12, !17, debug-location !23
267 DBG_VALUE 0, 0, !13, !17, debug-location !25
268 %ecx = IMUL32rr killed %ecx, killed %edi, implicit-def dead %eflags, debug-location !36
269 DBG_VALUE 0, 0, !13, !17, debug-location !25
270 %eax = MOV32rr killed %ecx, debug-location !50
271 RETQ %eax, debug-location !50
272
273 bb.6.if.then.4:
274 liveins: %ecx, %esi
275
276 DBG_VALUE debug-use %esi, debug-use _, !10, !17, debug-location !19
277 DBG_VALUE debug-use %ecx, debug-use _, !12, !17, debug-location !23
278 DBG_VALUE 0, 0, !13, !17, debug-location !25
279 %ecx = IMUL32rr killed %ecx, killed %esi, implicit-def dead %eflags, debug-location !40
280 DBG_VALUE 0, 0, !13, !17, debug-location !25
281 %eax = MOV32rr killed %ecx, debug-location !50
282 RETQ %eax, debug-location !50
283
284 bb.8.if.then.8:
285 successors: %bb.9.for.end(0)
286 liveins: %ecx, %edx
287
288 DBG_VALUE debug-use %edx, debug-use _, !11, !17, debug-location !21
289 DBG_VALUE debug-use %ecx, debug-use _, !12, !17, debug-location !23
290 DBG_VALUE 0, 0, !13, !17, debug-location !25
291 %ecx = IMUL32rr killed %ecx, killed %edx, implicit-def dead %eflags, debug-location !46
292
293 bb.9.for.end:
294 liveins: %ecx
295
296 DBG_VALUE 0, 0, !13, !17, debug-location !25
297 %eax = MOV32rr killed %ecx, debug-location !50
298 RETQ %eax, debug-location !50
299
300...