1 # REQUIRES: system-linux
3 # RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o
4 # RUN: %clang %cflags -dwarf-4 %tmain.o -o %t.exe -Wl,-q
5 # RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --use-old-text
6 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt > %t.txt
7 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe >> %t.txt
8 # RUN: cat %t.txt | FileCheck --check-prefix=CHECK %s
10 # CHECK: DW_TAG_inlined_subroutine
11 # CHECK: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,ADDR:]])
12 # CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000000)
14 # CHECK: DW_TAG_inlined_subroutine
15 # CHECK-NOT: DW_AT_low_pc [DW_FORM_addr] (0x[[#ADDR]])
16 # CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000000)
19 # Testing BOLT handles correctly when size of DW_AT_inlined_subroutine is 0.
20 # In other words DW_AT_high_pc is 0 or DW_AT_low_pc == DW_AT_high_pc.
22 # Modified assembly manually to set DW_AT_high_pc to 0.
23 # clang++ -g2 -gdwarf-4 main.cpp -O1 -S -o main4.s
25 # static int helper(int i) {
28 # void may_not_exist(void) __attribute__ ((weak));
29 # int main(int argc, char *argv[]) {
33 # [[clang::always_inline]] j = helper(argc);
40 .globl main # -- Begin function main
45 .file 1 "." "main.cpp"
46 .loc 1 5 0 # main.cpp:5:0
49 #DEBUG_VALUE: main:argc <- $edi
50 #DEBUG_VALUE: main:argv <- $rsi
52 .cfi_def_cfa_offset 16
56 .loc 1 6 7 prologue_end # main.cpp:6:7
57 cmpq $
0, _Z13may_not_existv@GOTPCREL
(%rip
)
61 #DEBUG_VALUE: main:argc <- $ebx
62 #DEBUG_VALUE: main:argv <- $rsi
63 .loc 1 7 5 # main.cpp:7:5
64 callq _Z13may_not_existv@PLT
66 #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi
68 #DEBUG_VALUE: main:argc <- $ebx
69 #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi
70 #DEBUG_VALUE: main:j <- 0
71 #DEBUG_VALUE: helper:i <- $ebx
72 .loc 1 2 10 # main.cpp:2:10
75 #DEBUG_VALUE: main:argc <- [DW_OP_LLVM_entry_value 1] $edi
76 #DEBUG_VALUE: helper:i <- $ebx
77 #DEBUG_VALUE: main:j <- $ebx
78 .loc 1 10 3 # main.cpp:10:3
82 #DEBUG_VALUE: helper:i <- $eax
83 #DEBUG_VALUE: main:j <- $eax
88 .size main, .Lfunc_end0-main
91 .section .debug_loc,"",@progbits
93 .quad .Lfunc_begin0-.Lfunc_begin0
94 .quad .Ltmp1-.Lfunc_begin0
95 .short 1 # Loc expr size
96 .byte 85 # super-register DW_OP_reg5
97 .quad .Ltmp1-.Lfunc_begin0
98 .quad .Ltmp3-.Lfunc_begin0
99 .short 1 # Loc expr size
100 .byte 83 # super-register DW_OP_reg3
101 .quad .Ltmp3-.Lfunc_begin0
102 .quad .Lfunc_end0-.Lfunc_begin0
103 .short 4 # Loc expr size
104 .byte 243 # DW_OP_GNU_entry_value
106 .byte 85 # super-register DW_OP_reg5
107 .byte 159 # DW_OP_stack_value
111 .quad .Lfunc_begin0-.Lfunc_begin0
112 .quad .Ltmp2-.Lfunc_begin0
113 .short 1 # Loc expr size
114 .byte 84 # DW_OP_reg4
115 .quad .Ltmp2-.Lfunc_begin0
116 .quad .Lfunc_end0-.Lfunc_begin0
117 .short 4 # Loc expr size
118 .byte 243 # DW_OP_GNU_entry_value
120 .byte 84 # DW_OP_reg4
121 .byte 159 # DW_OP_stack_value
125 .quad .Ltmp2-.Lfunc_begin0
126 .quad .Ltmp3-.Lfunc_begin0
127 .short 3 # Loc expr size
128 .byte 17 # DW_OP_consts
130 .byte 159 # DW_OP_stack_value
131 .quad .Ltmp3-.Lfunc_begin0
132 .quad .Ltmp4-.Lfunc_begin0
133 .short 1 # Loc expr size
134 .byte 83 # super-register DW_OP_reg3
135 .quad .Ltmp4-.Lfunc_begin0
136 .quad .Lfunc_end0-.Lfunc_begin0
137 .short 1 # Loc expr size
138 .byte 80 # super-register DW_OP_reg0
141 .section .debug_abbrev,"",@progbits
142 .byte 1 # Abbreviation Code
143 .byte 17 # DW_TAG_compile_unit
144 .byte 1 # DW_CHILDREN_yes
145 .byte 37 # DW_AT_producer
146 .byte 14 # DW_FORM_strp
147 .byte 19 # DW_AT_language
148 .byte 5 # DW_FORM_data2
150 .byte 14 # DW_FORM_strp
151 .byte 16 # DW_AT_stmt_list
152 .byte 23 # DW_FORM_sec_offset
153 .byte 27 # DW_AT_comp_dir
154 .byte 14 # DW_FORM_strp
155 .byte 17 # DW_AT_low_pc
156 .byte 1 # DW_FORM_addr
157 .byte 18 # DW_AT_high_pc
158 .byte 6 # DW_FORM_data4
161 .byte 2 # Abbreviation Code
162 .byte 46 # DW_TAG_subprogram
163 .byte 1 # DW_CHILDREN_yes
164 .byte 110 # DW_AT_linkage_name
165 .byte 14 # DW_FORM_strp
167 .byte 14 # DW_FORM_strp
168 .byte 58 # DW_AT_decl_file
169 .byte 11 # DW_FORM_data1
170 .byte 59 # DW_AT_decl_line
171 .byte 11 # DW_FORM_data1
172 .byte 73 # DW_AT_type
173 .byte 19 # DW_FORM_ref4
174 .byte 32 # DW_AT_inline
175 .byte 11 # DW_FORM_data1
178 .byte 3 # Abbreviation Code
179 .byte 5 # DW_TAG_formal_parameter
180 .byte 0 # DW_CHILDREN_no
182 .byte 14 # DW_FORM_strp
183 .byte 58 # DW_AT_decl_file
184 .byte 11 # DW_FORM_data1
185 .byte 59 # DW_AT_decl_line
186 .byte 11 # DW_FORM_data1
187 .byte 73 # DW_AT_type
188 .byte 19 # DW_FORM_ref4
191 .byte 4 # Abbreviation Code
192 .byte 36 # DW_TAG_base_type
193 .byte 0 # DW_CHILDREN_no
195 .byte 14 # DW_FORM_strp
196 .byte 62 # DW_AT_encoding
197 .byte 11 # DW_FORM_data1
198 .byte 11 # DW_AT_byte_size
199 .byte 11 # DW_FORM_data1
202 .byte 5 # Abbreviation Code
203 .byte 46 # DW_TAG_subprogram
204 .byte 1 # DW_CHILDREN_yes
205 .byte 17 # DW_AT_low_pc
206 .byte 1 # DW_FORM_addr
207 .byte 18 # DW_AT_high_pc
208 .byte 6 # DW_FORM_data4
209 .byte 64 # DW_AT_frame_base
210 .byte 24 # DW_FORM_exprloc
211 .ascii "\227B" # DW_AT_GNU_all_call_sites
212 .byte 25 # DW_FORM_flag_present
214 .byte 14 # DW_FORM_strp
215 .byte 58 # DW_AT_decl_file
216 .byte 11 # DW_FORM_data1
217 .byte 59 # DW_AT_decl_line
218 .byte 11 # DW_FORM_data1
219 .byte 73 # DW_AT_type
220 .byte 19 # DW_FORM_ref4
221 .byte 63 # DW_AT_external
222 .byte 25 # DW_FORM_flag_present
225 .byte 6 # Abbreviation Code
226 .byte 5 # DW_TAG_formal_parameter
227 .byte 0 # DW_CHILDREN_no
228 .byte 2 # DW_AT_location
229 .byte 23 # DW_FORM_sec_offset
231 .byte 14 # DW_FORM_strp
232 .byte 58 # DW_AT_decl_file
233 .byte 11 # DW_FORM_data1
234 .byte 59 # DW_AT_decl_line
235 .byte 11 # DW_FORM_data1
236 .byte 73 # DW_AT_type
237 .byte 19 # DW_FORM_ref4
240 .byte 7 # Abbreviation Code
241 .byte 52 # DW_TAG_variable
242 .byte 0 # DW_CHILDREN_no
243 .byte 2 # DW_AT_location
244 .byte 23 # DW_FORM_sec_offset
246 .byte 14 # DW_FORM_strp
247 .byte 58 # DW_AT_decl_file
248 .byte 11 # DW_FORM_data1
249 .byte 59 # DW_AT_decl_line
250 .byte 11 # DW_FORM_data1
251 .byte 73 # DW_AT_type
252 .byte 19 # DW_FORM_ref4
255 .byte 8 # Abbreviation Code
256 .byte 29 # DW_TAG_inlined_subroutine
257 .byte 1 # DW_CHILDREN_yes
258 .byte 49 # DW_AT_abstract_origin
259 .byte 19 # DW_FORM_ref4
260 .byte 17 # DW_AT_low_pc
261 .byte 1 # DW_FORM_addr
262 .byte 18 # DW_AT_high_pc
263 .byte 6 # DW_FORM_data4
264 .byte 88 # DW_AT_call_file
265 .byte 11 # DW_FORM_data1
266 .byte 89 # DW_AT_call_line
267 .byte 11 # DW_FORM_data1
268 .byte 87 # DW_AT_call_column
269 .byte 11 # DW_FORM_data1
272 .byte 9 # Abbreviation Code
273 .byte 5 # DW_TAG_formal_parameter
274 .byte 0 # DW_CHILDREN_no
275 .byte 2 # DW_AT_location
276 .byte 24 # DW_FORM_exprloc
277 .byte 49 # DW_AT_abstract_origin
278 .byte 19 # DW_FORM_ref4
281 .byte 10 # Abbreviation Code
282 .ascii "\211\202\001" # DW_TAG_GNU_call_site
283 .byte 0 # DW_CHILDREN_no
284 .byte 49 # DW_AT_abstract_origin
285 .byte 19 # DW_FORM_ref4
286 .byte 17 # DW_AT_low_pc
287 .byte 1 # DW_FORM_addr
290 .byte 11 # Abbreviation Code
291 .byte 46 # DW_TAG_subprogram
292 .byte 0 # DW_CHILDREN_no
293 .byte 110 # DW_AT_linkage_name
294 .byte 14 # DW_FORM_strp
296 .byte 14 # DW_FORM_strp
297 .byte 58 # DW_AT_decl_file
298 .byte 11 # DW_FORM_data1
299 .byte 59 # DW_AT_decl_line
300 .byte 11 # DW_FORM_data1
301 .byte 60 # DW_AT_declaration
302 .byte 25 # DW_FORM_flag_present
303 .byte 63 # DW_AT_external
304 .byte 25 # DW_FORM_flag_present
307 .byte 12 # Abbreviation Code
308 .byte 15 # DW_TAG_pointer_type
309 .byte 0 # DW_CHILDREN_no
310 .byte 73 # DW_AT_type
311 .byte 19 # DW_FORM_ref4
315 .section .debug_info,"",@progbits
317 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
319 .short 4 # DWARF version number
320 .long .debug_abbrev # Offset Into Abbrev. Section
321 .byte 8 # Address Size (in bytes)
322 .byte 1 # Abbrev [1] 0xb:0xcf DW_TAG_compile_unit
323 .long .Linfo_string0 # DW_AT_producer
324 .short 33 # DW_AT_language
325 .long .Linfo_string1 # DW_AT_name
326 .long .Lline_table_start0 # DW_AT_stmt_list
327 .long .Linfo_string2 # DW_AT_comp_dir
328 .quad .Lfunc_begin0 # DW_AT_low_pc
329 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
330 .byte 2 # Abbrev [2] 0x2a:0x1c DW_TAG_subprogram
331 .long .Linfo_string3 # DW_AT_linkage_name
332 .long .Linfo_string4 # DW_AT_name
333 .byte 1 # DW_AT_decl_file
334 .byte 1 # DW_AT_decl_line
335 .long 70 # DW_AT_type
336 .byte 1 # DW_AT_inline
337 .byte 3 # Abbrev [3] 0x3a:0xb DW_TAG_formal_parameter
338 .long .Linfo_string6 # DW_AT_name
339 .byte 1 # DW_AT_decl_file
340 .byte 1 # DW_AT_decl_line
341 .long 70 # DW_AT_type
342 .byte 0 # End Of Children Mark
343 .byte 4 # Abbrev [4] 0x46:0x7 DW_TAG_base_type
344 .long .Linfo_string5 # DW_AT_name
345 .byte 5 # DW_AT_encoding
346 .byte 4 # DW_AT_byte_size
347 .byte 5 # Abbrev [5] 0x4d:0x70 DW_TAG_subprogram
348 .quad .Lfunc_begin0 # DW_AT_low_pc
349 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
350 .byte 1 # DW_AT_frame_base
352 # DW_AT_GNU_all_call_sites
353 .long .Linfo_string9 # DW_AT_name
354 .byte 1 # DW_AT_decl_file
355 .byte 5 # DW_AT_decl_line
356 .long 70 # DW_AT_type
358 .byte 6 # Abbrev [6] 0x66:0xf DW_TAG_formal_parameter
359 .long .Ldebug_loc0 # DW_AT_location
360 .long .Linfo_string10 # DW_AT_name
361 .byte 1 # DW_AT_decl_file
362 .byte 5 # DW_AT_decl_line
363 .long 70 # DW_AT_type
364 .byte 6 # Abbrev [6] 0x75:0xf DW_TAG_formal_parameter
365 .long .Ldebug_loc1 # DW_AT_location
366 .long .Linfo_string11 # DW_AT_name
367 .byte 1 # DW_AT_decl_file
368 .byte 5 # DW_AT_decl_line
369 .long 200 # DW_AT_type
370 .byte 7 # Abbrev [7] 0x84:0xf DW_TAG_variable
371 .long .Ldebug_loc2 # DW_AT_location
372 .long .Linfo_string13 # DW_AT_name
373 .byte 1 # DW_AT_decl_file
374 .byte 8 # DW_AT_decl_line
375 .long 70 # DW_AT_type
376 .byte 8 # Abbrev [8] 0x93:0x1c DW_TAG_inlined_subroutine
377 .long 42 # DW_AT_abstract_origin
378 .quad .Ltmp2 # DW_AT_low_pc
379 .long 0 # DW_AT_high_pc Manually modified
380 .byte 1 # DW_AT_call_file
381 .byte 9 # DW_AT_call_line
382 .byte 32 # DW_AT_call_column
383 .byte 9 # Abbrev [9] 0xa7:0x7 DW_TAG_formal_parameter
384 .byte 1 # DW_AT_location
386 .long 58 # DW_AT_abstract_origin
387 .byte 0 # End Of Children Mark
388 .byte 10 # Abbrev [10] 0xaf:0xd DW_TAG_GNU_call_site
389 .long 189 # DW_AT_abstract_origin
390 .quad .Ltmp2 # DW_AT_low_pc
391 .byte 0 # End Of Children Mark
392 .byte 11 # Abbrev [11] 0xbd:0xb DW_TAG_subprogram
393 .long .Linfo_string7 # DW_AT_linkage_name
394 .long .Linfo_string8 # DW_AT_name
395 .byte 1 # DW_AT_decl_file
396 .byte 4 # DW_AT_decl_line
399 .byte 12 # Abbrev [12] 0xc8:0x5 DW_TAG_pointer_type
400 .long 205 # DW_AT_type
401 .byte 12 # Abbrev [12] 0xcd:0x5 DW_TAG_pointer_type
402 .long 210 # DW_AT_type
403 .byte 4 # Abbrev [4] 0xd2:0x7 DW_TAG_base_type
404 .long .Linfo_string12 # DW_AT_name
405 .byte 6 # DW_AT_encoding
406 .byte 1 # DW_AT_byte_size
407 .byte 0 # End Of Children Mark
409 .section .debug_str,"MS",@progbits,1
411 .asciz "clang version 16.0.0" # string offset=0
413 .asciz "main.cpp" # string offset=105
415 .asciz "." # string offset=114
417 .asciz "_ZL6helperi" # string offset=152
419 .asciz "helper" # string offset=164
421 .asciz "int" # string offset=171
423 .asciz "i" # string offset=175
425 .asciz "_Z13may_not_existv" # string offset=177
427 .asciz "may_not_exist" # string offset=196
429 .asciz "main" # string offset=210
431 .asciz "argc" # string offset=215
433 .asciz "argv" # string offset=220
435 .asciz "char" # string offset=225
437 .asciz "j" # string offset=230
438 .weak _Z13may_not_existv
439 .ident "clang version 16.0.0"
440 .section ".note.GNU-stack","",@progbits
442 .addrsig_sym _Z13may_not_existv
443 .section .debug_line,"",@progbits