1 # RUN: llc -o - %s -start-after=patchable-function -O0 -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
3 # Test dwarf codegen of:
4 # - DW_OP_constu, X, DW_OP_minus
5 # - DW_OP_constu, X, DW_OP_plus
6 # - DW_OP_plus_uconst, X
7 # when feeding a DW_OP_breg.
9 # Internally in LLVM the value X is saved as an "uint64_t". But when
10 # DwarfExpression::addMachineRegExpression is trying to simplify the DWARF by
11 # folding such expressions into a DW_OP_breg (or DW_OP_fbreg) the offset is
12 # converted to an "int". We must be careful when doing those folds, checking
13 # that X is in the range for "int".
16 define void @test() !dbg !5 {
22 !llvm.module.flags = !{!3, !4}
24 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
25 !1 = !DIFile(filename: "1.cc", directory: "/tmp")
27 !3 = !{i32 2, !"Dwarf Version", i32 4}
28 !4 = !{i32 2, !"Debug Info Version", i32 3}
29 !5 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 4, type: !6, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
30 !6 = !DISubroutineType(types: !7)
33 !9 = !DILocalVariable(name: "buf", scope: !5, file: !1, line: 5, type: !10)
34 !10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 3200, align: 32, elements: !12)
35 !11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
37 !13 = !DISubrange(count: 100)
38 !14 = !DILocation(line: 7, column: 1, scope: !5)
43 tracksRegLiveness: true
46 bb.0: ;-------------------------- DW_OP_plus -------------------------------
49 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
50 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 4294967295, DW_OP_minus), debug-location !14
53 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
54 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 4294967296, DW_OP_minus), debug-location !14
57 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
58 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 2147483647, DW_OP_minus), debug-location !14
61 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
62 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 2147483648, DW_OP_minus), debug-location !14
65 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
66 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 0, DW_OP_minus), debug-location !14
69 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
70 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 18446744073709551615, DW_OP_minus), debug-location !14
73 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
74 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 18446744073709551614, DW_OP_minus), debug-location !14
76 RETQ debug-location !14
79 bb.1: ;-------------------------- DW_OP_plus -------------------------------
82 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
83 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 4294967295, DW_OP_plus), debug-location !14
86 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
87 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 4294967296, DW_OP_plus), debug-location !14
90 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
91 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 2147483647, DW_OP_plus), debug-location !14
94 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
95 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 2147483648, DW_OP_plus), debug-location !14
98 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
99 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 0, DW_OP_plus), debug-location !14
102 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
103 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 18446744073709551615, DW_OP_plus), debug-location !14
106 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
107 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 18446744073709551614, DW_OP_plus), debug-location !14
109 RETQ debug-location !14
112 bb.2: ;-------------------------- DW_OP_plus_uconst -------------------------------
115 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
116 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_plus_uconst, 4294967295), debug-location !14
119 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
120 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_plus_uconst, 4294967296), debug-location !14
123 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
124 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_plus_uconst, 2147483647), debug-location !14
127 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
128 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_plus_uconst, 2147483648), debug-location !14
131 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
132 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_plus_uconst, 0), debug-location !14
135 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
136 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_plus_uconst, 18446744073709551615), debug-location !14
139 renamable $rcx = MOV64rm renamable $noreg, 1, $noreg, 0, $fs
140 DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_plus_uconst, 18446744073709551614), debug-location !14
142 RETQ debug-location !14
147 # CHECK-LABEL: .Ldebug_loc0:
148 # CHECK-NEXT: .quad .Ltmp0-.Lfunc_begin0
149 # CHECK-NEXT: .quad .Ltmp1-.Lfunc_begin0
150 # CHECK-NEXT: .short 9 # Loc expr size
151 # CHECK-NEXT: .byte 114 # DW_OP_breg2
152 # CHECK-NEXT: .byte 0 # 0
153 # CHECK-NEXT: .byte 16 # DW_OP_constu
154 # CHECK-NEXT: .byte 255 # 4294967295
155 # CHECK-NEXT: .byte 255 #
156 # CHECK-NEXT: .byte 255 #
157 # CHECK-NEXT: .byte 255 #
158 # CHECK-NEXT: .byte 15 #
159 # CHECK-NEXT: .byte 28 # DW_OP_minus
160 # CHECK-NEXT: .quad .Ltmp1-.Lfunc_begin0
161 # CHECK-NEXT: .quad .Ltmp2-.Lfunc_begin0
162 # CHECK-NEXT: .short 9 # Loc expr size
163 # CHECK-NEXT: .byte 114 # DW_OP_breg2
164 # CHECK-NEXT: .byte 0 # 0
165 # CHECK-NEXT: .byte 16 # DW_OP_constu
166 # CHECK-NEXT: .byte 128 # 4294967296
167 # CHECK-NEXT: .byte 128 #
168 # CHECK-NEXT: .byte 128 #
169 # CHECK-NEXT: .byte 128 #
170 # CHECK-NEXT: .byte 16 #
171 # CHECK-NEXT: .byte 28 # DW_OP_minus
172 # CHECK-NEXT: .quad .Ltmp2-.Lfunc_begin0
173 # CHECK-NEXT: .quad .Ltmp3-.Lfunc_begin0
174 # CHECK-NEXT: .short 6 # Loc expr size
175 # CHECK-NEXT: .byte 114 # DW_OP_breg2
176 # CHECK-NEXT: .byte 129 # -2147483647
177 # CHECK-NEXT: .byte 128 #
178 # CHECK-NEXT: .byte 128 #
179 # CHECK-NEXT: .byte 128 #
180 # CHECK-NEXT: .byte 120 #
181 # CHECK-NEXT: .quad .Ltmp3-.Lfunc_begin0
182 # CHECK-NEXT: .quad .Ltmp4-.Lfunc_begin0
183 # CHECK-NEXT: .short 6 # Loc expr size
184 # CHECK-NEXT: .byte 114 # DW_OP_breg2
185 # CHECK-NEXT: .byte 128 # -2147483648
186 # CHECK-NEXT: .byte 128 #
187 # CHECK-NEXT: .byte 128 #
188 # CHECK-NEXT: .byte 128 #
189 # CHECK-NEXT: .byte 120 #
190 # CHECK-NEXT: .quad .Ltmp4-.Lfunc_begin0
191 # CHECK-NEXT: .quad .Ltmp5-.Lfunc_begin0
192 # CHECK-NEXT: .short 2 # Loc expr size
193 # CHECK-NEXT: .byte 114 # DW_OP_breg2
194 # CHECK-NEXT: .byte 0 # 0
195 # CHECK-NEXT: .quad .Ltmp5-.Lfunc_begin0
196 # CHECK-NEXT: .quad .Ltmp6-.Lfunc_begin0
197 # CHECK-NEXT: .short 5 # Loc expr size
198 # CHECK-NEXT: .byte 114 # DW_OP_breg2
199 # CHECK-NEXT: .byte 0 # 0
200 # CHECK-NEXT: .byte 48 # DW_OP_lit0
201 # CHECK-NEXT: .byte 32 # DW_OP_not
202 # CHECK-NEXT: .byte 28 # DW_OP_minus
203 # CHECK-NEXT: .quad .Ltmp6-.Lfunc_begin0
204 # CHECK-NEXT: .quad .Ltmp7-.Lfunc_begin0
205 # CHECK-NEXT: .short 14 # Loc expr size
206 # CHECK-NEXT: .byte 114 # DW_OP_breg2
207 # CHECK-NEXT: .byte 0 # 0
208 # CHECK-NEXT: .byte 16 # DW_OP_constu
209 # CHECK-NEXT: .byte 254 # 18446744073709551614
210 # CHECK-NEXT: .byte 255 #
211 # CHECK-NEXT: .byte 255 #
212 # CHECK-NEXT: .byte 255 #
213 # CHECK-NEXT: .byte 255 #
214 # CHECK-NEXT: .byte 255 #
215 # CHECK-NEXT: .byte 255 #
216 # CHECK-NEXT: .byte 255 #
217 # CHECK-NEXT: .byte 255 #
218 # CHECK-NEXT: .byte 1 #
219 # CHECK-NEXT: .byte 28 # DW_OP_minus
220 #-----------------------------------------------------------------------
221 # CHECK-NEXT: .quad .Ltmp8-.Lfunc_begin0
222 # CHECK-NEXT: .quad .Ltmp9-.Lfunc_begin0
223 # CHECK-NEXT: .short 9 # Loc expr size
224 # CHECK-NEXT: .byte 114 # DW_OP_breg2
225 # CHECK-NEXT: .byte 0 # 0
226 # CHECK-NEXT: .byte 16 # DW_OP_constu
227 # CHECK-NEXT: .byte 255 # 4294967295
228 # CHECK-NEXT: .byte 255 #
229 # CHECK-NEXT: .byte 255 #
230 # CHECK-NEXT: .byte 255 #
231 # CHECK-NEXT: .byte 15 #
232 # CHECK-NEXT: .byte 34 # DW_OP_plus
233 # CHECK-NEXT: .quad .Ltmp9-.Lfunc_begin0
234 # CHECK-NEXT: .quad .Ltmp10-.Lfunc_begin0
235 # CHECK-NEXT: .short 9 # Loc expr size
236 # CHECK-NEXT: .byte 114 # DW_OP_breg2
237 # CHECK-NEXT: .byte 0 # 0
238 # CHECK-NEXT: .byte 16 # DW_OP_constu
239 # CHECK-NEXT: .byte 128 # 4294967296
240 # CHECK-NEXT: .byte 128 #
241 # CHECK-NEXT: .byte 128 #
242 # CHECK-NEXT: .byte 128 #
243 # CHECK-NEXT: .byte 16 #
244 # CHECK-NEXT: .byte 34 # DW_OP_plus
245 # CHECK-NEXT: .quad .Ltmp10-.Lfunc_begin0
246 # CHECK-NEXT: .quad .Ltmp11-.Lfunc_begin0
247 # CHECK-NEXT: .short 6 # Loc expr size
248 # CHECK-NEXT: .byte 114 # DW_OP_breg2
249 # CHECK-NEXT: .byte 255 # 2147483647
250 # CHECK-NEXT: .byte 255 #
251 # CHECK-NEXT: .byte 255 #
252 # CHECK-NEXT: .byte 255 #
253 # CHECK-NEXT: .byte 7 #
254 # CHECK-NEXT: .quad .Ltmp11-.Lfunc_begin0
255 # CHECK-NEXT: .quad .Ltmp12-.Lfunc_begin0
256 # CHECK-NEXT: .short 9 # Loc expr size
257 # CHECK-NEXT: .byte 114 # DW_OP_breg2
258 # CHECK-NEXT: .byte 0 # 0
259 # CHECK-NEXT: .byte 16 # DW_OP_constu
260 # CHECK-NEXT: .byte 128 # 2147483648
261 # CHECK-NEXT: .byte 128 #
262 # CHECK-NEXT: .byte 128 #
263 # CHECK-NEXT: .byte 128 #
264 # CHECK-NEXT: .byte 8 #
265 # CHECK-NEXT: .byte 34 # DW_OP_plus
266 # CHECK-NEXT: .quad .Ltmp12-.Lfunc_begin0
267 # CHECK-NEXT: .quad .Ltmp13-.Lfunc_begin0
268 # CHECK-NEXT: .short 2 # Loc expr size
269 # CHECK-NEXT: .byte 114 # DW_OP_breg2
270 # CHECK-NEXT: .byte 0 # 0
271 # CHECK-NEXT: .quad .Ltmp13-.Lfunc_begin0
272 # CHECK-NEXT: .quad .Ltmp14-.Lfunc_begin0
273 # CHECK-NEXT: .short 5 # Loc expr size
274 # CHECK-NEXT: .byte 114 # DW_OP_breg2
275 # CHECK-NEXT: .byte 0 # 0
276 # CHECK-NEXT: .byte 48 # DW_OP_lit0
277 # CHECK-NEXT: .byte 32 # DW_OP_not
278 # CHECK-NEXT: .byte 34 # DW_OP_plus
279 # CHECK-NEXT: .quad .Ltmp14-.Lfunc_begin0
280 # CHECK-NEXT: .quad .Ltmp15-.Lfunc_begin0
281 # CHECK-NEXT: .short 14 # Loc expr size
282 # CHECK-NEXT: .byte 114 # DW_OP_breg2
283 # CHECK-NEXT: .byte 0 # 0
284 # CHECK-NEXT: .byte 16 # DW_OP_constu
285 # CHECK-NEXT: .byte 254 # 18446744073709551614
286 # CHECK-NEXT: .byte 255 #
287 # CHECK-NEXT: .byte 255 #
288 # CHECK-NEXT: .byte 255 #
289 # CHECK-NEXT: .byte 255 #
290 # CHECK-NEXT: .byte 255 #
291 # CHECK-NEXT: .byte 255 #
292 # CHECK-NEXT: .byte 255 #
293 # CHECK-NEXT: .byte 255 #
294 # CHECK-NEXT: .byte 1 #
295 # CHECK-NEXT: .byte 34 # DW_OP_plus
296 #-----------------------------------------------------------------------
297 # CHECK-NEXT: .quad .Ltmp16-.Lfunc_begin0
298 # CHECK-NEXT: .quad .Ltmp17-.Lfunc_begin0
299 # CHECK-NEXT: .short 8 # Loc expr size
300 # CHECK-NEXT: .byte 114 # DW_OP_breg2
301 # CHECK-NEXT: .byte 0 # 0
302 # CHECK-NEXT: .byte 35 # DW_OP_plus_uconst
303 # CHECK-NEXT: .byte 255 # 4294967295
304 # CHECK-NEXT: .byte 255 #
305 # CHECK-NEXT: .byte 255 #
306 # CHECK-NEXT: .byte 255 #
307 # CHECK-NEXT: .byte 15 #
308 # CHECK-NEXT: .quad .Ltmp17-.Lfunc_begin0
309 # CHECK-NEXT: .quad .Ltmp18-.Lfunc_begin0
310 # CHECK-NEXT: .short 8 # Loc expr size
311 # CHECK-NEXT: .byte 114 # DW_OP_breg2
312 # CHECK-NEXT: .byte 0 # 0
313 # CHECK-NEXT: .byte 35 # DW_OP_plus_uconst
314 # CHECK-NEXT: .byte 128 # 4294967296
315 # CHECK-NEXT: .byte 128 #
316 # CHECK-NEXT: .byte 128 #
317 # CHECK-NEXT: .byte 128 #
318 # CHECK-NEXT: .byte 16 #
319 # CHECK-NEXT: .quad .Ltmp18-.Lfunc_begin0
320 # CHECK-NEXT: .quad .Ltmp19-.Lfunc_begin0
321 # CHECK-NEXT: .short 6 # Loc expr size
322 # CHECK-NEXT: .byte 114 # DW_OP_breg2
323 # CHECK-NEXT: .byte 255 # 2147483647
324 # CHECK-NEXT: .byte 255 #
325 # CHECK-NEXT: .byte 255 #
326 # CHECK-NEXT: .byte 255 #
327 # CHECK-NEXT: .byte 7 #
328 # CHECK-NEXT: .quad .Ltmp19-.Lfunc_begin0
329 # CHECK-NEXT: .quad .Ltmp20-.Lfunc_begin0
330 # CHECK-NEXT: .short 8 # Loc expr size
331 # CHECK-NEXT: .byte 114 # DW_OP_breg2
332 # CHECK-NEXT: .byte 0 # 0
333 # CHECK-NEXT: .byte 35 # DW_OP_plus_uconst
334 # CHECK-NEXT: .byte 128 # 2147483648
335 # CHECK-NEXT: .byte 128 #
336 # CHECK-NEXT: .byte 128 #
337 # CHECK-NEXT: .byte 128 #
338 # CHECK-NEXT: .byte 8 #
339 # CHECK-NEXT: .quad .Ltmp20-.Lfunc_begin0
340 # CHECK-NEXT: .quad .Ltmp21-.Lfunc_begin0
341 # CHECK-NEXT: .short 2 # Loc expr size
342 # CHECK-NEXT: .byte 114 # DW_OP_breg2
343 # CHECK-NEXT: .byte 0 # 0
344 # CHECK-NEXT: .quad .Ltmp21-.Lfunc_begin0
345 # CHECK-NEXT: .quad .Ltmp22-.Lfunc_begin0
346 # CHECK-NEXT: .short 13 # Loc expr size
347 # CHECK-NEXT: .byte 114 # DW_OP_breg2
348 # CHECK-NEXT: .byte 0 # 0
349 # CHECK-NEXT: .byte 35 # DW_OP_plus_uconst
350 # CHECK-NEXT: .byte 255 # 18446744073709551615
351 # CHECK-NEXT: .byte 255 #
352 # CHECK-NEXT: .byte 255 #
353 # CHECK-NEXT: .byte 255 #
354 # CHECK-NEXT: .byte 255 #
355 # CHECK-NEXT: .byte 255 #
356 # CHECK-NEXT: .byte 255 #
357 # CHECK-NEXT: .byte 255 #
358 # CHECK-NEXT: .byte 255 #
359 # CHECK-NEXT: .byte 1 #
360 # CHECK-NEXT: .quad .Ltmp22-.Lfunc_begin0
361 # CHECK-NEXT: .quad .Lfunc_end0-.Lfunc_begin0
362 # CHECK-NEXT: .short 13 # Loc expr size
363 # CHECK-NEXT: .byte 114 # DW_OP_breg2
364 # CHECK-NEXT: .byte 0 # 0
365 # CHECK-NEXT: .byte 35 # DW_OP_plus_uconst
366 # CHECK-NEXT: .byte 254 # 18446744073709551614
367 # CHECK-NEXT: .byte 255 #
368 # CHECK-NEXT: .byte 255 #
369 # CHECK-NEXT: .byte 255 #
370 # CHECK-NEXT: .byte 255 #
371 # CHECK-NEXT: .byte 255 #
372 # CHECK-NEXT: .byte 255 #
373 # CHECK-NEXT: .byte 255 #
374 # CHECK-NEXT: .byte 255 #
375 # CHECK-NEXT: .byte 1 #
376 # CHECK-NEXT: .quad 0
377 # CHECK-NEXT: .quad 0