539 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,-q -Wl,-gc-sections -fuse-ld=lld -Wl,--entry=main5# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections6# RUN: llvm-dwarfdump --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s7# RUN: llvm-dwarfdump --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s8 9# PRECHECK: DW_TAG_subprogram10# PRECHECK-NEXT: DW_AT_ranges11# PRECHECK-NEXT: [0x000000000000000012# PRECHECK-NEXT: [0x000000000000000013# PRECHECK-NEXT: [0x000000000000000014# PRECHECK-NEXT: [0x000000000000000015# PRECHECK-NEXT: DW_AT_frame_base16# PRECHECK-NEXT: DW_AT_linkage_name ("_Z6helperi")17# PRECHECK-NEXT: DW_AT_name ("helper")18 19# POSTCHECK: DW_TAG_subprogram20# POSTCHECK-NEXT: DW_AT_frame_base21# POSTCHECK-NEXT: DW_AT_linkage_name ("_Z6helperi")22# POSTCHECK-NEXT: DW_AT_name ("helper")23# POSTCHECK-NEXT: DW_AT_decl_file24# POSTCHECK-NEXT: DW_AT_decl_line25# POSTCHECK-NEXT: DW_AT_type26# POSTCHECK-NEXT: DW_AT_external27# POSTCHECK-NEXT: DW_AT_low_pc (0x0000000000000000)28# POSTCHECK-NEXT: DW_AT_high_pc (0x0000000000000001)29 30## Tests BOLT path that handles DW_AT_ranges with no output function ranges.31 32## clang++ main.cpp -O0 -fno-inline-functions -fbasic-block-sections=all -g2 -S33## int helper(int argc) {34## int x = argc;35## if (x == 3)36## x++;37## else38## x--;39## return x;40## }41## int main(int argc, char *argv[]) {42## int x = argc;43## if (x == 3)44## x++;45## else46## x--;47## return x;48## }49 50 .text51 .file "main.cpp"52 .section .text._Z6helperi,"ax",@progbits53 .globl _Z6helperi # -- Begin function _Z6helperi54 .p2align 4, 0x9055 .type _Z6helperi,@function56_Z6helperi: # @_Z6helperi57.Lfunc_begin0:58 .file 0 "/repro2" "main.cpp" md5 0x888a2704226ec400f256aa9c2207456c59 .loc 0 1 0 # main.cpp:1:060 .cfi_startproc61# %bb.0: # %entry62 pushq %rbp63 .cfi_def_cfa_offset 1664 .cfi_offset %rbp, -1665 movq %rsp, %rbp66 .cfi_def_cfa_register %rbp67 movl %edi, -4(%rbp)68.Ltmp0:69 .loc 0 2 11 prologue_end # main.cpp:2:1170 movl -4(%rbp), %eax71 .loc 0 2 7 is_stmt 0 # main.cpp:2:772 movl %eax, -8(%rbp)73.Ltmp1:74 .loc 0 3 9 is_stmt 1 # main.cpp:3:975 cmpl $3, -8(%rbp)76.Ltmp2:77 .loc 0 3 7 is_stmt 0 # main.cpp:3:778 jne _Z6helperi.__part.279 jmp _Z6helperi.__part.180.LBB_END0_0:81 .cfi_endproc82 .section .text._Z6helperi,"ax",@progbits,unique,183_Z6helperi.__part.1: # %if.then84 .cfi_startproc85 .cfi_def_cfa %rbp, 1686 .cfi_offset %rbp, -1687 .loc 0 4 6 is_stmt 1 # main.cpp:4:688 movl -8(%rbp), %eax89 addl $1, %eax90 movl %eax, -8(%rbp)91 .loc 0 4 5 is_stmt 0 # main.cpp:4:592 jmp _Z6helperi.__part.393.LBB_END0_1:94 .size _Z6helperi.__part.1, .LBB_END0_1-_Z6helperi.__part.195 .cfi_endproc96 .section .text._Z6helperi,"ax",@progbits,unique,297_Z6helperi.__part.2: # %if.else98 .cfi_startproc99 .cfi_def_cfa %rbp, 16100 .cfi_offset %rbp, -16101 .loc 0 6 6 is_stmt 1 # main.cpp:6:6102 movl -8(%rbp), %eax103 addl $-1, %eax104 movl %eax, -8(%rbp)105 jmp _Z6helperi.__part.3106.LBB_END0_2:107 .size _Z6helperi.__part.2, .LBB_END0_2-_Z6helperi.__part.2108 .cfi_endproc109 .section .text._Z6helperi,"ax",@progbits,unique,3110_Z6helperi.__part.3: # %if.end111 .cfi_startproc112 .cfi_def_cfa %rbp, 16113 .cfi_offset %rbp, -16114 .loc 0 7 10 # main.cpp:7:10115 movl -8(%rbp), %eax116 .loc 0 7 3 epilogue_begin is_stmt 0 # main.cpp:7:3117 popq %rbp118 .cfi_def_cfa %rsp, 8119 retq120.LBB_END0_3:121 .size _Z6helperi.__part.3, .LBB_END0_3-_Z6helperi.__part.3122 .cfi_endproc123 .section .text._Z6helperi,"ax",@progbits124.Lfunc_end0:125 .size _Z6helperi, .Lfunc_end0-_Z6helperi126 # -- End function127 .section .text.main,"ax",@progbits128 .globl main # -- Begin function main129 .p2align 4, 0x90130 .type main,@function131main: # @main132.Lfunc_begin1:133 .loc 0 9 0 is_stmt 1 # main.cpp:9:0134 .cfi_startproc135# %bb.0: # %entry136 pushq %rbp137 .cfi_def_cfa_offset 16138 .cfi_offset %rbp, -16139 movq %rsp, %rbp140 .cfi_def_cfa_register %rbp141 movl $0, -4(%rbp)142 movl %edi, -8(%rbp)143 movq %rsi, -16(%rbp)144.Ltmp3:145 .loc 0 10 11 prologue_end # main.cpp:10:11146 movl -8(%rbp), %eax147 .loc 0 10 7 is_stmt 0 # main.cpp:10:7148 movl %eax, -20(%rbp)149.Ltmp4:150 .loc 0 11 9 is_stmt 1 # main.cpp:11:9151 cmpl $3, -20(%rbp)152.Ltmp5:153 .loc 0 11 7 is_stmt 0 # main.cpp:11:7154 jne main.__part.2155 jmp main.__part.1156.LBB_END1_0:157 .cfi_endproc158 .section .text.main,"ax",@progbits,unique,4159main.__part.1: # %if.then160 .cfi_startproc161 .cfi_def_cfa %rbp, 16162 .cfi_offset %rbp, -16163 .loc 0 12 6 is_stmt 1 # main.cpp:12:6164 movl -20(%rbp), %eax165 addl $1, %eax166 movl %eax, -20(%rbp)167 .loc 0 12 5 is_stmt 0 # main.cpp:12:5168 jmp main.__part.3169.LBB_END1_1:170 .size main.__part.1, .LBB_END1_1-main.__part.1171 .cfi_endproc172 .section .text.main,"ax",@progbits,unique,5173main.__part.2: # %if.else174 .cfi_startproc175 .cfi_def_cfa %rbp, 16176 .cfi_offset %rbp, -16177 .loc 0 14 6 is_stmt 1 # main.cpp:14:6178 movl -20(%rbp), %eax179 addl $-1, %eax180 movl %eax, -20(%rbp)181 jmp main.__part.3182.LBB_END1_2:183 .size main.__part.2, .LBB_END1_2-main.__part.2184 .cfi_endproc185 .section .text.main,"ax",@progbits,unique,6186main.__part.3: # %if.end187 .cfi_startproc188 .cfi_def_cfa %rbp, 16189 .cfi_offset %rbp, -16190 .loc 0 15 10 # main.cpp:15:10191 movl -20(%rbp), %eax192 .loc 0 15 3 epilogue_begin is_stmt 0 # main.cpp:15:3193 popq %rbp194 .cfi_def_cfa %rsp, 8195 retq196.LBB_END1_3:197 .size main.__part.3, .LBB_END1_3-main.__part.3198 .cfi_endproc199 .section .text.main,"ax",@progbits200.Lfunc_end1:201 .size main, .Lfunc_end1-main202 # -- End function203 .section .debug_abbrev,"",@progbits204 .byte 1 # Abbreviation Code205 .byte 17 # DW_TAG_compile_unit206 .byte 1 # DW_CHILDREN_yes207 .byte 37 # DW_AT_producer208 .byte 37 # DW_FORM_strx1209 .byte 19 # DW_AT_language210 .byte 5 # DW_FORM_data2211 .byte 3 # DW_AT_name212 .byte 37 # DW_FORM_strx1213 .byte 114 # DW_AT_str_offsets_base214 .byte 23 # DW_FORM_sec_offset215 .byte 16 # DW_AT_stmt_list216 .byte 23 # DW_FORM_sec_offset217 .byte 27 # DW_AT_comp_dir218 .byte 37 # DW_FORM_strx1219 .byte 17 # DW_AT_low_pc220 .byte 1 # DW_FORM_addr221 .byte 85 # DW_AT_ranges222 .byte 35 # DW_FORM_rnglistx223 .byte 115 # DW_AT_addr_base224 .byte 23 # DW_FORM_sec_offset225 .byte 116 # DW_AT_rnglists_base226 .byte 23 # DW_FORM_sec_offset227 .byte 0 # EOM(1)228 .byte 0 # EOM(2)229 .byte 2 # Abbreviation Code230 .byte 46 # DW_TAG_subprogram231 .byte 1 # DW_CHILDREN_yes232 .byte 85 # DW_AT_ranges233 .byte 35 # DW_FORM_rnglistx234 .byte 64 # DW_AT_frame_base235 .byte 24 # DW_FORM_exprloc236 .byte 110 # DW_AT_linkage_name237 .byte 37 # DW_FORM_strx1238 .byte 3 # DW_AT_name239 .byte 37 # DW_FORM_strx1240 .byte 58 # DW_AT_decl_file241 .byte 11 # DW_FORM_data1242 .byte 59 # DW_AT_decl_line243 .byte 11 # DW_FORM_data1244 .byte 73 # DW_AT_type245 .byte 19 # DW_FORM_ref4246 .byte 63 # DW_AT_external247 .byte 25 # DW_FORM_flag_present248 .byte 0 # EOM(1)249 .byte 0 # EOM(2)250 .byte 3 # Abbreviation Code251 .byte 5 # DW_TAG_formal_parameter252 .byte 0 # DW_CHILDREN_no253 .byte 2 # DW_AT_location254 .byte 24 # DW_FORM_exprloc255 .byte 3 # DW_AT_name256 .byte 37 # DW_FORM_strx1257 .byte 58 # DW_AT_decl_file258 .byte 11 # DW_FORM_data1259 .byte 59 # DW_AT_decl_line260 .byte 11 # DW_FORM_data1261 .byte 73 # DW_AT_type262 .byte 19 # DW_FORM_ref4263 .byte 0 # EOM(1)264 .byte 0 # EOM(2)265 .byte 4 # Abbreviation Code266 .byte 52 # DW_TAG_variable267 .byte 0 # DW_CHILDREN_no268 .byte 2 # DW_AT_location269 .byte 24 # DW_FORM_exprloc270 .byte 3 # DW_AT_name271 .byte 37 # DW_FORM_strx1272 .byte 58 # DW_AT_decl_file273 .byte 11 # DW_FORM_data1274 .byte 59 # DW_AT_decl_line275 .byte 11 # DW_FORM_data1276 .byte 73 # DW_AT_type277 .byte 19 # DW_FORM_ref4278 .byte 0 # EOM(1)279 .byte 0 # EOM(2)280 .byte 5 # Abbreviation Code281 .byte 46 # DW_TAG_subprogram282 .byte 1 # DW_CHILDREN_yes283 .byte 85 # DW_AT_ranges284 .byte 35 # DW_FORM_rnglistx285 .byte 64 # DW_AT_frame_base286 .byte 24 # DW_FORM_exprloc287 .byte 3 # DW_AT_name288 .byte 37 # DW_FORM_strx1289 .byte 58 # DW_AT_decl_file290 .byte 11 # DW_FORM_data1291 .byte 59 # DW_AT_decl_line292 .byte 11 # DW_FORM_data1293 .byte 73 # DW_AT_type294 .byte 19 # DW_FORM_ref4295 .byte 63 # DW_AT_external296 .byte 25 # DW_FORM_flag_present297 .byte 0 # EOM(1)298 .byte 0 # EOM(2)299 .byte 6 # Abbreviation Code300 .byte 36 # DW_TAG_base_type301 .byte 0 # DW_CHILDREN_no302 .byte 3 # DW_AT_name303 .byte 37 # DW_FORM_strx1304 .byte 62 # DW_AT_encoding305 .byte 11 # DW_FORM_data1306 .byte 11 # DW_AT_byte_size307 .byte 11 # DW_FORM_data1308 .byte 0 # EOM(1)309 .byte 0 # EOM(2)310 .byte 7 # Abbreviation Code311 .byte 15 # DW_TAG_pointer_type312 .byte 0 # DW_CHILDREN_no313 .byte 73 # DW_AT_type314 .byte 19 # DW_FORM_ref4315 .byte 0 # EOM(1)316 .byte 0 # EOM(2)317 .byte 0 # EOM(3)318 .section .debug_info,"",@progbits319.Lcu_begin0:320 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit321.Ldebug_info_start0:322 .short 5 # DWARF version number323 .byte 1 # DWARF Unit Type324 .byte 8 # Address Size (in bytes)325 .long .debug_abbrev # Offset Into Abbrev. Section326 .byte 1 # Abbrev [1] 0xc:0x82 DW_TAG_compile_unit327 .byte 0 # DW_AT_producer328 .short 33 # DW_AT_language329 .byte 1 # DW_AT_name330 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base331 .long .Lline_table_start0 # DW_AT_stmt_list332 .byte 2 # DW_AT_comp_dir333 .quad 0 # DW_AT_low_pc334 .byte 2 # DW_AT_ranges335 .long .Laddr_table_base0 # DW_AT_addr_base336 .long .Lrnglists_table_base0 # DW_AT_rnglists_base337 .byte 2 # Abbrev [2] 0x2b:0x23 DW_TAG_subprogram338 .byte 0 # DW_AT_ranges339 .byte 1 # DW_AT_frame_base340 .byte 86341 .byte 3 # DW_AT_linkage_name342 .byte 4 # DW_AT_name343 .byte 0 # DW_AT_decl_file344 .byte 1 # DW_AT_decl_line345 .long 123 # DW_AT_type346 # DW_AT_external347 .byte 3 # Abbrev [3] 0x37:0xb DW_TAG_formal_parameter348 .byte 2 # DW_AT_location349 .byte 145350 .byte 124351 .byte 7 # DW_AT_name352 .byte 0 # DW_AT_decl_file353 .byte 1 # DW_AT_decl_line354 .long 123 # DW_AT_type355 .byte 4 # Abbrev [4] 0x42:0xb DW_TAG_variable356 .byte 2 # DW_AT_location357 .byte 145358 .byte 120359 .byte 8 # DW_AT_name360 .byte 0 # DW_AT_decl_file361 .byte 2 # DW_AT_decl_line362 .long 123 # DW_AT_type363 .byte 0 # End Of Children Mark364 .byte 5 # Abbrev [5] 0x4e:0x2d DW_TAG_subprogram365 .byte 1 # DW_AT_ranges366 .byte 1 # DW_AT_frame_base367 .byte 86368 .byte 6 # DW_AT_name369 .byte 0 # DW_AT_decl_file370 .byte 9 # DW_AT_decl_line371 .long 123 # DW_AT_type372 # DW_AT_external373 .byte 3 # Abbrev [3] 0x59:0xb DW_TAG_formal_parameter374 .byte 2 # DW_AT_location375 .byte 145376 .byte 120377 .byte 7 # DW_AT_name378 .byte 0 # DW_AT_decl_file379 .byte 9 # DW_AT_decl_line380 .long 123 # DW_AT_type381 .byte 3 # Abbrev [3] 0x64:0xb DW_TAG_formal_parameter382 .byte 2 # DW_AT_location383 .byte 145384 .byte 112385 .byte 9 # DW_AT_name386 .byte 0 # DW_AT_decl_file387 .byte 9 # DW_AT_decl_line388 .long 127 # DW_AT_type389 .byte 4 # Abbrev [4] 0x6f:0xb DW_TAG_variable390 .byte 2 # DW_AT_location391 .byte 145392 .byte 108393 .byte 8 # DW_AT_name394 .byte 0 # DW_AT_decl_file395 .byte 10 # DW_AT_decl_line396 .long 123 # DW_AT_type397 .byte 0 # End Of Children Mark398 .byte 6 # Abbrev [6] 0x7b:0x4 DW_TAG_base_type399 .byte 5 # DW_AT_name400 .byte 5 # DW_AT_encoding401 .byte 4 # DW_AT_byte_size402 .byte 7 # Abbrev [7] 0x7f:0x5 DW_TAG_pointer_type403 .long 132 # DW_AT_type404 .byte 7 # Abbrev [7] 0x84:0x5 DW_TAG_pointer_type405 .long 137 # DW_AT_type406 .byte 6 # Abbrev [6] 0x89:0x4 DW_TAG_base_type407 .byte 10 # DW_AT_name408 .byte 6 # DW_AT_encoding409 .byte 1 # DW_AT_byte_size410 .byte 0 # End Of Children Mark411.Ldebug_info_end0:412 .section .debug_rnglists,"",@progbits413 .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length414.Ldebug_list_header_start0:415 .short 5 # Version416 .byte 8 # Address size417 .byte 0 # Segment selector size418 .long 3 # Offset entry count419.Lrnglists_table_base0:420 .long .Ldebug_ranges0-.Lrnglists_table_base0421 .long .Ldebug_ranges1-.Lrnglists_table_base0422 .long .Ldebug_ranges2-.Lrnglists_table_base0423.Ldebug_ranges0:424 .byte 3 # DW_RLE_startx_length425 .byte 0 # start index426 .uleb128 .LBB_END0_1-_Z6helperi.__part.1 # length427 .byte 3 # DW_RLE_startx_length428 .byte 1 # start index429 .uleb128 .LBB_END0_2-_Z6helperi.__part.2 # length430 .byte 3 # DW_RLE_startx_length431 .byte 2 # start index432 .uleb128 .LBB_END0_3-_Z6helperi.__part.3 # length433 .byte 3 # DW_RLE_startx_length434 .byte 3 # start index435 .uleb128 .Lfunc_end0-.Lfunc_begin0 # length436 .byte 0 # DW_RLE_end_of_list437.Ldebug_ranges1:438 .byte 3 # DW_RLE_startx_length439 .byte 4 # start index440 .uleb128 .LBB_END1_1-main.__part.1 # length441 .byte 3 # DW_RLE_startx_length442 .byte 5 # start index443 .uleb128 .LBB_END1_2-main.__part.2 # length444 .byte 3 # DW_RLE_startx_length445 .byte 6 # start index446 .uleb128 .LBB_END1_3-main.__part.3 # length447 .byte 3 # DW_RLE_startx_length448 .byte 7 # start index449 .uleb128 .Lfunc_end1-.Lfunc_begin1 # length450 .byte 0 # DW_RLE_end_of_list451.Ldebug_ranges2:452 .byte 3 # DW_RLE_startx_length453 .byte 0 # start index454 .uleb128 .LBB_END0_1-_Z6helperi.__part.1 # length455 .byte 3 # DW_RLE_startx_length456 .byte 1 # start index457 .uleb128 .LBB_END0_2-_Z6helperi.__part.2 # length458 .byte 3 # DW_RLE_startx_length459 .byte 2 # start index460 .uleb128 .LBB_END0_3-_Z6helperi.__part.3 # length461 .byte 3 # DW_RLE_startx_length462 .byte 3 # start index463 .uleb128 .Lfunc_end0-.Lfunc_begin0 # length464 .byte 3 # DW_RLE_startx_length465 .byte 4 # start index466 .uleb128 .LBB_END1_1-main.__part.1 # length467 .byte 3 # DW_RLE_startx_length468 .byte 5 # start index469 .uleb128 .LBB_END1_2-main.__part.2 # length470 .byte 3 # DW_RLE_startx_length471 .byte 6 # start index472 .uleb128 .LBB_END1_3-main.__part.3 # length473 .byte 3 # DW_RLE_startx_length474 .byte 7 # start index475 .uleb128 .Lfunc_end1-.Lfunc_begin1 # length476 .byte 0 # DW_RLE_end_of_list477.Ldebug_list_header_end0:478 .section .debug_str_offsets,"",@progbits479 .long 48 # Length of String Offsets Set480 .short 5481 .short 0482.Lstr_offsets_base0:483 .section .debug_str,"MS",@progbits,1484.Linfo_string0:485 .asciz "clang version 19.0.0git (git@github.com:ayermolo/llvm-project.git a1d8664d409cac2a923176a8e9a731385bde279e)" # string offset=0486.Linfo_string1:487 .asciz "main.cpp" # string offset=108488.Linfo_string2:489 .asciz "/repro2" # string offset=117490.Linfo_string3:491 .asciz "_Z6helperi" # string offset=162492.Linfo_string4:493 .asciz "helper" # string offset=173494.Linfo_string5:495 .asciz "int" # string offset=180496.Linfo_string6:497 .asciz "main" # string offset=184498.Linfo_string7:499 .asciz "argc" # string offset=189500.Linfo_string8:501 .asciz "x" # string offset=194502.Linfo_string9:503 .asciz "argv" # string offset=196504.Linfo_string10:505 .asciz "char" # string offset=201506 .section .debug_str_offsets,"",@progbits507 .long .Linfo_string0508 .long .Linfo_string1509 .long .Linfo_string2510 .long .Linfo_string3511 .long .Linfo_string4512 .long .Linfo_string5513 .long .Linfo_string6514 .long .Linfo_string7515 .long .Linfo_string8516 .long .Linfo_string9517 .long .Linfo_string10518 .section .debug_addr,"",@progbits519 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution520.Ldebug_addr_start0:521 .short 5 # DWARF version number522 .byte 8 # Address size523 .byte 0 # Segment selector size524.Laddr_table_base0:525 .quad _Z6helperi.__part.1526 .quad _Z6helperi.__part.2527 .quad _Z6helperi.__part.3528 .quad .Lfunc_begin0529 .quad main.__part.1530 .quad main.__part.2531 .quad main.__part.3532 .quad .Lfunc_begin1533.Ldebug_addr_end0:534 .ident "clang version 19.0.0git (git@github.com:ayermolo/llvm-project.git a1d8664d409cac2a923176a8e9a731385bde279e)"535 .section ".note.GNU-stack","",@progbits536 .addrsig537 .section .debug_line,"",@progbits538.Lline_table_start0:539