diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp --- a/bolt/lib/Rewrite/DWARFRewriter.cpp +++ b/bolt/lib/Rewrite/DWARFRewriter.cpp @@ -839,7 +839,7 @@ case dwarf::DW_TAG_inlined_subroutine: case dwarf::DW_TAG_try_block: case dwarf::DW_TAG_catch_block: { - uint64_t RangesSectionOffset = RangesSectionWriter.getEmptyRangesOffset(); + uint64_t RangesSectionOffset = 0; Expected RangesOrError = getDIEAddressRanges(*Die, Unit); const BinaryFunction *Function = @@ -865,6 +865,11 @@ } } else if (!RangesOrError) { consumeError(RangesOrError.takeError()); + } else if (OutputRanges.empty()) { + if (RangesOrError.get().front().LowPC) + errs() << "BOLT-WARNING: [internal-dwarf-error]: Could not map " + "DW_AT_low_pc to address in output binary\n"; + OutputRanges.push_back({0, RangesOrError.get().front().HighPC}); } DIEValue LowPCVal = Die->findAttribute(dwarf::DW_AT_low_pc); DIEValue HighPCVal = Die->findAttribute(dwarf::DW_AT_high_pc); diff --git a/bolt/test/X86/Inputs/dwarf4-df-inlined-subroutine-lowpc-0-main.s b/bolt/test/X86/Inputs/dwarf4-df-inlined-subroutine-lowpc-0-main.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarf4-df-inlined-subroutine-lowpc-0-main.s @@ -0,0 +1,591 @@ +# __attribute__((always_inline)) +# int doStuff(int val) { +# if (val) +# ++val; +# return val; +# } +# __attribute__((always_inline)) +# int doStuffSame(int val) { +# if (val) +# ++val; +# return val; +# } +# +# +# int main(int argc, const char** argv) { +# return doStuff(argc) + doStuffSame(argc); +# } +# Assembly manually modified to set DW_AT_low_pc to 0 for DW_TAG_inlined_subroutine(s) + .text + .file "main.cpp" + .section .text._Z7doStuffi,"ax",@progbits + .globl _Z7doStuffi # -- Begin function _Z7doStuffi + .p2align 4, 0x90 + .type _Z7doStuffi,@function +_Z7doStuffi: # @_Z7doStuffi +.Lfunc_begin0: + .file 1 "." "main.cpp" + .loc 1 2 0 # main.cpp:2:0 + .cfi_startproc +# %bb.0: # %entry + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq %rsp, %rbp + .cfi_def_cfa_register %rbp + movl %edi, -4(%rbp) +.Ltmp0: + .loc 1 3 7 prologue_end # main.cpp:3:7 + cmpl $0, -4(%rbp) +.Ltmp1: + .loc 1 3 7 is_stmt 0 # main.cpp:3:7 + je .LBB0_2 +# %bb.1: # %if.then +.Ltmp2: + .loc 1 4 5 is_stmt 1 # main.cpp:4:5 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) +.Ltmp3: +.LBB0_2: # %if.end + .loc 1 5 10 # main.cpp:5:10 + movl -4(%rbp), %eax + .loc 1 5 3 epilogue_begin is_stmt 0 # main.cpp:5:3 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp4: +.Lfunc_end0: + .size _Z7doStuffi, .Lfunc_end0-_Z7doStuffi + .cfi_endproc + # -- End function + .section .text._Z11doStuffSamei,"ax",@progbits + .globl _Z11doStuffSamei # -- Begin function _Z11doStuffSamei + .p2align 4, 0x90 + .type _Z11doStuffSamei,@function +_Z11doStuffSamei: # @_Z11doStuffSamei +.Lfunc_begin1: + .loc 1 8 0 is_stmt 1 # main.cpp:8:0 + .cfi_startproc +# %bb.0: # %entry + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq %rsp, %rbp + .cfi_def_cfa_register %rbp + movl %edi, -4(%rbp) +.Ltmp5: + .loc 1 9 11 prologue_end # main.cpp:9:11 + cmpl $0, -4(%rbp) +.Ltmp6: + .loc 1 9 11 is_stmt 0 # main.cpp:9:11 + je .LBB1_2 +# %bb.1: # %if.then +.Ltmp7: + .loc 1 10 13 is_stmt 1 # main.cpp:10:13 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) +.Ltmp8: +.LBB1_2: # %if.end + .loc 1 11 16 # main.cpp:11:16 + movl -4(%rbp), %eax + .loc 1 11 9 epilogue_begin is_stmt 0 # main.cpp:11:9 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp9: +.Lfunc_end1: + .size _Z11doStuffSamei, .Lfunc_end1-_Z11doStuffSamei + .cfi_endproc + # -- End function + .section .text.main,"ax",@progbits + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin2: + .loc 1 15 0 is_stmt 1 # main.cpp:15:0 + .cfi_startproc +# %bb.0: # %entry + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq %rsp, %rbp + .cfi_def_cfa_register %rbp + movl $0, -12(%rbp) + movl %edi, -16(%rbp) + movq %rsi, -24(%rbp) +.Ltmp10: + .loc 1 16 21 prologue_end # main.cpp:16:21 + movl -16(%rbp), %eax + movl %eax, -8(%rbp) +.Ltmp11: + .loc 1 3 7 # main.cpp:3:7 + cmpl $0, -8(%rbp) +.Ltmp12: + .loc 1 3 7 is_stmt 0 # main.cpp:3:7 + je .LBB2_2 +# %bb.1: # %if.then.i +.Ltmp13: + .loc 1 4 5 is_stmt 1 # main.cpp:4:5 + movl -8(%rbp), %eax + addl $1, %eax + movl %eax, -8(%rbp) +.Ltmp14: +.LBB2_2: # %_Z7doStuffi.exit + .loc 1 5 10 # main.cpp:5:10 + movl -8(%rbp), %eax + movl %eax, -28(%rbp) # 4-byte Spill +.Ltmp15: + .loc 1 16 41 # main.cpp:16:41 + movl -16(%rbp), %eax + movl %eax, -4(%rbp) +.Ltmp16: + .loc 1 9 11 # main.cpp:9:11 + cmpl $0, -4(%rbp) +.Ltmp17: + .loc 1 9 11 is_stmt 0 # main.cpp:9:11 + je .LBB2_4 +# %bb.3: # %if.then.i4 +.Ltmp18: + .loc 1 10 13 is_stmt 1 # main.cpp:10:13 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) +.Ltmp19: +.LBB2_4: # %_Z11doStuffSamei.exit + .loc 1 0 13 is_stmt 0 # main.cpp:0:13 + movl -28(%rbp), %eax # 4-byte Reload + .loc 1 16 27 is_stmt 1 # main.cpp:16:27 + addl -4(%rbp), %eax + .loc 1 16 5 epilogue_begin is_stmt 0 # main.cpp:16:5 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp20: +.Lfunc_end2: + .size main, .Lfunc_end2-main + .cfi_endproc + # -- End function + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .ascii "\264B" # DW_AT_GNU_pubnames + .byte 25 # DW_FORM_flag_present + .ascii "\260B" # DW_AT_GNU_dwo_name + .byte 14 # DW_FORM_strp + .ascii "\261B" # DW_AT_GNU_dwo_id + .byte 7 # DW_FORM_data8 + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 85 # DW_AT_ranges + .byte 23 # DW_FORM_sec_offset + .ascii "\263B" # DW_AT_GNU_addr_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x25 DW_TAG_compile_unit + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Lskel_string0 # DW_AT_comp_dir + # DW_AT_GNU_pubnames + .long .Lskel_string1 # DW_AT_GNU_dwo_name + .quad 1388808602086005033 # DW_AT_GNU_dwo_id + .quad 0 # DW_AT_low_pc + .long .Ldebug_ranges0 # DW_AT_ranges + .long .Laddr_table_base0 # DW_AT_GNU_addr_base +.Ldebug_info_end0: + .section .debug_ranges,"",@progbits +.Ldebug_ranges0: + .quad .Lfunc_begin0 + .quad .Lfunc_end0 + .quad .Lfunc_begin1 + .quad .Lfunc_end1 + .quad .Lfunc_begin2 + .quad .Lfunc_end2 + .quad 0 # manually modified + .quad 0 # manually modified + .section .debug_str,"MS",@progbits,1 +.Lskel_string0: + .asciz "." # string offset=0 +.Lskel_string1: + .asciz "main.dwo" # string offset=38 + .section .debug_str.dwo,"eMS",@progbits,1 +.Linfo_string0: + .asciz "_Z7doStuffi" # string offset=0 +.Linfo_string1: + .asciz "doStuff" # string offset=12 +.Linfo_string2: + .asciz "int" # string offset=20 +.Linfo_string3: + .asciz "val" # string offset=24 +.Linfo_string4: + .asciz "_Z11doStuffSamei" # string offset=28 +.Linfo_string5: + .asciz "doStuffSame" # string offset=45 +.Linfo_string6: + .asciz "main" # string offset=57 +.Linfo_string7: + .asciz "argc" # string offset=62 +.Linfo_string8: + .asciz "argv" # string offset=67 +.Linfo_string9: + .asciz "char" # string offset=72 +.Linfo_string10: + .asciz "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 63dbe7e808d07bdf25bad85301980bc323b0cd64)" # string offset=77 +.Linfo_string11: + .asciz "main.cpp" # string offset=178 +.Linfo_string12: + .asciz "main.dwo" # string offset=187 + .section .debug_str_offsets.dwo,"e",@progbits + .long 0 + .long 12 + .long 20 + .long 24 + .long 28 + .long 45 + .long 57 + .long 62 + .long 67 + .long 72 + .long 77 + .long 178 + .long 187 + .section .debug_info.dwo,"e",@progbits + .long .Ldebug_info_dwo_end0-.Ldebug_info_dwo_start0 # Length of Unit +.Ldebug_info_dwo_start0: + .short 4 # DWARF version number + .long 0 # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0xc8 DW_TAG_compile_unit + .byte 10 # DW_AT_producer + .short 33 # DW_AT_language + .byte 11 # DW_AT_name + .byte 12 # DW_AT_GNU_dwo_name + .quad 1388808602086005033 # DW_AT_GNU_dwo_id + .byte 2 # Abbrev [2] 0x19:0x15 DW_TAG_subprogram + .byte 0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .long 67 # DW_AT_abstract_origin + .byte 3 # Abbrev [3] 0x25:0x8 DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .long 77 # DW_AT_abstract_origin + .byte 0 # End Of Children Mark + .byte 2 # Abbrev [2] 0x2e:0x15 DW_TAG_subprogram + .byte 1 # DW_AT_low_pc + .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .long 90 # DW_AT_abstract_origin + .byte 3 # Abbrev [3] 0x3a:0x8 DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .long 100 # DW_AT_abstract_origin + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x43:0x13 DW_TAG_subprogram + .byte 0 # DW_AT_linkage_name + .byte 1 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .long 86 # DW_AT_type + # DW_AT_external + .byte 1 # DW_AT_inline + .byte 5 # Abbrev [5] 0x4d:0x8 DW_TAG_formal_parameter + .byte 3 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .long 86 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 6 # Abbrev [6] 0x56:0x4 DW_TAG_base_type + .byte 2 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 4 # Abbrev [4] 0x5a:0x13 DW_TAG_subprogram + .byte 4 # DW_AT_linkage_name + .byte 5 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 8 # DW_AT_decl_line + .long 86 # DW_AT_type + # DW_AT_external + .byte 1 # DW_AT_inline + .byte 5 # Abbrev [5] 0x64:0x8 DW_TAG_formal_parameter + .byte 3 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 8 # DW_AT_decl_line + .long 86 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 7 # Abbrev [7] 0x6d:0x52 DW_TAG_subprogram + .byte 2 # DW_AT_low_pc + .long .Lfunc_end2-.Lfunc_begin2 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 6 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 15 # DW_AT_decl_line + .long 86 # DW_AT_type + # DW_AT_external + .byte 8 # Abbrev [8] 0x7c:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 112 + .byte 7 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 15 # DW_AT_decl_line + .long 86 # DW_AT_type + .byte 8 # Abbrev [8] 0x87:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 104 + .byte 8 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 15 # DW_AT_decl_line + .long 191 # DW_AT_type + .byte 9 # Abbrev [9] 0x92:0x16 DW_TAG_inlined_subroutine + .long 67 # DW_AT_abstract_origin + .byte 3 # DW_AT_low_pc + .long .Ltmp15-.Ltmp11 # DW_AT_high_pc + .byte 1 # DW_AT_call_file + .byte 16 # DW_AT_call_line + .byte 13 # DW_AT_call_column + .byte 3 # Abbrev [3] 0x9f:0x8 DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 120 + .long 77 # DW_AT_abstract_origin + .byte 0 # End Of Children Mark + .byte 9 # Abbrev [9] 0xa8:0x16 DW_TAG_inlined_subroutine + .long 90 # DW_AT_abstract_origin + .byte 4 # DW_AT_low_pc + .long .Ltmp19-.Ltmp16 # DW_AT_high_pc + .byte 1 # DW_AT_call_file + .byte 16 # DW_AT_call_line + .byte 29 # DW_AT_call_column + .byte 3 # Abbrev [3] 0xb5:0x8 DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .long 100 # DW_AT_abstract_origin + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark + .byte 10 # Abbrev [10] 0xbf:0x5 DW_TAG_pointer_type + .long 196 # DW_AT_type + .byte 10 # Abbrev [10] 0xc4:0x5 DW_TAG_pointer_type + .long 201 # DW_AT_type + .byte 11 # Abbrev [11] 0xc9:0x5 DW_TAG_const_type + .long 206 # DW_AT_type + .byte 6 # Abbrev [6] 0xce:0x4 DW_TAG_base_type + .byte 9 # DW_AT_name + .byte 6 # DW_AT_encoding + .byte 1 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Ldebug_info_dwo_end0: + .section .debug_abbrev.dwo,"e",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .ascii "\202>" # DW_FORM_GNU_str_index + .ascii "\260B" # DW_AT_GNU_dwo_name + .ascii "\202>" # DW_FORM_GNU_str_index + .ascii "\261B" # DW_AT_GNU_dwo_id + .byte 7 # DW_FORM_data8 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .ascii "\201>" # DW_FORM_GNU_addr_index + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .byte 49 # DW_AT_abstract_origin + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 5 # DW_TAG_formal_parameter + .byte 0 # DW_CHILDREN_no + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 49 # DW_AT_abstract_origin + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 4 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 110 # DW_AT_linkage_name + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 3 # DW_AT_name + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 32 # DW_AT_inline + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 5 # DW_TAG_formal_parameter + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 6 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 7 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .ascii "\201>" # DW_FORM_GNU_addr_index + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .byte 3 # DW_AT_name + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 8 # Abbreviation Code + .byte 5 # DW_TAG_formal_parameter + .byte 0 # DW_CHILDREN_no + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 3 # DW_AT_name + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 9 # Abbreviation Code + .byte 29 # DW_TAG_inlined_subroutine + .byte 1 # DW_CHILDREN_yes + .byte 49 # DW_AT_abstract_origin + .byte 19 # DW_FORM_ref4 + .byte 17 # DW_AT_low_pc + .ascii "\201>" # DW_FORM_GNU_addr_index + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 88 # DW_AT_call_file + .byte 11 # DW_FORM_data1 + .byte 89 # DW_AT_call_line + .byte 11 # DW_FORM_data1 + .byte 87 # DW_AT_call_column + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 10 # Abbreviation Code + .byte 15 # DW_TAG_pointer_type + .byte 0 # DW_CHILDREN_no + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 11 # Abbreviation Code + .byte 38 # DW_TAG_const_type + .byte 0 # DW_CHILDREN_no + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_addr,"",@progbits +.Laddr_table_base0: + .quad .Lfunc_begin0 + .quad .Lfunc_begin1 + .quad .Lfunc_begin2 + .quad 0 + .quad 0 + .section .debug_gnu_pubnames,"",@progbits + .long .LpubNames_end0-.LpubNames_start0 # Length of Public Names Info +.LpubNames_start0: + .short 2 # DWARF Version + .long .Lcu_begin0 # Offset of Compilation Unit Info + .long 48 # Compilation Unit Length + .long 67 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "doStuff" # External Name + .long 90 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "doStuffSame" # External Name + .long 109 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "main" # External Name + .long 0 # End Mark +.LpubNames_end0: + .section .debug_gnu_pubtypes,"",@progbits + .long .LpubTypes_end0-.LpubTypes_start0 # Length of Public Types Info +.LpubTypes_start0: + .short 2 # DWARF Version + .long .Lcu_begin0 # Offset of Compilation Unit Info + .long 48 # Compilation Unit Length + .long 86 # DIE offset + .byte 144 # Attributes: TYPE, STATIC + .asciz "int" # External Name + .long 206 # DIE offset + .byte 144 # Attributes: TYPE, STATIC + .asciz "char" # External Name + .long 0 # End Mark +.LpubTypes_end0: + .ident "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 63dbe7e808d07bdf25bad85301980bc323b0cd64)" + .section ".note.GNU-stack","",@progbits + .addrsig + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/Inputs/dwarf5-df-inlined-subroutine-range-0-main.s b/bolt/test/X86/Inputs/dwarf5-df-inlined-subroutine-range-0-main.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarf5-df-inlined-subroutine-range-0-main.s @@ -0,0 +1,645 @@ +# __attribute__((always_inline)) +# int doStuff(int val) { +# if (val) +# ++val; +# return val; +# } +# __attribute__((always_inline)) +# int doStuffSame(int val) { +# if (val) +# ++val; +# return val; +# } +# +# +# int main(int argc, const char** argv) { +# return doStuff(argc) + doStuffSame(argc); +# } +# Manually modified to set range to 0. + + .text + .file "main.cpp" + .section .text._Z7doStuffi,"ax",@progbits + .globl _Z7doStuffi # -- Begin function _Z7doStuffi + .p2align 4, 0x90 + .type _Z7doStuffi,@function +_Z7doStuffi: # @_Z7doStuffi +.Lfunc_begin0: + .file 0 "." "main.cpp" md5 0x5391f0751c21da59df94bf9d3771518e + .loc 0 2 0 # main.cpp:2:0 + .cfi_startproc +# %bb.0: # %entry + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq %rsp, %rbp + .cfi_def_cfa_register %rbp + movl %edi, -4(%rbp) +.Ltmp0: + .loc 0 3 7 prologue_end # main.cpp:3:7 + cmpl $0, -4(%rbp) +.Ltmp1: + .loc 0 3 7 is_stmt 0 # main.cpp:3:7 + je .LBB0_2 +# %bb.1: # %if.then +.Ltmp2: + .loc 0 4 5 is_stmt 1 # main.cpp:4:5 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) +.Ltmp3: +.LBB0_2: # %if.end + .loc 0 5 10 # main.cpp:5:10 + movl -4(%rbp), %eax + .loc 0 5 3 epilogue_begin is_stmt 0 # main.cpp:5:3 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp4: +.Lfunc_end0: + .size _Z7doStuffi, .Lfunc_end0-_Z7doStuffi + .cfi_endproc + # -- End function + .section .text._Z11doStuffSamei,"ax",@progbits + .globl _Z11doStuffSamei # -- Begin function _Z11doStuffSamei + .p2align 4, 0x90 + .type _Z11doStuffSamei,@function +_Z11doStuffSamei: # @_Z11doStuffSamei +.Lfunc_begin1: + .loc 0 8 0 is_stmt 1 # main.cpp:8:0 + .cfi_startproc +# %bb.0: # %entry + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq %rsp, %rbp + .cfi_def_cfa_register %rbp + movl %edi, -4(%rbp) +.Ltmp5: + .loc 0 9 11 prologue_end # main.cpp:9:11 + cmpl $0, -4(%rbp) +.Ltmp6: + .loc 0 9 11 is_stmt 0 # main.cpp:9:11 + je .LBB1_2 +# %bb.1: # %if.then +.Ltmp7: + .loc 0 10 13 is_stmt 1 # main.cpp:10:13 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) +.Ltmp8: +.LBB1_2: # %if.end + .loc 0 11 16 # main.cpp:11:16 + movl -4(%rbp), %eax + .loc 0 11 9 epilogue_begin is_stmt 0 # main.cpp:11:9 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp9: +.Lfunc_end1: + .size _Z11doStuffSamei, .Lfunc_end1-_Z11doStuffSamei + .cfi_endproc + # -- End function + .section .text.main,"ax",@progbits + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin2: + .loc 0 15 0 is_stmt 1 # main.cpp:15:0 + .cfi_startproc +# %bb.0: # %entry + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq %rsp, %rbp + .cfi_def_cfa_register %rbp + movl $0, -12(%rbp) + movl %edi, -16(%rbp) + movq %rsi, -24(%rbp) +.Ltmp10: + .loc 0 16 21 prologue_end # main.cpp:16:21 + movl -16(%rbp), %eax + movl %eax, -8(%rbp) +.Ltmp11: + .loc 0 3 7 # main.cpp:3:7 + cmpl $0, -8(%rbp) +.Ltmp12: + .loc 0 3 7 is_stmt 0 # main.cpp:3:7 + je .LBB2_2 +# %bb.1: # %if.then.i +.Ltmp13: + .loc 0 4 5 is_stmt 1 # main.cpp:4:5 + movl -8(%rbp), %eax + addl $1, %eax + movl %eax, -8(%rbp) +.Ltmp14: +.LBB2_2: # %_Z7doStuffi.exit + .loc 0 5 10 # main.cpp:5:10 + movl -8(%rbp), %eax + movl %eax, -28(%rbp) # 4-byte Spill +.Ltmp15: + .loc 0 16 41 # main.cpp:16:41 + movl -16(%rbp), %eax + movl %eax, -4(%rbp) +.Ltmp16: + .loc 0 9 11 # main.cpp:9:11 + cmpl $0, -4(%rbp) +.Ltmp17: + .loc 0 9 11 is_stmt 0 # main.cpp:9:11 + je .LBB2_4 +# %bb.3: # %if.then.i4 +.Ltmp18: + .loc 0 10 13 is_stmt 1 # main.cpp:10:13 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) +.Ltmp19: +.LBB2_4: # %_Z11doStuffSamei.exit + .loc 0 0 13 is_stmt 0 # main.cpp:0:13 + movl -28(%rbp), %eax # 4-byte Reload + .loc 0 16 27 is_stmt 1 # main.cpp:16:27 + addl -4(%rbp), %eax + .loc 0 16 5 epilogue_begin is_stmt 0 # main.cpp:16:5 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp20: +.Lfunc_end2: + .size main, .Lfunc_end2-main + .cfi_endproc + # -- End function + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 74 # DW_TAG_skeleton_unit + .byte 0 # DW_CHILDREN_no + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 114 # DW_AT_str_offsets_base + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 37 # DW_FORM_strx1 + .ascii "\264B" # DW_AT_GNU_pubnames + .byte 25 # DW_FORM_flag_present + .byte 118 # DW_AT_dwo_name + .byte 37 # DW_FORM_strx1 + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 85 # DW_AT_ranges + .byte 35 # DW_FORM_rnglistx + .byte 115 # DW_AT_addr_base + .byte 23 # DW_FORM_sec_offset + .byte 116 # DW_AT_rnglists_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 5 # DWARF version number + .byte 4 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .quad 1388808602086005033 + .byte 1 # Abbrev [1] 0x14:0x1c DW_TAG_skeleton_unit + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Lstr_offsets_base0 # DW_AT_str_offsets_base + .byte 0 # DW_AT_comp_dir + # DW_AT_GNU_pubnames + .byte 1 # DW_AT_dwo_name + .quad 0 # DW_AT_low_pc + .byte 0 # DW_AT_ranges + .long .Laddr_table_base0 # DW_AT_addr_base + .long .Lrnglists_table_base0 # DW_AT_rnglists_base +.Ldebug_info_end0: + .section .debug_rnglists,"",@progbits + .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length +.Ldebug_list_header_start0: + .short 5 # Version + .byte 8 # Address size + .byte 0 # Segment selector size + .long 1 # Offset entry count +.Lrnglists_table_base0: + .long .Ldebug_ranges2-.Lrnglists_table_base0 +.Ldebug_ranges2: + .byte 3 # DW_RLE_startx_length + .byte 0 # start index + .uleb128 .Lfunc_end0-.Lfunc_begin0 # length + .byte 3 # DW_RLE_startx_length + .byte 1 # start index + .uleb128 .Lfunc_end1-.Lfunc_begin1 # length + .byte 3 # DW_RLE_startx_length + .byte 2 # start index + .uleb128 .Lfunc_end2-.Lfunc_begin2 # length + .byte 0 # DW_RLE_end_of_list +.Ldebug_list_header_end0: + .section .debug_str_offsets,"",@progbits + .long 12 # Length of String Offsets Set + .short 5 + .short 0 +.Lstr_offsets_base0: + .section .debug_str,"MS",@progbits,1 +.Lskel_string0: + .asciz "." # string offset=0 +.Lskel_string1: + .asciz "main.dwo" # string offset=38 + .section .debug_str_offsets,"",@progbits + .long .Lskel_string0 + .long .Lskel_string1 + .section .debug_str_offsets.dwo,"e",@progbits + .long 56 # Length of String Offsets Set + .short 5 + .short 0 + .section .debug_str.dwo,"eMS",@progbits,1 +.Linfo_string0: + .asciz "_Z7doStuffi" # string offset=0 +.Linfo_string1: + .asciz "doStuff" # string offset=12 +.Linfo_string2: + .asciz "int" # string offset=20 +.Linfo_string3: + .asciz "val" # string offset=24 +.Linfo_string4: + .asciz "_Z11doStuffSamei" # string offset=28 +.Linfo_string5: + .asciz "doStuffSame" # string offset=45 +.Linfo_string6: + .asciz "main" # string offset=57 +.Linfo_string7: + .asciz "argc" # string offset=62 +.Linfo_string8: + .asciz "argv" # string offset=67 +.Linfo_string9: + .asciz "char" # string offset=72 +.Linfo_string10: + .asciz "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 63dbe7e808d07bdf25bad85301980bc323b0cd64)" # string offset=77 +.Linfo_string11: + .asciz "main.cpp" # string offset=178 +.Linfo_string12: + .asciz "main.dwo" # string offset=187 + .section .debug_str_offsets.dwo,"e",@progbits + .long 0 + .long 12 + .long 20 + .long 24 + .long 28 + .long 45 + .long 57 + .long 62 + .long 67 + .long 72 + .long 77 + .long 178 + .long 187 + .section .debug_info.dwo,"e",@progbits + .long .Ldebug_info_dwo_end0-.Ldebug_info_dwo_start0 # Length of Unit +.Ldebug_info_dwo_start0: + .short 5 # DWARF version number + .byte 5 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long 0 # Offset Into Abbrev. Section + .quad 1388808602086005033 + .byte 1 # Abbrev [1] 0x14:0xb6 DW_TAG_compile_unit + .byte 10 # DW_AT_producer + .short 33 # DW_AT_language + .byte 11 # DW_AT_name + .byte 12 # DW_AT_dwo_name + .byte 2 # Abbrev [2] 0x1a:0x15 DW_TAG_subprogram + .byte 0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .long 68 # DW_AT_abstract_origin + .byte 3 # Abbrev [3] 0x26:0x8 DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .long 77 # DW_AT_abstract_origin + .byte 0 # End Of Children Mark + .byte 2 # Abbrev [2] 0x2f:0x15 DW_TAG_subprogram + .byte 1 # DW_AT_low_pc + .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .long 90 # DW_AT_abstract_origin + .byte 3 # Abbrev [3] 0x3b:0x8 DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .long 99 # DW_AT_abstract_origin + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x44:0x12 DW_TAG_subprogram + .byte 0 # DW_AT_linkage_name + .byte 1 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .long 86 # DW_AT_type + # DW_AT_external + # DW_AT_inline + .byte 5 # Abbrev [5] 0x4d:0x8 DW_TAG_formal_parameter + .byte 3 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .long 86 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 6 # Abbrev [6] 0x56:0x4 DW_TAG_base_type + .byte 2 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 4 # Abbrev [4] 0x5a:0x12 DW_TAG_subprogram + .byte 4 # DW_AT_linkage_name + .byte 5 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 8 # DW_AT_decl_line + .long 86 # DW_AT_type + # DW_AT_external + # DW_AT_inline + .byte 5 # Abbrev [5] 0x63:0x8 DW_TAG_formal_parameter + .byte 3 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 8 # DW_AT_decl_line + .long 86 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 7 # Abbrev [7] 0x6c:0x4a DW_TAG_subprogram + .byte 2 # DW_AT_low_pc + .long .Lfunc_end2-.Lfunc_begin2 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 6 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 15 # DW_AT_decl_line + .long 86 # DW_AT_type + # DW_AT_external + .byte 8 # Abbrev [8] 0x7b:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 112 + .byte 7 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 15 # DW_AT_decl_line + .long 86 # DW_AT_type + .byte 8 # Abbrev [8] 0x86:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 104 + .byte 8 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 15 # DW_AT_decl_line + .long 182 # DW_AT_type + .byte 9 # Abbrev [9] 0x91:0x12 DW_TAG_inlined_subroutine + .long 68 # DW_AT_abstract_origin + .byte 0 # DW_AT_ranges + .byte 0 # DW_AT_call_file + .byte 16 # DW_AT_call_line + .byte 13 # DW_AT_call_column + .byte 3 # Abbrev [3] 0x9a:0x8 DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 120 + .long 77 # DW_AT_abstract_origin + .byte 0 # End Of Children Mark + .byte 9 # Abbrev [9] 0xa3:0x12 DW_TAG_inlined_subroutine + .long 90 # DW_AT_abstract_origin + .byte 1 # DW_AT_ranges + .byte 0 # DW_AT_call_file + .byte 16 # DW_AT_call_line + .byte 29 # DW_AT_call_column + .byte 3 # Abbrev [3] 0xac:0x8 DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .long 99 # DW_AT_abstract_origin + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark + .byte 10 # Abbrev [10] 0xb6:0x5 DW_TAG_pointer_type + .long 187 # DW_AT_type + .byte 10 # Abbrev [10] 0xbb:0x5 DW_TAG_pointer_type + .long 192 # DW_AT_type + .byte 11 # Abbrev [11] 0xc0:0x5 DW_TAG_const_type + .long 197 # DW_AT_type + .byte 6 # Abbrev [6] 0xc5:0x4 DW_TAG_base_type + .byte 9 # DW_AT_name + .byte 6 # DW_AT_encoding + .byte 1 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Ldebug_info_dwo_end0: + .section .debug_abbrev.dwo,"e",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 37 # DW_FORM_strx1 + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 118 # DW_AT_dwo_name + .byte 37 # DW_FORM_strx1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 27 # DW_FORM_addrx + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .byte 49 # DW_AT_abstract_origin + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 5 # DW_TAG_formal_parameter + .byte 0 # DW_CHILDREN_no + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 49 # DW_AT_abstract_origin + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 4 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 110 # DW_AT_linkage_name + .byte 37 # DW_FORM_strx1 + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 32 # DW_AT_inline + .byte 33 # DW_FORM_implicit_const + .byte 1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 5 # DW_TAG_formal_parameter + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 6 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 7 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 27 # DW_FORM_addrx + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 8 # Abbreviation Code + .byte 5 # DW_TAG_formal_parameter + .byte 0 # DW_CHILDREN_no + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 9 # Abbreviation Code + .byte 29 # DW_TAG_inlined_subroutine + .byte 1 # DW_CHILDREN_yes + .byte 49 # DW_AT_abstract_origin + .byte 19 # DW_FORM_ref4 + .byte 85 # DW_AT_ranges + .byte 35 # DW_FORM_rnglistx + .byte 88 # DW_AT_call_file + .byte 11 # DW_FORM_data1 + .byte 89 # DW_AT_call_line + .byte 11 # DW_FORM_data1 + .byte 87 # DW_AT_call_column + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 10 # Abbreviation Code + .byte 15 # DW_TAG_pointer_type + .byte 0 # DW_CHILDREN_no + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 11 # Abbreviation Code + .byte 38 # DW_TAG_const_type + .byte 0 # DW_CHILDREN_no + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_rnglists.dwo,"e",@progbits + .long .Ldebug_list_header_end1-.Ldebug_list_header_start1 # Length +.Ldebug_list_header_start1: + .short 5 # Version + .byte 8 # Address size + .byte 0 # Segment selector size + .long 2 # Offset entry count +.Lrnglists_dwo_table_base0: + .long .Ldebug_ranges0-.Lrnglists_dwo_table_base0 + .long .Ldebug_ranges1-.Lrnglists_dwo_table_base0 +.Ldebug_ranges0: + .byte 1 # DW_RLE_base_addressx + .byte 2 # base address index + .byte 4 # DW_RLE_offset_pair + .uleb128 0 # starting offset Manually modified + .uleb128 .Ltmp15-.Lfunc_begin2 # ending offset + .byte 0 # DW_RLE_end_of_list +.Ldebug_ranges1: + .byte 1 # DW_RLE_base_addressx + .byte 2 # base address index + .byte 4 # DW_RLE_offset_pair + .uleb128 0 # starting offset Manually modified + .uleb128 .Ltmp19-.Lfunc_begin2 # ending offset + .byte 0 # DW_RLE_end_of_list +.Ldebug_list_header_end1: + .section .debug_addr,"",@progbits + .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution +.Ldebug_addr_start0: + .short 5 # DWARF version number + .byte 8 # Address size + .byte 0 # Segment selector size +.Laddr_table_base0: + .quad .Lfunc_begin0 + .quad .Lfunc_begin1 + .quad 0 # Manually modified +.Ldebug_addr_end0: + .section .debug_gnu_pubnames,"",@progbits + .long .LpubNames_end0-.LpubNames_start0 # Length of Public Names Info +.LpubNames_start0: + .short 2 # DWARF Version + .long .Lcu_begin0 # Offset of Compilation Unit Info + .long 48 # Compilation Unit Length + .long 68 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "doStuff" # External Name + .long 90 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "doStuffSame" # External Name + .long 108 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "main" # External Name + .long 0 # End Mark +.LpubNames_end0: + .section .debug_gnu_pubtypes,"",@progbits + .long .LpubTypes_end0-.LpubTypes_start0 # Length of Public Types Info +.LpubTypes_start0: + .short 2 # DWARF Version + .long .Lcu_begin0 # Offset of Compilation Unit Info + .long 48 # Compilation Unit Length + .long 86 # DIE offset + .byte 144 # Attributes: TYPE, STATIC + .asciz "int" # External Name + .long 197 # DIE offset + .byte 144 # Attributes: TYPE, STATIC + .asciz "char" # External Name + .long 0 # End Mark +.LpubTypes_end0: + .ident "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 63dbe7e808d07bdf25bad85301980bc323b0cd64)" + .section ".note.GNU-stack","",@progbits + .addrsig + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/dwarf4-df-inlined-subroutine-lowpc-0.test b/bolt/test/X86/dwarf4-df-inlined-subroutine-lowpc-0.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf4-df-inlined-subroutine-lowpc-0.test @@ -0,0 +1,30 @@ +; RUN: rm -rf %t +; RUN: mkdir %t +; RUN: cd %t +; RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-df-inlined-subroutine-lowpc-0-main.s \ +; RUN: -split-dwarf-file=main.dwo -o main.o +; RUN: %clang %cflags -gdwarf-4 -gsplit-dwarf=split main.o -o main.exe +; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections +; RUN: llvm-dwarfdump --debug-addr main.exe.bolt > log.txt +; RUN: llvm-dwarfdump --debug-info --verbose --show-form main.dwo.dwo >> log.txt +; RUN: cat log.txt | FileCheck -check-prefix=BOLT-MAIN %s + +; Tests whether BOLT handles correctly DW_TAG_inlined_subroutine when DW_AT_low_pc is 0, +; and split dwarf is enabled. + +; BOLT-MAIN: 0x +; BOLT-MAIN: 0x +; BOLT-MAIN: 0x +; BOLT-MAIN: 0x0000000000000000 +; BOLT-MAIN: DW_TAG_inlined_subroutine +; BOLT-MAIN: DW_AT_abstract_origin [DW_FORM_ref4] +; BOLT-MAIN-SAME: (cu + 0x0043 => {0x00000043} "_Z7doStuffi") +; BOLT-MAIN: DW_AT_low_pc [DW_FORM_GNU_addr_index] +; BOLT-MAIN-SAME: (indexed (00000003) address = ) +; BOLT-MAIN: DW_AT_high_pc [DW_FORM_data4] (0x00000015) +; BOLT-MAIN: DW_TAG_inlined_subroutine +; BOLT-MAIN: DW_AT_abstract_origin [DW_FORM_ref4] +; BOLT-MAIN-SAME: (cu + 0x005a => {0x0000005a} "_Z11doStuffSamei") +; BOLT-MAIN: DW_AT_low_pc [DW_FORM_GNU_addr_index] +; BOLT-MAIN-SAME: (indexed (00000003) address = ) +; BOLT-MAIN: DW_AT_high_pc [DW_FORM_data4] (0x0000000f) diff --git a/bolt/test/X86/dwarf5-df-inlined-subroutine-range-0.test b/bolt/test/X86/dwarf5-df-inlined-subroutine-range-0.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf5-df-inlined-subroutine-range-0.test @@ -0,0 +1,32 @@ +; RUN: rm -rf %t +; RUN: mkdir %t +; RUN: cd %t +; RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-inlined-subroutine-range-0-main.s \ +; RUN: -split-dwarf-file=main.dwo -o main.o +; RUN: %clang %cflags -gdwarf-4 -gsplit-dwarf=split main.o -o main.exe +; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections +; RUN: llvm-dwarfdump --debug-addr main.exe.bolt > log.txt +; RUN: llvm-dwarfdump --debug-info --verbose --show-form main.dwo.dwo >> log.txt +; RUN: cat log.txt | FileCheck -check-prefix=BOLT-MAIN %s + +; Tests whether BOLT handles correctly DW_TAG_inlined_subroutine when DW_AT_ranges is 0, +; and split dwarf is enabled. + +; BOLT-MAIN: 0x +; BOLT-MAIN: 0x +; BOLT-MAIN: 0x0000000000000000 +; BOLT-MAIN: DW_TAG_inlined_subroutine +; BOLT-MAIN: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x0044 => {0x00000044} "_Z7doStuffi") +; BOLT-MAIN: DW_AT_call_file +; BOLT-MAIN: DW_AT_call_line +; BOLT-MAIN: DW_AT_call_column +; BOLT-MAIN: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002) address = ) +; BOLT-MAIN: DW_AT_high_pc [DW_FORM_data4] (0x0000002d) + +; BOLT-MAIN: DW_TAG_inlined_subroutine +; BOLT-MAIN: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x005a => {0x0000005a} "_Z11doStuffSamei") +; BOLT-MAIN: DW_AT_call_file [DW_FORM_data1] (0x00) +; BOLT-MAIN: DW_AT_call_line [DW_FORM_data1] (16) +; BOLT-MAIN: DW_AT_call_column [DW_FORM_data1] (0x1d) +; BOLT-MAIN: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002) address = ) +; BOLT-MAIN: DW_AT_high_pc [DW_FORM_data4] (0x00000042)