486 lines · plain
1# REQUIRES: system-linux2 3# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o4# RUN: %clang %cflags -dwarf-5 %t1.o -o %t.exe -Wl,-q5# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --skip-funcs=main6# RUN: llvm-dwarfdump --show-form --verbose --debug-loclists --debug-addr %t.bolt > %t.txt7# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt8# RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s9 10## Tests to make sure BOLT handles correctly locations that are out of order, and the function is not being processed.11 12# POSTCHECK: DW_LLE_base_addressx13# POSTCHECK-NEXT: DW_LLE_offset_pair14# POSTCHECK-NEXT: DW_LLE_offset_pair15# POSTCHECK-NEXT: DW_LLE_startx_length16# POSTCHECK-NEXT: DW_LLE_end_of_list17# POSTCHECK: DW_LLE_base_addressx18# POSTCHECK-NEXT: DW_LLE_offset_pair19# POSTCHECK-NEXT: DW_LLE_offset_pair20# POSTCHECK-NEXT: DW_LLE_end_of_list21 22# POSTCHECK: Addrs: [23# POSTCHECK-NEXT: 0x[[#%.16x,ADDR:]]24# POSTCHECK-NEXT: 0x25# POSTCHECK-NEXT: 0x26# POSTCHECK-NEXT: 0x[[#%.16x,ADDR1:]]27# POSTCHECK-NEXT: 0x28# POSTCHECK-NEXT: 0x29 30# POSTCHECK: DW_TAG_formal_parameter31# POSTCHECK: DW_TAG_formal_parameter32# POSTCHECK-NEXT: DW_AT_location33# POSTCHECK-NEXT: [0x[[#ADDR1]], 0x[[#ADDR1 + 0x1a]]): DW_OP_reg3 RBX34# POSTCHECK-NEXT: [0x[[#ADDR1 + 0x1a]], 0x[[#ADDR1 + 0x1d]]): DW_OP_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value35# POSTCHECK-NEXT: [0x[[#ADDR]], 0x[[#ADDR + 0x12]]): DW_OP_reg5 RDI)36 37## clang++ main.cpp -fno-inline-functions -g2 -O2 -S38## void use(int * x) {39## *x += 4;40## }41## int main(int argc, char *argv[]) {42## int x = argc;43## use(&x);44## x = x + argc;45## use(&x);46## return x;47## }48 49## Test was manually modified to re-order locations.50 .text51 .file "main.cpp"52 .globl _Z3usePi # -- Begin function _Z3usePi53 .p2align 4, 0x9054 .type _Z3usePi,@function55_Z3usePi: # @_Z3usePi56.Lfunc_begin0:57 .file 0 "/repro" "main.cpp" md5 0xe24a1d6afb5e23ce0028f1f33bc08cd758 .cfi_startproc59# %bb.0: # %entry60 #DEBUG_VALUE: use:x <- $rdi61 .loc 0 2 8 prologue_end # main.cpp:2:862 addl $4, (%rdi)63 .loc 0 3 1 # main.cpp:3:164 retq65.Ltmp0:66.Lfunc_end0:67 .size _Z3usePi, .Lfunc_end0-_Z3usePi68 .cfi_endproc69 # -- End function70 .globl main # -- Begin function main71 .p2align 4, 0x9072 .type main,@function73main: # @main74.Lfunc_begin1:75 .loc 0 4 0 # main.cpp:4:076 .cfi_startproc77# %bb.0: # %entry78 #DEBUG_VALUE: main:argc <- $edi79 #DEBUG_VALUE: main:argv <- $rsi80 pushq %r1481 .cfi_def_cfa_offset 1682 pushq %rbx83 .cfi_def_cfa_offset 2484 pushq %rax85 .cfi_def_cfa_offset 3286 .cfi_offset %rbx, -2487 .cfi_offset %r14, -1688 movl %edi, %ebx89.Ltmp1:90 .loc 0 5 7 prologue_end # main.cpp:5:791 movl %edi, 4(%rsp)92 leaq 4(%rsp), %r1493 .loc 0 6 3 # main.cpp:6:394 movq %r14, %rdi95.Ltmp2:96 #DEBUG_VALUE: main:argc <- $ebx97 callq _Z3usePi98.Ltmp3:99 #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi100 .loc 0 7 5 # main.cpp:7:5101 addl %ebx, 4(%rsp)102 .loc 0 8 3 # main.cpp:8:3103 movq %r14, %rdi104 callq _Z3usePi105.Ltmp4:106 .loc 0 9 10 # main.cpp:9:10107 movl 4(%rsp), %eax108 .loc 0 9 3 epilogue_begin is_stmt 0 # main.cpp:9:3109 addq $8, %rsp110 .cfi_def_cfa_offset 24111 popq %rbx112.Ltmp5:113 #DEBUG_VALUE: main:argc <- [DW_OP_LLVM_entry_value 1] $edi114 .cfi_def_cfa_offset 16115 popq %r14116 .cfi_def_cfa_offset 8117 retq118.Ltmp6:119.Lfunc_end1:120 .size main, .Lfunc_end1-main121 .cfi_endproc122 # -- End function123 .section .debug_loclists,"",@progbits124 .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length125.Ldebug_list_header_start0:126 .short 5 # Version127 .byte 8 # Address size128 .byte 0 # Segment selector size129 .long 2 # Offset entry count130.Lloclists_table_base0:131 .long .Ldebug_loc0-.Lloclists_table_base0132 .long .Ldebug_loc1-.Lloclists_table_base0133.Ldebug_loc0:134 .byte 4 # DW_LLE_offset_pair135 .uleb128 .Ltmp2-.Lfunc_begin0 # starting offset136 .uleb128 .Ltmp5-.Lfunc_begin0 # ending offset137 .byte 1 # Loc expr size138 .byte 83 # super-register DW_OP_reg3139 .byte 4 # DW_LLE_offset_pair140 .uleb128 .Ltmp5-.Lfunc_begin0 # starting offset141 .uleb128 .Lfunc_end1-.Lfunc_begin0 # ending offset142 .byte 4 # Loc expr size143 .byte 163 # DW_OP_entry_value144 .byte 1 # 1145 .byte 85 # super-register DW_OP_reg5146 .byte 159 # DW_OP_stack_value147 .byte 4 # DW_LLE_offset_pair #manually moved out of order148 .uleb128 .Lfunc_begin1-.Lfunc_begin0 # starting offset149 .uleb128 .Ltmp2-.Lfunc_begin0 # ending offset150 .byte 1 # Loc expr size151 .byte 85 # super-register DW_OP_reg5152 .byte 0 # DW_LLE_end_of_list153.Ldebug_loc1:154 .byte 4 # DW_LLE_offset_pair155 .uleb128 .Lfunc_begin1-.Lfunc_begin0 # starting offset156 .uleb128 .Ltmp3-.Lfunc_begin0 # ending offset157 .byte 1 # Loc expr size158 .byte 84 # DW_OP_reg4159 .byte 4 # DW_LLE_offset_pair160 .uleb128 .Ltmp3-.Lfunc_begin0 # starting offset161 .uleb128 .Lfunc_end1-.Lfunc_begin0 # ending offset162 .byte 4 # Loc expr size163 .byte 163 # DW_OP_entry_value164 .byte 1 # 1165 .byte 84 # DW_OP_reg4166 .byte 159 # DW_OP_stack_value167 .byte 0 # DW_LLE_end_of_list168.Ldebug_list_header_end0:169 .section .debug_abbrev,"",@progbits170 .byte 1 # Abbreviation Code171 .byte 17 # DW_TAG_compile_unit172 .byte 1 # DW_CHILDREN_yes173 .byte 37 # DW_AT_producer174 .byte 37 # DW_FORM_strx1175 .byte 19 # DW_AT_language176 .byte 5 # DW_FORM_data2177 .byte 3 # DW_AT_name178 .byte 37 # DW_FORM_strx1179 .byte 114 # DW_AT_str_offsets_base180 .byte 23 # DW_FORM_sec_offset181 .byte 16 # DW_AT_stmt_list182 .byte 23 # DW_FORM_sec_offset183 .byte 27 # DW_AT_comp_dir184 .byte 37 # DW_FORM_strx1185 .byte 17 # DW_AT_low_pc186 .byte 27 # DW_FORM_addrx187 .byte 18 # DW_AT_high_pc188 .byte 6 # DW_FORM_data4189 .byte 115 # DW_AT_addr_base190 .byte 23 # DW_FORM_sec_offset191 .ascii "\214\001" # DW_AT_loclists_base192 .byte 23 # DW_FORM_sec_offset193 .byte 0 # EOM(1)194 .byte 0 # EOM(2)195 .byte 2 # Abbreviation Code196 .byte 46 # DW_TAG_subprogram197 .byte 1 # DW_CHILDREN_yes198 .byte 17 # DW_AT_low_pc199 .byte 27 # DW_FORM_addrx200 .byte 18 # DW_AT_high_pc201 .byte 6 # DW_FORM_data4202 .byte 64 # DW_AT_frame_base203 .byte 24 # DW_FORM_exprloc204 .byte 122 # DW_AT_call_all_calls205 .byte 25 # DW_FORM_flag_present206 .byte 110 # DW_AT_linkage_name207 .byte 37 # DW_FORM_strx1208 .byte 3 # DW_AT_name209 .byte 37 # DW_FORM_strx1210 .byte 58 # DW_AT_decl_file211 .byte 11 # DW_FORM_data1212 .byte 59 # DW_AT_decl_line213 .byte 11 # DW_FORM_data1214 .byte 63 # DW_AT_external215 .byte 25 # DW_FORM_flag_present216 .byte 0 # EOM(1)217 .byte 0 # EOM(2)218 .byte 3 # Abbreviation Code219 .byte 5 # DW_TAG_formal_parameter220 .byte 0 # DW_CHILDREN_no221 .byte 2 # DW_AT_location222 .byte 24 # DW_FORM_exprloc223 .byte 3 # DW_AT_name224 .byte 37 # DW_FORM_strx1225 .byte 58 # DW_AT_decl_file226 .byte 11 # DW_FORM_data1227 .byte 59 # DW_AT_decl_line228 .byte 11 # DW_FORM_data1229 .byte 73 # DW_AT_type230 .byte 19 # DW_FORM_ref4231 .byte 0 # EOM(1)232 .byte 0 # EOM(2)233 .byte 4 # Abbreviation Code234 .byte 46 # DW_TAG_subprogram235 .byte 1 # DW_CHILDREN_yes236 .byte 17 # DW_AT_low_pc237 .byte 27 # DW_FORM_addrx238 .byte 18 # DW_AT_high_pc239 .byte 6 # DW_FORM_data4240 .byte 64 # DW_AT_frame_base241 .byte 24 # DW_FORM_exprloc242 .byte 122 # DW_AT_call_all_calls243 .byte 25 # DW_FORM_flag_present244 .byte 3 # DW_AT_name245 .byte 37 # DW_FORM_strx1246 .byte 58 # DW_AT_decl_file247 .byte 11 # DW_FORM_data1248 .byte 59 # DW_AT_decl_line249 .byte 11 # DW_FORM_data1250 .byte 73 # DW_AT_type251 .byte 19 # DW_FORM_ref4252 .byte 63 # DW_AT_external253 .byte 25 # DW_FORM_flag_present254 .byte 0 # EOM(1)255 .byte 0 # EOM(2)256 .byte 5 # Abbreviation Code257 .byte 5 # DW_TAG_formal_parameter258 .byte 0 # DW_CHILDREN_no259 .byte 2 # DW_AT_location260 .byte 34 # DW_FORM_loclistx261 .byte 3 # DW_AT_name262 .byte 37 # DW_FORM_strx1263 .byte 58 # DW_AT_decl_file264 .byte 11 # DW_FORM_data1265 .byte 59 # DW_AT_decl_line266 .byte 11 # DW_FORM_data1267 .byte 73 # DW_AT_type268 .byte 19 # DW_FORM_ref4269 .byte 0 # EOM(1)270 .byte 0 # EOM(2)271 .byte 6 # Abbreviation Code272 .byte 52 # DW_TAG_variable273 .byte 0 # DW_CHILDREN_no274 .byte 2 # DW_AT_location275 .byte 24 # DW_FORM_exprloc276 .byte 3 # DW_AT_name277 .byte 37 # DW_FORM_strx1278 .byte 58 # DW_AT_decl_file279 .byte 11 # DW_FORM_data1280 .byte 59 # DW_AT_decl_line281 .byte 11 # DW_FORM_data1282 .byte 73 # DW_AT_type283 .byte 19 # DW_FORM_ref4284 .byte 0 # EOM(1)285 .byte 0 # EOM(2)286 .byte 7 # Abbreviation Code287 .byte 72 # DW_TAG_call_site288 .byte 1 # DW_CHILDREN_yes289 .byte 127 # DW_AT_call_origin290 .byte 19 # DW_FORM_ref4291 .byte 125 # DW_AT_call_return_pc292 .byte 27 # DW_FORM_addrx293 .byte 0 # EOM(1)294 .byte 0 # EOM(2)295 .byte 8 # Abbreviation Code296 .byte 73 # DW_TAG_call_site_parameter297 .byte 0 # DW_CHILDREN_no298 .byte 2 # DW_AT_location299 .byte 24 # DW_FORM_exprloc300 .byte 126 # DW_AT_call_value301 .byte 24 # DW_FORM_exprloc302 .byte 0 # EOM(1)303 .byte 0 # EOM(2)304 .byte 9 # Abbreviation Code305 .byte 36 # DW_TAG_base_type306 .byte 0 # DW_CHILDREN_no307 .byte 3 # DW_AT_name308 .byte 37 # DW_FORM_strx1309 .byte 62 # DW_AT_encoding310 .byte 11 # DW_FORM_data1311 .byte 11 # DW_AT_byte_size312 .byte 11 # DW_FORM_data1313 .byte 0 # EOM(1)314 .byte 0 # EOM(2)315 .byte 10 # Abbreviation Code316 .byte 15 # DW_TAG_pointer_type317 .byte 0 # DW_CHILDREN_no318 .byte 73 # DW_AT_type319 .byte 19 # DW_FORM_ref4320 .byte 0 # EOM(1)321 .byte 0 # EOM(2)322 .byte 0 # EOM(3)323 .section .debug_info,"",@progbits324.Lcu_begin0:325 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit326.Ldebug_info_start0:327 .short 5 # DWARF version number328 .byte 1 # DWARF Unit Type329 .byte 8 # Address Size (in bytes)330 .long .debug_abbrev # Offset Into Abbrev. Section331 .byte 1 # Abbrev [1] 0xc:0x91 DW_TAG_compile_unit332 .byte 0 # DW_AT_producer333 .short 33 # DW_AT_language334 .byte 1 # DW_AT_name335 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base336 .long .Lline_table_start0 # DW_AT_stmt_list337 .byte 2 # DW_AT_comp_dir338 .byte 0 # DW_AT_low_pc339 .long .Lfunc_end1-.Lfunc_begin0 # DW_AT_high_pc340 .long .Laddr_table_base0 # DW_AT_addr_base341 .long .Lloclists_table_base0 # DW_AT_loclists_base342 .byte 2 # Abbrev [2] 0x27:0x17 DW_TAG_subprogram343 .byte 0 # DW_AT_low_pc344 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc345 .byte 1 # DW_AT_frame_base346 .byte 87347 # DW_AT_call_all_calls348 .byte 3 # DW_AT_linkage_name349 .byte 4 # DW_AT_name350 .byte 0 # DW_AT_decl_file351 .byte 1 # DW_AT_decl_line352 # DW_AT_external353 .byte 3 # Abbrev [3] 0x33:0xa DW_TAG_formal_parameter354 .byte 1 # DW_AT_location355 .byte 85356 .byte 7 # DW_AT_name357 .byte 0 # DW_AT_decl_file358 .byte 1 # DW_AT_decl_line359 .long 137 # DW_AT_type360 .byte 0 # End Of Children Mark361 .byte 4 # Abbrev [4] 0x3e:0x47 DW_TAG_subprogram362 .byte 1 # DW_AT_low_pc363 .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc364 .byte 1 # DW_AT_frame_base365 .byte 87366 # DW_AT_call_all_calls367 .byte 5 # DW_AT_name368 .byte 0 # DW_AT_decl_file369 .byte 4 # DW_AT_decl_line370 .long 133 # DW_AT_type371 # DW_AT_external372 .byte 5 # Abbrev [5] 0x4d:0x9 DW_TAG_formal_parameter373 .byte 0 # DW_AT_location374 .byte 8 # DW_AT_name375 .byte 0 # DW_AT_decl_file376 .byte 4 # DW_AT_decl_line377 .long 133 # DW_AT_type378 .byte 5 # Abbrev [5] 0x56:0x9 DW_TAG_formal_parameter379 .byte 1 # DW_AT_location380 .byte 9 # DW_AT_name381 .byte 0 # DW_AT_decl_file382 .byte 4 # DW_AT_decl_line383 .long 142 # DW_AT_type384 .byte 6 # Abbrev [6] 0x5f:0xb DW_TAG_variable385 .byte 2 # DW_AT_location386 .byte 145387 .byte 4388 .byte 7 # DW_AT_name389 .byte 0 # DW_AT_decl_file390 .byte 5 # DW_AT_decl_line391 .long 133 # DW_AT_type392 .byte 7 # Abbrev [7] 0x6a:0xd DW_TAG_call_site393 .long 39 # DW_AT_call_origin394 .byte 2 # DW_AT_call_return_pc395 .byte 8 # Abbrev [8] 0x70:0x6 DW_TAG_call_site_parameter396 .byte 1 # DW_AT_location397 .byte 85398 .byte 2 # DW_AT_call_value399 .byte 126400 .byte 0401 .byte 0 # End Of Children Mark402 .byte 7 # Abbrev [7] 0x77:0xd DW_TAG_call_site403 .long 39 # DW_AT_call_origin404 .byte 3 # DW_AT_call_return_pc405 .byte 8 # Abbrev [8] 0x7d:0x6 DW_TAG_call_site_parameter406 .byte 1 # DW_AT_location407 .byte 85408 .byte 2 # DW_AT_call_value409 .byte 126410 .byte 0411 .byte 0 # End Of Children Mark412 .byte 0 # End Of Children Mark413 .byte 9 # Abbrev [9] 0x85:0x4 DW_TAG_base_type414 .byte 6 # DW_AT_name415 .byte 5 # DW_AT_encoding416 .byte 4 # DW_AT_byte_size417 .byte 10 # Abbrev [10] 0x89:0x5 DW_TAG_pointer_type418 .long 133 # DW_AT_type419 .byte 10 # Abbrev [10] 0x8e:0x5 DW_TAG_pointer_type420 .long 147 # DW_AT_type421 .byte 10 # Abbrev [10] 0x93:0x5 DW_TAG_pointer_type422 .long 152 # DW_AT_type423 .byte 9 # Abbrev [9] 0x98:0x4 DW_TAG_base_type424 .byte 10 # DW_AT_name425 .byte 6 # DW_AT_encoding426 .byte 1 # DW_AT_byte_size427 .byte 0 # End Of Children Mark428.Ldebug_info_end0:429 .section .debug_str_offsets,"",@progbits430 .long 48 # Length of String Offsets Set431 .short 5432 .short 0433.Lstr_offsets_base0:434 .section .debug_str,"MS",@progbits,1435.Linfo_string0:436 .asciz "clang version 19.0.0git (git@github.com:ayermolo/llvm-project.git a1e412af2bf4bf613021f72205f249ab2469f08b)" # string offset=0437.Linfo_string1:438 .asciz "main.cpp" # string offset=108439.Linfo_string2:440 .asciz "/repro" # string offset=117441.Linfo_string3:442 .asciz "_Z3usePi" # string offset=161443.Linfo_string4:444 .asciz "use" # string offset=170445.Linfo_string5:446 .asciz "main" # string offset=174447.Linfo_string6:448 .asciz "int" # string offset=179449.Linfo_string7:450 .asciz "x" # string offset=183451.Linfo_string8:452 .asciz "argc" # string offset=185453.Linfo_string9:454 .asciz "argv" # string offset=190455.Linfo_string10:456 .asciz "char" # string offset=195457 .section .debug_str_offsets,"",@progbits458 .long .Linfo_string0459 .long .Linfo_string1460 .long .Linfo_string2461 .long .Linfo_string3462 .long .Linfo_string4463 .long .Linfo_string5464 .long .Linfo_string6465 .long .Linfo_string7466 .long .Linfo_string8467 .long .Linfo_string9468 .long .Linfo_string10469 .section .debug_addr,"",@progbits470 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution471.Ldebug_addr_start0:472 .short 5 # DWARF version number473 .byte 8 # Address size474 .byte 0 # Segment selector size475.Laddr_table_base0:476 .quad .Lfunc_begin0477 .quad .Lfunc_begin1478 .quad .Ltmp3479 .quad .Ltmp4480.Ldebug_addr_end0:481 .ident "clang version 19.0.0git (git@github.com:ayermolo/llvm-project.git a1e412af2bf4bf613021f72205f249ab2469f08b)"482 .section ".note.GNU-stack","",@progbits483 .addrsig484 .section .debug_line,"",@progbits485.Lline_table_start0:486