1 # REQUIRES: system-linux
3 # RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o
4 # RUN: %clang %cflags -no-pie %s -o %t.exe -Wl,-q
5 # RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
6 # RUN: llvm-dwarfdump --show-children --name=main --debug-info %t.bolt \
9 # CHECK: DW_TAG_inlined_subroutine
11 # CHECK-SAME: 0x0000000000000000
13 # CHECK: DW_TAG_call_site
14 # CHECK: DW_AT_call_return_pc
15 # CHECK-SAME: 0x0000000000000000
17 ## Test that llvm-bolt correctly updates DIEs corresponding to deleted code.
19 # Test case built from the following source using:
21 # clang -O2 -g -gdwarf-5 ...
23 # Assembly modified with "je" -> "jmp" to introduce unreachable block.
25 # extern void puts(const char *);
31 # int main(int argc, char **argv) {
39 .file 0 "." "unreachable.c" md5 0xd268d8460ea246544a440d4d42235947
40 .globl main # -- Begin function main
45 .loc 0 7 0 # unreachable.c:7:0
48 #DEBUG_VALUE: main:argc <- $edi
49 #DEBUG_VALUE: main:argv <- $rsi
50 .loc 0 8 7 prologue_end # unreachable.c:8:7
53 .loc 0 8 7 is_stmt 0 # unreachable.c:8:7
57 #DEBUG_VALUE: main:argc <- $edi
58 #DEBUG_VALUE: main:argv <- $rsi
60 .cfi_def_cfa_offset 16
62 .loc 0 4 3 is_stmt 1 # unreachable.c:4:3
65 #DEBUG_VALUE: main:argc <- [DW_OP_LLVM_entry_value 1] $edi
68 #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi
69 .loc 0 0 3 is_stmt 0 # unreachable.c:0:3
74 #DEBUG_VALUE: main:argc <- [DW_OP_LLVM_entry_value 1] $edi
75 #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi
76 .loc 0 10 3 is_stmt 1 # unreachable.c:10:3
81 .size main, .Lfunc_end0-main
84 .type .L.str,@object # @.str
85 .section .rodata.str1.1,"aMS",@progbits,1
90 .section .debug_loclists,"",@progbits
91 .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length
92 .Ldebug_list_header_start0:
94 .byte 8 # Address size
95 .byte 0 # Segment selector size
96 .long 2 # Offset entry count
97 .Lloclists_table_base0:
98 .long .Ldebug_loc0-.Lloclists_table_base0
99 .long .Ldebug_loc1-.Lloclists_table_base0
101 .byte 4 # DW_LLE_offset_pair
102 .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset
103 .uleb128 .Ltmp3-.Lfunc_begin0 # ending offset
104 .byte 1 # Loc expr size
105 .byte 85 # super-register DW_OP_reg5
106 .byte 4 # DW_LLE_offset_pair
107 .uleb128 .Ltmp3-.Lfunc_begin0 # starting offset
108 .uleb128 .Lfunc_end0-.Lfunc_begin0 # ending offset
109 .byte 4 # Loc expr size
110 .byte 163 # DW_OP_entry_value
112 .byte 85 # super-register DW_OP_reg5
113 .byte 159 # DW_OP_stack_value
114 .byte 0 # DW_LLE_end_of_list
116 .byte 4 # DW_LLE_offset_pair
117 .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset
118 .uleb128 .Ltmp4-.Lfunc_begin0 # ending offset
119 .byte 1 # Loc expr size
120 .byte 84 # DW_OP_reg4
121 .byte 4 # DW_LLE_offset_pair
122 .uleb128 .Ltmp4-.Lfunc_begin0 # starting offset
123 .uleb128 .Lfunc_end0-.Lfunc_begin0 # ending offset
124 .byte 4 # Loc expr size
125 .byte 163 # DW_OP_entry_value
127 .byte 84 # DW_OP_reg4
128 .byte 159 # DW_OP_stack_value
129 .byte 0 # DW_LLE_end_of_list
130 .Ldebug_list_header_end0:
131 .section .debug_abbrev,"",@progbits
132 .byte 1 # Abbreviation Code
133 .byte 17 # DW_TAG_compile_unit
134 .byte 1 # DW_CHILDREN_yes
135 .byte 37 # DW_AT_producer
136 .byte 37 # DW_FORM_strx1
137 .byte 19 # DW_AT_language
138 .byte 5 # DW_FORM_data2
140 .byte 37 # DW_FORM_strx1
141 .byte 114 # DW_AT_str_offsets_base
142 .byte 23 # DW_FORM_sec_offset
143 .byte 16 # DW_AT_stmt_list
144 .byte 23 # DW_FORM_sec_offset
145 .byte 27 # DW_AT_comp_dir
146 .byte 37 # DW_FORM_strx1
147 .byte 17 # DW_AT_low_pc
148 .byte 27 # DW_FORM_addrx
149 .byte 18 # DW_AT_high_pc
150 .byte 6 # DW_FORM_data4
151 .byte 115 # DW_AT_addr_base
152 .byte 23 # DW_FORM_sec_offset
153 .ascii "\214\001" # DW_AT_loclists_base
154 .byte 23 # DW_FORM_sec_offset
157 .byte 2 # Abbreviation Code
158 .byte 52 # DW_TAG_variable
159 .byte 0 # DW_CHILDREN_no
160 .byte 73 # DW_AT_type
161 .byte 19 # DW_FORM_ref4
162 .byte 58 # DW_AT_decl_file
163 .byte 11 # DW_FORM_data1
164 .byte 59 # DW_AT_decl_line
165 .byte 11 # DW_FORM_data1
166 .byte 2 # DW_AT_location
167 .byte 24 # DW_FORM_exprloc
170 .byte 3 # Abbreviation Code
171 .byte 1 # DW_TAG_array_type
172 .byte 1 # DW_CHILDREN_yes
173 .byte 73 # DW_AT_type
174 .byte 19 # DW_FORM_ref4
177 .byte 4 # Abbreviation Code
178 .byte 33 # DW_TAG_subrange_type
179 .byte 0 # DW_CHILDREN_no
180 .byte 73 # DW_AT_type
181 .byte 19 # DW_FORM_ref4
182 .byte 55 # DW_AT_count
183 .byte 11 # DW_FORM_data1
186 .byte 5 # Abbreviation Code
187 .byte 36 # DW_TAG_base_type
188 .byte 0 # DW_CHILDREN_no
190 .byte 37 # DW_FORM_strx1
191 .byte 62 # DW_AT_encoding
192 .byte 11 # DW_FORM_data1
193 .byte 11 # DW_AT_byte_size
194 .byte 11 # DW_FORM_data1
197 .byte 6 # Abbreviation Code
198 .byte 36 # DW_TAG_base_type
199 .byte 0 # DW_CHILDREN_no
201 .byte 37 # DW_FORM_strx1
202 .byte 11 # DW_AT_byte_size
203 .byte 11 # DW_FORM_data1
204 .byte 62 # DW_AT_encoding
205 .byte 11 # DW_FORM_data1
208 .byte 7 # Abbreviation Code
209 .byte 46 # DW_TAG_subprogram
210 .byte 0 # DW_CHILDREN_no
212 .byte 37 # DW_FORM_strx1
213 .byte 58 # DW_AT_decl_file
214 .byte 11 # DW_FORM_data1
215 .byte 59 # DW_AT_decl_line
216 .byte 11 # DW_FORM_data1
217 .byte 32 # DW_AT_inline
218 .byte 33 # DW_FORM_implicit_const
222 .byte 8 # Abbreviation Code
223 .byte 46 # DW_TAG_subprogram
224 .byte 1 # DW_CHILDREN_yes
225 .byte 17 # DW_AT_low_pc
226 .byte 27 # DW_FORM_addrx
227 .byte 18 # DW_AT_high_pc
228 .byte 6 # DW_FORM_data4
229 .byte 64 # DW_AT_frame_base
230 .byte 24 # DW_FORM_exprloc
231 .byte 122 # DW_AT_call_all_calls
232 .byte 25 # DW_FORM_flag_present
234 .byte 37 # DW_FORM_strx1
235 .byte 58 # DW_AT_decl_file
236 .byte 11 # DW_FORM_data1
237 .byte 59 # DW_AT_decl_line
238 .byte 11 # DW_FORM_data1
239 .byte 39 # DW_AT_prototyped
240 .byte 25 # DW_FORM_flag_present
241 .byte 73 # DW_AT_type
242 .byte 19 # DW_FORM_ref4
243 .byte 63 # DW_AT_external
244 .byte 25 # DW_FORM_flag_present
247 .byte 9 # Abbreviation Code
248 .byte 5 # DW_TAG_formal_parameter
249 .byte 0 # DW_CHILDREN_no
250 .byte 2 # DW_AT_location
251 .byte 34 # DW_FORM_loclistx
253 .byte 37 # DW_FORM_strx1
254 .byte 58 # DW_AT_decl_file
255 .byte 11 # DW_FORM_data1
256 .byte 59 # DW_AT_decl_line
257 .byte 11 # DW_FORM_data1
258 .byte 73 # DW_AT_type
259 .byte 19 # DW_FORM_ref4
262 .byte 10 # Abbreviation Code
263 .byte 29 # DW_TAG_inlined_subroutine
264 .byte 0 # DW_CHILDREN_no
265 .byte 49 # DW_AT_abstract_origin
266 .byte 19 # DW_FORM_ref4
267 .byte 17 # DW_AT_low_pc
268 .byte 27 # DW_FORM_addrx
269 .byte 18 # DW_AT_high_pc
270 .byte 6 # DW_FORM_data4
271 .byte 88 # DW_AT_call_file
272 .byte 11 # DW_FORM_data1
273 .byte 89 # DW_AT_call_line
274 .byte 11 # DW_FORM_data1
275 .byte 87 # DW_AT_call_column
276 .byte 11 # DW_FORM_data1
279 .byte 11 # Abbreviation Code
280 .byte 72 # DW_TAG_call_site
281 .byte 0 # DW_CHILDREN_no
282 .byte 127 # DW_AT_call_origin
283 .byte 19 # DW_FORM_ref4
284 .byte 125 # DW_AT_call_return_pc
285 .byte 27 # DW_FORM_addrx
288 .byte 12 # Abbreviation Code
289 .byte 46 # DW_TAG_subprogram
290 .byte 1 # DW_CHILDREN_yes
292 .byte 37 # DW_FORM_strx1
293 .byte 58 # DW_AT_decl_file
294 .byte 11 # DW_FORM_data1
295 .byte 59 # DW_AT_decl_line
296 .byte 11 # DW_FORM_data1
297 .byte 39 # DW_AT_prototyped
298 .byte 25 # DW_FORM_flag_present
299 .byte 60 # DW_AT_declaration
300 .byte 25 # DW_FORM_flag_present
301 .byte 63 # DW_AT_external
302 .byte 25 # DW_FORM_flag_present
305 .byte 13 # Abbreviation Code
306 .byte 5 # DW_TAG_formal_parameter
307 .byte 0 # DW_CHILDREN_no
308 .byte 73 # DW_AT_type
309 .byte 19 # DW_FORM_ref4
312 .byte 14 # Abbreviation Code
313 .byte 15 # DW_TAG_pointer_type
314 .byte 0 # DW_CHILDREN_no
315 .byte 73 # DW_AT_type
316 .byte 19 # DW_FORM_ref4
319 .byte 15 # Abbreviation Code
320 .byte 38 # DW_TAG_const_type
321 .byte 0 # DW_CHILDREN_no
322 .byte 73 # DW_AT_type
323 .byte 19 # DW_FORM_ref4
327 .section .debug_info,"",@progbits
329 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
331 .short 5 # DWARF version number
332 .byte 1 # DWARF Unit Type
333 .byte 8 # Address Size (in bytes)
334 .long .debug_abbrev # Offset Into Abbrev. Section
335 .byte 1 # Abbrev [1] 0xc:0x95 DW_TAG_compile_unit
336 .byte 0 # DW_AT_producer
337 .short 12 # DW_AT_language
339 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base
340 .long .Lline_table_start0 # DW_AT_stmt_list
341 .byte 2 # DW_AT_comp_dir
342 .byte 1 # DW_AT_low_pc
343 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
344 .long .Laddr_table_base0 # DW_AT_addr_base
345 .long .Lloclists_table_base0 # DW_AT_loclists_base
346 .byte 2 # Abbrev [2] 0x27:0xa DW_TAG_variable
347 .long 49 # DW_AT_type
348 .byte 0 # DW_AT_decl_file
349 .byte 4 # DW_AT_decl_line
350 .byte 2 # DW_AT_location
353 .byte 3 # Abbrev [3] 0x31:0xc DW_TAG_array_type
354 .long 61 # DW_AT_type
355 .byte 4 # Abbrev [4] 0x36:0x6 DW_TAG_subrange_type
356 .long 65 # DW_AT_type
357 .byte 3 # DW_AT_count
358 .byte 0 # End Of Children Mark
359 .byte 5 # Abbrev [5] 0x3d:0x4 DW_TAG_base_type
361 .byte 6 # DW_AT_encoding
362 .byte 1 # DW_AT_byte_size
363 .byte 6 # Abbrev [6] 0x41:0x4 DW_TAG_base_type
365 .byte 8 # DW_AT_byte_size
366 .byte 7 # DW_AT_encoding
367 .byte 7 # Abbrev [7] 0x45:0x4 DW_TAG_subprogram
369 .byte 0 # DW_AT_decl_file
370 .byte 3 # DW_AT_decl_line
372 .byte 8 # Abbrev [8] 0x49:0x35 DW_TAG_subprogram
373 .byte 1 # DW_AT_low_pc
374 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
375 .byte 1 # DW_AT_frame_base
377 # DW_AT_call_all_calls
379 .byte 0 # DW_AT_decl_file
380 .byte 7 # DW_AT_decl_line
382 .long 146 # DW_AT_type
384 .byte 9 # Abbrev [9] 0x58:0x9 DW_TAG_formal_parameter
385 .byte 0 # DW_AT_location
387 .byte 0 # DW_AT_decl_file
388 .byte 7 # DW_AT_decl_line
389 .long 146 # DW_AT_type
390 .byte 9 # Abbrev [9] 0x61:0x9 DW_TAG_formal_parameter
391 .byte 1 # DW_AT_location
392 .byte 10 # DW_AT_name
393 .byte 0 # DW_AT_decl_file
394 .byte 7 # DW_AT_decl_line
395 .long 150 # DW_AT_type
396 .byte 10 # Abbrev [10] 0x6a:0xd DW_TAG_inlined_subroutine
397 .long 69 # DW_AT_abstract_origin
398 .byte 2 # DW_AT_low_pc
399 .long .Ltmp5-.Ltmp2 # DW_AT_high_pc
400 .byte 0 # DW_AT_call_file
401 .byte 9 # DW_AT_call_line
402 .byte 5 # DW_AT_call_column
403 .byte 11 # Abbrev [11] 0x77:0x6 DW_TAG_call_site
404 .long 126 # DW_AT_call_origin
405 .byte 3 # DW_AT_call_return_pc
406 .byte 0 # End Of Children Mark
407 .byte 12 # Abbrev [12] 0x7e:0xa DW_TAG_subprogram
409 .byte 0 # DW_AT_decl_file
410 .byte 1 # DW_AT_decl_line
414 .byte 13 # Abbrev [13] 0x82:0x5 DW_TAG_formal_parameter
415 .long 136 # DW_AT_type
416 .byte 0 # End Of Children Mark
417 .byte 14 # Abbrev [14] 0x88:0x5 DW_TAG_pointer_type
418 .long 141 # DW_AT_type
419 .byte 15 # Abbrev [15] 0x8d:0x5 DW_TAG_const_type
420 .long 61 # DW_AT_type
421 .byte 5 # Abbrev [5] 0x92:0x4 DW_TAG_base_type
423 .byte 5 # DW_AT_encoding
424 .byte 4 # DW_AT_byte_size
425 .byte 14 # Abbrev [14] 0x96:0x5 DW_TAG_pointer_type
426 .long 155 # DW_AT_type
427 .byte 14 # Abbrev [14] 0x9b:0x5 DW_TAG_pointer_type
428 .long 61 # DW_AT_type
429 .byte 0 # End Of Children Mark
431 .section .debug_str_offsets,"",@progbits
432 .long 48 # Length of String Offsets Set
436 .section .debug_str,"MS",@progbits,1
438 .asciz "clang version 15.0.7 " # string offset=0
440 .asciz "unreachable.c" # string offset=69
442 .asciz "." # string offset=83
444 .asciz "char" # string offset=85
446 .asciz "__ARRAY_SIZE_TYPE__" # string offset=90
448 .asciz "foo" # string offset=110
450 .asciz "puts" # string offset=114
452 .asciz "main" # string offset=119
454 .asciz "int" # string offset=124
456 .asciz "argc" # string offset=128
458 .asciz "argv" # string offset=133
459 .section .debug_str_offsets,"",@progbits
470 .long .Linfo_string10
471 .section .debug_addr,"",@progbits
472 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
474 .short 5 # DWARF version number
475 .byte 8 # Address size
476 .byte 0 # Segment selector size
483 .section .debug_line,"",@progbits