2 # REQUIRES: system-linux
4 # RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o
5 # RUN: %clang %cflags -dwarf-4 %t1.o -o %t.exe
6 # RUN: llvm-objcopy --remove-section=.debug_loc %t.exe
7 # RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections &> file
8 # RUN: cat file | FileCheck --check-prefix=CHECK %s
10 # Making sure we handle error returned by visitLocationList correctly.
12 # CHECK: BOLT-WARNING: empty location list detected at
13 # CHECK-NEXT: BOLT-WARNING: empty location list detected at
16 # clang++ main.cpp -g -ffunction-sections -Os -gdwarf-4 -S
17 # int doStuff2(int val) {
21 # int main(int argc, const char** argv) {
22 # return doStuff2(argc);
27 .section .text._Z8doStuff2i,"ax",@progbits
28 .globl _Z8doStuff2i # -- Begin function _Z8doStuff2i
29 .type _Z8doStuff2i,@function
30 _Z8doStuff2i
: # @_Z8doStuff2i
32 .file 1 "." "main.cpp"
33 .loc 1 2 0 # main.cpp:2:0
36 #DEBUG_VALUE: doStuff2:val <- $edi
37 # kill: def $edi killed $edi def $rdi
38 .loc 1 3 14 prologue_end # main.cpp:3:14
41 #DEBUG_VALUE: doStuff2:val <- $eax
42 .loc 1 3 3 is_stmt 0 # main.cpp:3:3
46 .size _Z8doStuff2i, .Lfunc_end0-_Z8doStuff2i
49 .section .text.main,"ax",@progbits
50 .globl main # -- Begin function main
54 .loc 1 6 0 is_stmt 1 # main.cpp:6:0
57 #DEBUG_VALUE: main:argc <- $edi
58 #DEBUG_VALUE: main:argv <- $rsi
59 #DEBUG_VALUE: doStuff2:val <- $edi
60 # kill: def $edi killed $edi def $rdi
61 .loc 1 3 14 prologue_end # main.cpp:3:14
64 #DEBUG_VALUE: doStuff2:val <- $eax
65 .loc 1 7 3 # main.cpp:7:3
69 .size main, .Lfunc_end1-main
72 .section .debug_loc,"",@progbits
75 .quad .Lfunc_begin0 # base address
76 .quad .Lfunc_begin0-.Lfunc_begin0
77 .quad .Ltmp0-.Lfunc_begin0
78 .short 1 # Loc expr size
79 .byte 85 # super-register DW_OP_reg5
80 .quad .Ltmp0-.Lfunc_begin0
81 .quad .Lfunc_end0-.Lfunc_begin0
82 .short 1 # Loc expr size
83 .byte 80 # super-register DW_OP_reg0
88 .quad .Lfunc_begin1 # base address
89 .quad .Lfunc_begin1-.Lfunc_begin1
90 .quad .Ltmp2-.Lfunc_begin1
91 .short 1 # Loc expr size
92 .byte 85 # super-register DW_OP_reg5
93 .quad .Ltmp2-.Lfunc_begin1
94 .quad .Lfunc_end1-.Lfunc_begin1
95 .short 1 # Loc expr size
96 .byte 80 # super-register DW_OP_reg0
99 .section .debug_abbrev,"",@progbits
100 .byte 1 # Abbreviation Code
101 .byte 17 # DW_TAG_compile_unit
102 .byte 1 # DW_CHILDREN_yes
103 .byte 37 # DW_AT_producer
104 .byte 14 # DW_FORM_strp
105 .byte 19 # DW_AT_language
106 .byte 5 # DW_FORM_data2
108 .byte 14 # DW_FORM_strp
109 .byte 16 # DW_AT_stmt_list
110 .byte 23 # DW_FORM_sec_offset
111 .byte 27 # DW_AT_comp_dir
112 .byte 14 # DW_FORM_strp
113 .byte 17 # DW_AT_low_pc
114 .byte 1 # DW_FORM_addr
115 .byte 85 # DW_AT_ranges
116 .byte 23 # DW_FORM_sec_offset
119 .byte 2 # Abbreviation Code
120 .byte 46 # DW_TAG_subprogram
121 .byte 1 # DW_CHILDREN_yes
122 .byte 17 # DW_AT_low_pc
123 .byte 1 # DW_FORM_addr
124 .byte 18 # DW_AT_high_pc
125 .byte 6 # DW_FORM_data4
126 .byte 64 # DW_AT_frame_base
127 .byte 24 # DW_FORM_exprloc
128 .ascii "\227B" # DW_AT_GNU_all_call_sites
129 .byte 25 # DW_FORM_flag_present
130 .byte 49 # DW_AT_abstract_origin
131 .byte 19 # DW_FORM_ref4
134 .byte 3 # Abbreviation Code
135 .byte 5 # DW_TAG_formal_parameter
136 .byte 0 # DW_CHILDREN_no
137 .byte 2 # DW_AT_location
138 .byte 23 # DW_FORM_sec_offset
139 .byte 49 # DW_AT_abstract_origin
140 .byte 19 # DW_FORM_ref4
143 .byte 4 # Abbreviation Code
144 .byte 46 # DW_TAG_subprogram
145 .byte 1 # DW_CHILDREN_yes
146 .byte 110 # DW_AT_linkage_name
147 .byte 14 # DW_FORM_strp
149 .byte 14 # DW_FORM_strp
150 .byte 58 # DW_AT_decl_file
151 .byte 11 # DW_FORM_data1
152 .byte 59 # DW_AT_decl_line
153 .byte 11 # DW_FORM_data1
154 .byte 73 # DW_AT_type
155 .byte 19 # DW_FORM_ref4
156 .byte 63 # DW_AT_external
157 .byte 25 # DW_FORM_flag_present
158 .byte 32 # DW_AT_inline
159 .byte 11 # DW_FORM_data1
162 .byte 5 # Abbreviation Code
163 .byte 5 # DW_TAG_formal_parameter
164 .byte 0 # DW_CHILDREN_no
166 .byte 14 # DW_FORM_strp
167 .byte 58 # DW_AT_decl_file
168 .byte 11 # DW_FORM_data1
169 .byte 59 # DW_AT_decl_line
170 .byte 11 # DW_FORM_data1
171 .byte 73 # DW_AT_type
172 .byte 19 # DW_FORM_ref4
175 .byte 6 # Abbreviation Code
176 .byte 36 # DW_TAG_base_type
177 .byte 0 # DW_CHILDREN_no
179 .byte 14 # DW_FORM_strp
180 .byte 62 # DW_AT_encoding
181 .byte 11 # DW_FORM_data1
182 .byte 11 # DW_AT_byte_size
183 .byte 11 # DW_FORM_data1
186 .byte 7 # Abbreviation Code
187 .byte 46 # DW_TAG_subprogram
188 .byte 1 # DW_CHILDREN_yes
189 .byte 17 # DW_AT_low_pc
190 .byte 1 # DW_FORM_addr
191 .byte 18 # DW_AT_high_pc
192 .byte 6 # DW_FORM_data4
193 .byte 64 # DW_AT_frame_base
194 .byte 24 # DW_FORM_exprloc
195 .ascii "\227B" # DW_AT_GNU_all_call_sites
196 .byte 25 # DW_FORM_flag_present
198 .byte 14 # DW_FORM_strp
199 .byte 58 # DW_AT_decl_file
200 .byte 11 # DW_FORM_data1
201 .byte 59 # DW_AT_decl_line
202 .byte 11 # DW_FORM_data1
203 .byte 73 # DW_AT_type
204 .byte 19 # DW_FORM_ref4
205 .byte 63 # DW_AT_external
206 .byte 25 # DW_FORM_flag_present
209 .byte 8 # Abbreviation Code
210 .byte 5 # DW_TAG_formal_parameter
211 .byte 0 # DW_CHILDREN_no
212 .byte 2 # DW_AT_location
213 .byte 24 # DW_FORM_exprloc
215 .byte 14 # DW_FORM_strp
216 .byte 58 # DW_AT_decl_file
217 .byte 11 # DW_FORM_data1
218 .byte 59 # DW_AT_decl_line
219 .byte 11 # DW_FORM_data1
220 .byte 73 # DW_AT_type
221 .byte 19 # DW_FORM_ref4
224 .byte 9 # Abbreviation Code
225 .byte 29 # DW_TAG_inlined_subroutine
226 .byte 1 # DW_CHILDREN_yes
227 .byte 49 # DW_AT_abstract_origin
228 .byte 19 # DW_FORM_ref4
229 .byte 17 # DW_AT_low_pc
230 .byte 1 # DW_FORM_addr
231 .byte 18 # DW_AT_high_pc
232 .byte 6 # DW_FORM_data4
233 .byte 88 # DW_AT_call_file
234 .byte 11 # DW_FORM_data1
235 .byte 89 # DW_AT_call_line
236 .byte 11 # DW_FORM_data1
237 .byte 87 # DW_AT_call_column
238 .byte 11 # DW_FORM_data1
241 .byte 10 # Abbreviation Code
242 .byte 15 # DW_TAG_pointer_type
243 .byte 0 # DW_CHILDREN_no
244 .byte 73 # DW_AT_type
245 .byte 19 # DW_FORM_ref4
248 .byte 11 # Abbreviation Code
249 .byte 38 # DW_TAG_const_type
250 .byte 0 # DW_CHILDREN_no
251 .byte 73 # DW_AT_type
252 .byte 19 # DW_FORM_ref4
256 .section .debug_info,"",@progbits
258 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
260 .short 4 # DWARF version number
261 .long .debug_abbrev # Offset Into Abbrev. Section
262 .byte 8 # Address Size (in bytes)
263 .byte 1 # Abbrev [1] 0xb:0xc8 DW_TAG_compile_unit
264 .long .Linfo_string0 # DW_AT_producer
265 .short 33 # DW_AT_language
266 .long .Linfo_string1 # DW_AT_name
267 .long .Lline_table_start0 # DW_AT_stmt_list
268 .long .Linfo_string2 # DW_AT_comp_dir
269 .quad 0 # DW_AT_low_pc
270 .long .Ldebug_ranges0 # DW_AT_ranges
271 .byte 2 # Abbrev [2] 0x2a:0x1d DW_TAG_subprogram
272 .quad .Lfunc_begin0 # DW_AT_low_pc
273 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
274 .byte 1 # DW_AT_frame_base
276 # DW_AT_GNU_all_call_sites
277 .long 71 # DW_AT_abstract_origin
278 .byte 3 # Abbrev [3] 0x3d:0x9 DW_TAG_formal_parameter
279 .long .Ldebug_loc0 # DW_AT_location
280 .long 87 # DW_AT_abstract_origin
281 .byte 0 # End Of Children Mark
282 .byte 4 # Abbrev [4] 0x47:0x1c DW_TAG_subprogram
283 .long .Linfo_string3 # DW_AT_linkage_name
284 .long .Linfo_string4 # DW_AT_name
285 .byte 1 # DW_AT_decl_file
286 .byte 2 # DW_AT_decl_line
287 .long 99 # DW_AT_type
289 .byte 1 # DW_AT_inline
290 .byte 5 # Abbrev [5] 0x57:0xb DW_TAG_formal_parameter
291 .long .Linfo_string6 # DW_AT_name
292 .byte 1 # DW_AT_decl_file
293 .byte 2 # DW_AT_decl_line
294 .long 99 # DW_AT_type
295 .byte 0 # End Of Children Mark
296 .byte 6 # Abbrev [6] 0x63:0x7 DW_TAG_base_type
297 .long .Linfo_string5 # DW_AT_name
298 .byte 5 # DW_AT_encoding
299 .byte 4 # DW_AT_byte_size
300 .byte 7 # Abbrev [7] 0x6a:0x52 DW_TAG_subprogram
301 .quad .Lfunc_begin1 # DW_AT_low_pc
302 .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
303 .byte 1 # DW_AT_frame_base
305 # DW_AT_GNU_all_call_sites
306 .long .Linfo_string7 # DW_AT_name
307 .byte 1 # DW_AT_decl_file
308 .byte 6 # DW_AT_decl_line
309 .long 99 # DW_AT_type
311 .byte 8 # Abbrev [8] 0x83:0xd DW_TAG_formal_parameter
312 .byte 1 # DW_AT_location
314 .long .Linfo_string8 # DW_AT_name
315 .byte 1 # DW_AT_decl_file
316 .byte 6 # DW_AT_decl_line
317 .long 99 # DW_AT_type
318 .byte 8 # Abbrev [8] 0x90:0xd DW_TAG_formal_parameter
319 .byte 1 # DW_AT_location
321 .long .Linfo_string9 # DW_AT_name
322 .byte 1 # DW_AT_decl_file
323 .byte 6 # DW_AT_decl_line
324 .long 188 # DW_AT_type
325 .byte 9 # Abbrev [9] 0x9d:0x1e DW_TAG_inlined_subroutine
326 .long 71 # DW_AT_abstract_origin
327 .quad .Lfunc_begin1 # DW_AT_low_pc
328 .long .Ltmp2-.Lfunc_begin1 # DW_AT_high_pc
329 .byte 1 # DW_AT_call_file
330 .byte 7 # DW_AT_call_line
331 .byte 10 # DW_AT_call_column
332 .byte 3 # Abbrev [3] 0xb1:0x9 DW_TAG_formal_parameter
333 .long .Ldebug_loc1 # DW_AT_location
334 .long 87 # DW_AT_abstract_origin
335 .byte 0 # End Of Children Mark
336 .byte 0 # End Of Children Mark
337 .byte 10 # Abbrev [10] 0xbc:0x5 DW_TAG_pointer_type
338 .long 193 # DW_AT_type
339 .byte 10 # Abbrev [10] 0xc1:0x5 DW_TAG_pointer_type
340 .long 198 # DW_AT_type
341 .byte 11 # Abbrev [11] 0xc6:0x5 DW_TAG_const_type
342 .long 203 # DW_AT_type
343 .byte 6 # Abbrev [6] 0xcb:0x7 DW_TAG_base_type
344 .long .Linfo_string10 # DW_AT_name
345 .byte 6 # DW_AT_encoding
346 .byte 1 # DW_AT_byte_size
347 .byte 0 # End Of Children Mark
349 .section .debug_ranges,"",@progbits
357 .section .debug_str,"MS",@progbits,1
359 .asciz "clang version 15.0.0" # string offset=0
361 .asciz "main.cpp" # string offset=134
363 .asciz "." # string offset=143
365 .asciz "_Z8doStuff2i" # string offset=181
367 .asciz "doStuff2" # string offset=194
369 .asciz "int" # string offset=203
371 .asciz "val" # string offset=207
373 .asciz "main" # string offset=211
375 .asciz "argc" # string offset=216
377 .asciz "argv" # string offset=221
379 .asciz "char" # string offset=226
380 .ident "clang version 15.0.0"
381 .section ".note.GNU-stack","",@progbits
383 .section .debug_line,"",@progbits