diff --git a/bolt/include/bolt/Core/DIEBuilder.h b/bolt/include/bolt/Core/DIEBuilder.h --- a/bolt/include/bolt/Core/DIEBuilder.h +++ b/bolt/include/bolt/Core/DIEBuilder.h @@ -359,7 +359,6 @@ return Die->replaceValue(getState().DIEAlloc, Attribute, Form, NewValue); } - template bool deleteValue(DIEValueList *Die, dwarf::Attribute Attribute) { return Die->deleteValue(Attribute); } diff --git a/bolt/include/bolt/Rewrite/DWARFRewriter.h b/bolt/include/bolt/Rewrite/DWARFRewriter.h --- a/bolt/include/bolt/Rewrite/DWARFRewriter.h +++ b/bolt/include/bolt/Rewrite/DWARFRewriter.h @@ -125,7 +125,7 @@ /// attribute. void updateDWARFObjectAddressRanges( DWARFUnit &Unit, DIEBuilder &DIEBldr, DIE &Die, - uint64_t DebugRangesOffset, uint64_t LowPCToUse, + uint64_t DebugRangesOffset, std::optional RangesBase = std::nullopt); std::unique_ptr @@ -173,7 +173,7 @@ void convertToRangesPatchDebugInfo( DWARFUnit &Unit, DIEBuilder &DIEBldr, DIE &Die, uint64_t RangesSectionOffset, DIEValue &LowPCAttrInfo, - DIEValue &HighPCAttrInfo, uint64_t LowPCToUse, + DIEValue &HighPCAttrInfo, std::optional RangesBase = std::nullopt); /// Adds a \p Str to .debug_str section. 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 @@ -246,6 +246,12 @@ "Specifies the size of batches for processing CUs. Higher number has " "better performance, but more memory usage. Default value is 1."), cl::Hidden, cl::init(1), cl::cat(BoltCategory)); + +static cl::opt AlwaysConvertToRanges( + "always-convert-to-ranges", + cl::desc("This option is for testing purposes only. It forces BOLT to " + "convert low_pc/high_pc to ranges always."), + cl::ReallyHidden, cl::init(false), cl::cat(BoltCategory)); } // namespace opts static bool getLowAndHighPC(const DIE &Die, const DWARFUnit &DU, @@ -693,6 +699,45 @@ const std::vector> &DIs = DIEBldr.getDIEsByUnit(Unit); + // Either updates or normalizes DW_AT_range to DW_AT_low_pc and DW_AT_high_pc. + auto updateLowPCHighPC = [&](DIE *Die, const DIEValue &LowPCVal, + const DIEValue &HighPCVal, uint64_t LowPC, + const uint64_t HighPC) { + dwarf::Attribute AttrLowPC = dwarf::DW_AT_low_pc; + dwarf::Form FormLowPC = dwarf::DW_FORM_addr; + dwarf::Attribute AttrHighPC = dwarf::DW_AT_high_pc; + dwarf::Form FormHighPC = dwarf::DW_FORM_data4; + const uint32_t Size = HighPC - LowPC; + // Whatever was generated is not low_pc/high_pc, so will reset to + // default for size 1. + if (!LowPCVal || !HighPCVal) { + if (Unit.getVersion() >= 5) + FormLowPC = dwarf::DW_FORM_addrx; + else if (Unit.isDWOUnit()) + FormLowPC = dwarf::DW_FORM_GNU_addr_index; + } else { + AttrLowPC = LowPCVal.getAttribute(); + FormLowPC = LowPCVal.getForm(); + AttrHighPC = HighPCVal.getAttribute(); + FormHighPC = HighPCVal.getForm(); + } + + if (FormLowPC == dwarf::DW_FORM_addrx || + FormLowPC == dwarf::DW_FORM_GNU_addr_index) + LowPC = AddrWriter->getIndexFromAddress(LowPC, Unit); + + if (LowPCVal) + DIEBldr.replaceValue(Die, AttrLowPC, FormLowPC, DIEInteger(LowPC)); + else + DIEBldr.addValue(Die, AttrLowPC, FormLowPC, DIEInteger(LowPC)); + if (HighPCVal) { + DIEBldr.replaceValue(Die, AttrHighPC, FormHighPC, DIEInteger(Size)); + } else { + DIEBldr.deleteValue(Die, dwarf::DW_AT_ranges); + DIEBldr.addValue(Die, AttrHighPC, FormHighPC, DIEInteger(Size)); + } + }; + for (const std::unique_ptr &DI : DIs) { DIE *Die = DI->Die; switch (Die->getTag()) { @@ -726,7 +771,7 @@ ARangesSectionWriter->addCURanges(Unit.getOffset(), std::move(OutputRanges)); updateDWARFObjectAddressRanges(Unit, DIEBldr, *Die, RangesSectionOffset, - 0, RangesBase); + RangesBase); DIEValue StmtListAttrVal = Die->findAttribute(dwarf::DW_AT_stmt_list); if (LineTablePatchMap.count(&Unit)) DIEBldr.replaceValue(Die, dwarf::DW_AT_stmt_list, @@ -737,8 +782,9 @@ case dwarf::DW_TAG_subprogram: { // Get function address either from ranges or [LowPC, HighPC) pair. - uint64_t Address; + uint64_t Address = UINT64_MAX; uint64_t SectionIndex, HighPC; + DebugAddressRangesVector FunctionRanges; if (!getLowAndHighPC(*Die, Unit, Address, HighPC, SectionIndex)) { Expected RangesOrError = getDIEAddressRanges(*Die, Unit); @@ -751,23 +797,41 @@ if (Ranges.empty()) break; - Address = Ranges.front().LowPC; + for (const DWARFAddressRange &Range : Ranges) { + if (const BinaryFunction *Function = + BC.getBinaryFunctionAtAddress(Range.LowPC)) + FunctionRanges.append(Function->getOutputAddressRanges()); + } + } else { + if (const BinaryFunction *Function = + BC.getBinaryFunctionAtAddress(Address)) + FunctionRanges = Function->getOutputAddressRanges(); } // Clear cached ranges as the new function will have its own set. CachedRanges.clear(); + DIEValue LowPCVal = Die->findAttribute(dwarf::DW_AT_low_pc); + DIEValue HighPCVal = Die->findAttribute(dwarf::DW_AT_high_pc); + if (FunctionRanges.empty()) { + if (LowPCVal && HighPCVal) { + FunctionRanges.push_back({0, HighPCVal.getDIEInteger().getValue()}); + } else { + // I haven't seen this case, but who knows what other compilers + // generate. + FunctionRanges.push_back({0, 1}); + errs() << "BOLT-WARNING: [internal-dwarf-error]: subprogram got GCed " + "by the linker, DW_AT_ranges is used\n"; + } + } - DebugAddressRangesVector FunctionRanges; - if (const BinaryFunction *Function = - BC.getBinaryFunctionAtAddress(Address)) - FunctionRanges = Function->getOutputAddressRanges(); - - if (FunctionRanges.empty()) - FunctionRanges.push_back({0, 0}); + if (FunctionRanges.size() == 1 && !opts::AlwaysConvertToRanges) { + updateLowPCHighPC(Die, LowPCVal, HighPCVal, FunctionRanges.back().LowPC, + FunctionRanges.back().HighPC); + break; + } updateDWARFObjectAddressRanges( - Unit, DIEBldr, *Die, RangesSectionWriter.addRanges(FunctionRanges), - 0); + Unit, DIEBldr, *Die, RangesSectionWriter.addRanges(FunctionRanges)); break; } @@ -783,37 +847,33 @@ ? BC.getBinaryFunctionContainingAddress( RangesOrError->front().LowPC) : nullptr; - bool ErrorState = false; - std::optional NewLowPC; + DebugAddressRangesVector OutputRanges; if (Function) { - DebugAddressRangesVector OutputRanges = - Function->translateInputToOutputRanges(*RangesOrError); + OutputRanges = Function->translateInputToOutputRanges(*RangesOrError); LLVM_DEBUG(if (OutputRanges.empty() != RangesOrError->empty()) { dbgs() << "BOLT-DEBUG: problem with DIE at 0x" << Twine::utohexstr(Die->getOffset()) << " in CU at 0x" << Twine::utohexstr(Unit.getOffset()) << '\n'; }); - if (!OutputRanges.empty()) - NewLowPC = OutputRanges.front().LowPC; - RangesSectionOffset = RangesSectionWriter.addRanges( - std::move(OutputRanges), CachedRanges); + if (opts::AlwaysConvertToRanges || OutputRanges.size() > 1) { + RangesSectionOffset = RangesSectionWriter.addRanges( + std::move(OutputRanges), CachedRanges); + OutputRanges.clear(); + } else if (OutputRanges.empty()) { + OutputRanges.push_back({RangesOrError.get().front().LowPC, + RangesOrError.get().front().HighPC}); + } } else if (!RangesOrError) { - ErrorState = true; consumeError(RangesOrError.takeError()); } - - uint64_t LowPCToUse = 0; - if (!ErrorState && RangesOrError.get().size() == 1 && - RangesOrError.get().begin()->LowPC == - RangesOrError.get().begin()->HighPC) { - if (NewLowPC) - LowPCToUse = NewLowPC.value(); - else - LowPCToUse = RangesOrError.get().begin()->LowPC; + DIEValue LowPCVal = Die->findAttribute(dwarf::DW_AT_low_pc); + DIEValue HighPCVal = Die->findAttribute(dwarf::DW_AT_high_pc); + if (OutputRanges.size() == 1) { + updateLowPCHighPC(Die, LowPCVal, HighPCVal, OutputRanges.back().LowPC, + OutputRanges.back().HighPC); + break; } - - updateDWARFObjectAddressRanges(Unit, DIEBldr, *Die, RangesSectionOffset, - LowPCToUse); + updateDWARFObjectAddressRanges(Unit, DIEBldr, *Die, RangesSectionOffset); break; } case dwarf::DW_TAG_call_site: { @@ -1147,7 +1207,7 @@ void DWARFRewriter::updateDWARFObjectAddressRanges( DWARFUnit &Unit, DIEBuilder &DIEBldr, DIE &Die, uint64_t DebugRangesOffset, - uint64_t LowPCToUse, std::optional RangesBase) { + std::optional RangesBase) { if (RangesBase) { // If DW_AT_GNU_ranges_base is present, update it. No further modifications @@ -1195,7 +1255,7 @@ LowPCAttrInfo.getForm() != dwarf::DW_FORM_GNU_addr_index && LowPCAttrInfo.getForm() != dwarf::DW_FORM_addrx) DIEBldr.replaceValue(&Die, dwarf::DW_AT_low_pc, LowPCAttrInfo.getForm(), - DIEInteger(LowPCToUse)); + DIEInteger(0)); return; } @@ -1223,8 +1283,7 @@ if (LowPCAttrInfo && HighPCAttrInfo) { convertToRangesPatchDebugInfo(Unit, DIEBldr, Die, DebugRangesOffset, - LowPCAttrInfo, HighPCAttrInfo, LowPCToUse, - RangesBase); + LowPCAttrInfo, HighPCAttrInfo, RangesBase); } else if (!(Unit.isDWOUnit() && Die.getTag() == dwarf::DW_TAG_compile_unit)) { if (opts::Verbosity >= 1) @@ -2086,8 +2145,7 @@ void DWARFRewriter::convertToRangesPatchDebugInfo( DWARFUnit &Unit, DIEBuilder &DIEBldr, DIE &Die, uint64_t RangesSectionOffset, DIEValue &LowPCAttrInfo, - DIEValue &HighPCAttrInfo, uint64_t LowPCToUse, - std::optional RangesBase) { + DIEValue &HighPCAttrInfo, std::optional RangesBase) { uint32_t BaseOffset = 0; dwarf::Form LowForm = LowPCAttrInfo.getForm(); dwarf::Attribute RangeBaseAttribute = dwarf::DW_AT_GNU_ranges_base; @@ -2120,12 +2178,12 @@ // DW_FORM_addrx. Former is when DW_AT_rnglists_base is present. Latter is // when it's absent. if (LowForm == dwarf::DW_FORM_addrx) { - const uint32_t Index = AddrWriter->getIndexFromAddress(LowPCToUse, Unit); + const uint32_t Index = AddrWriter->getIndexFromAddress(0, Unit); DIEBldr.replaceValue(&Die, LowPCAttrInfo.getAttribute(), LowPCAttrInfo.getForm(), DIEInteger(Index)); } else DIEBldr.replaceValue(&Die, LowPCAttrInfo.getAttribute(), - LowPCAttrInfo.getForm(), DIEInteger(LowPCToUse)); + LowPCAttrInfo.getForm(), DIEInteger(0)); // Original CU didn't have DW_AT_*_base. We converted it's children (or // dwo), so need to insert it into CU. diff --git a/bolt/test/AArch64/go_dwarf.test b/bolt/test/AArch64/go_dwarf.test --- a/bolt/test/AArch64/go_dwarf.test +++ b/bolt/test/AArch64/go_dwarf.test @@ -49,6 +49,5 @@ CHECK-NEXT: DW_AT_decl_line (1) CHECK-NEXT: DW_AT_decl_column (0x05) CHECK-NEXT: DW_AT_type -CHECK-NEXT: DW_AT_low_pc (0x0000000000000000) -CHECK-NEXT: DW_AT_ranges (0x00000030 -CHECK-NEXT: [0x0000000000000660, 0x0000000000000684)) +CHECK-NEXT: DW_AT_low_pc (0x0000000000000660) +CHECK-NEXT: DW_AT_high_pc (0x0000000000000024) diff --git a/bolt/test/X86/Inputs/debug-fission-simple-convert.s b/bolt/test/X86/Inputs/debug-fission-simple-convert.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/debug-fission-simple-convert.s @@ -0,0 +1,446 @@ + .text + .file "debug-fission-simple.cpp" + .file 1 "" "debug-fission-simple.cpp" + .section .text._Z7doStuffi,"ax",@progbits + .globl _Z7doStuffi # -- Begin function _Z7doStuffi + .p2align 4, 0x90 + .type _Z7doStuffi,@function +_Z7doStuffi: # @_Z7doStuffi +.Lfunc_begin0: + .loc 1 3 0 # debug-fission-simple.cpp:3: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 4 11 prologue_end # debug-fission-simple.cpp:4:11 + cmpl $5, -4(%rbp) +.Ltmp1: + .loc 1 4 7 is_stmt 0 # debug-fission-simple.cpp:4:7 + jne .LBB0_2 +# %bb.1: # %if.then +.Ltmp2: + .loc 1 5 16 is_stmt 1 # debug-fission-simple.cpp:5:16 + movl _ZL3foo, %eax + .loc 1 5 14 is_stmt 0 # debug-fission-simple.cpp:5:14 + addl $1, %eax + .loc 1 5 9 # debug-fission-simple.cpp:5:9 + addl -4(%rbp), %eax + movl %eax, -4(%rbp) + .loc 1 5 5 # debug-fission-simple.cpp:5:5 + jmp .LBB0_3 +.LBB0_2: # %if.else + .loc 1 7 9 is_stmt 1 # debug-fission-simple.cpp:7:9 + movl -4(%rbp), %eax + subl $1, %eax + movl %eax, -4(%rbp) +.Ltmp3: +.LBB0_3: # %if.end + .loc 1 8 10 # debug-fission-simple.cpp:8:10 + movl -4(%rbp), %eax + .loc 1 8 3 is_stmt 0 # debug-fission-simple.cpp:8:3 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp4: +.Lfunc_end0: + .size _Z7doStuffi, .Lfunc_end0-_Z7doStuffi + .cfi_endproc + # -- End function + .section .text._Z8doStuff2i,"ax",@progbits + .globl _Z8doStuff2i # -- Begin function _Z8doStuff2i + .p2align 4, 0x90 + .type _Z8doStuff2i,@function +_Z8doStuff2i: # @_Z8doStuff2i +.Lfunc_begin1: + .loc 1 11 0 is_stmt 1 # debug-fission-simple.cpp:11: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 12 14 prologue_end # debug-fission-simple.cpp:12:14 + movl -4(%rbp), %eax + addl $3, %eax + movl %eax, -4(%rbp) + .loc 1 12 3 is_stmt 0 # debug-fission-simple.cpp:12:3 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp6: +.Lfunc_end1: + .size _Z8doStuff2i, .Lfunc_end1-_Z8doStuff2i + .cfi_endproc + # -- End function + .section .text._Z6_startv,"ax",@progbits + .globl _Z6_startv # -- Begin function _Z6_startv + .p2align 4, 0x90 + .type _Z6_startv,@function +_Z6_startv: # @_Z6_startv +.Lfunc_begin2: + .loc 1 15 0 is_stmt 1 # debug-fission-simple.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 + subq $16, %rsp +.Ltmp7: + .loc 1 16 7 prologue_end # debug-fission-simple.cpp:16:7 + movl $4, -4(%rbp) + .loc 1 17 18 # debug-fission-simple.cpp:17:18 + movl -4(%rbp), %edi + .loc 1 17 10 is_stmt 0 # debug-fission-simple.cpp:17:10 + callq _Z7doStuffi + .loc 1 17 3 # debug-fission-simple.cpp:17:3 + addq $16, %rsp + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp8: +.Lfunc_end2: + .size _Z6_startv, .Lfunc_end2-_Z6_startv + .cfi_endproc + # -- End function + .type _ZL3foo,@object # @_ZL3foo + .data + .p2align 2 +_ZL3foo: + .long 2 # 0x2 + .size _ZL3foo, 4 + + .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 436953012669069206 # 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 + .quad 0 + .section .debug_str,"MS",@progbits,1 +.Lskel_string0: + .asciz "" # string offset=0 +.Lskel_string1: + .asciz "debug-fission-simple-convert.dwo" # string offset=47 + .section .debug_str.dwo,"eMS",@progbits,1 +.Linfo_string0: + .asciz "foo" # string offset=0 +.Linfo_string1: + .asciz "int" # string offset=4 +.Linfo_string2: + .asciz "_ZL3foo" # string offset=8 +.Linfo_string3: + .asciz "_Z7doStuffi" # string offset=16 +.Linfo_string4: + .asciz "doStuff" # string offset=28 +.Linfo_string5: + .asciz "_Z8doStuff2i" # string offset=36 +.Linfo_string6: + .asciz "doStuff2" # string offset=49 +.Linfo_string7: + .asciz "_Z6_startv" # string offset=58 +.Linfo_string8: + .asciz "_start" # string offset=69 +.Linfo_string9: + .asciz "val" # string offset=76 +.Linfo_string10: + .asciz "clang version 13.0.0" # string offset=80 +.Linfo_string11: + .asciz "debug-fission-simple.cpp" # string offset=214 +.Linfo_string12: + .asciz "debug-fission-simple-convert.dwo" # string offset=239 + .section .debug_str_offsets.dwo,"e",@progbits + .long 0 + .long 4 + .long 8 + .long 16 + .long 28 + .long 36 + .long 49 + .long 58 + .long 69 + .long 76 + .long 80 + .long 214 + .long 239 + .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:0x73 DW_TAG_compile_unit + .byte 10 # DW_AT_producer + .short 4 # DW_AT_language + .byte 11 # DW_AT_name + .byte 12 # DW_AT_GNU_dwo_name + .quad 436953012669069206 # DW_AT_GNU_dwo_id + .byte 2 # Abbrev [2] 0x19:0xc DW_TAG_variable + .byte 0 # DW_AT_name + .long 37 # DW_AT_type + .byte 1 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .byte 2 # DW_AT_location + .byte 251 + .byte 0 + .byte 2 # DW_AT_linkage_name + .byte 3 # Abbrev [3] 0x25:0x4 DW_TAG_base_type + .byte 1 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 4 # Abbrev [4] 0x29:0x1c DW_TAG_subprogram + .byte 1 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 3 # DW_AT_linkage_name + .byte 4 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 3 # DW_AT_decl_line + .long 37 # DW_AT_type + # DW_AT_external + .byte 5 # Abbrev [5] 0x39:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .byte 9 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 3 # DW_AT_decl_line + .long 37 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x45:0x1c DW_TAG_subprogram + .byte 2 # DW_AT_low_pc + .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 5 # DW_AT_linkage_name + .byte 6 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 11 # DW_AT_decl_line + .long 37 # DW_AT_type + # DW_AT_external + .byte 5 # Abbrev [5] 0x55:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .byte 9 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 11 # DW_AT_decl_line + .long 37 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x61:0x1c DW_TAG_subprogram + .byte 3 # DW_AT_low_pc + .long .Lfunc_end2-.Lfunc_begin2 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 7 # DW_AT_linkage_name + .byte 8 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 15 # DW_AT_decl_line + .long 37 # DW_AT_type + # DW_AT_external + .byte 6 # Abbrev [6] 0x71:0xb DW_TAG_variable + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .byte 9 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 16 # DW_AT_decl_line + .long 37 # DW_AT_type + .byte 0 # End Of Children Mark + .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 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 110 # DW_AT_linkage_name + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # 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 4 # 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 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 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # 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 6 # Abbreviation Code + .byte 52 # DW_TAG_variable + .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 0 # EOM(3) + .section .debug_addr,"",@progbits +.Laddr_table_base0: + .quad _ZL3foo + .quad .Lfunc_begin0 + .quad .Lfunc_begin1 + .quad .Lfunc_begin2 + .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 25 # DIE offset + .byte 160 # Attributes: VARIABLE, STATIC + .asciz "foo" # External Name + .long 41 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "doStuff" # External Name + .long 69 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "doStuff2" # External Name + .long 97 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "_start" # 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 37 # DIE offset + .byte 144 # Attributes: TYPE, STATIC + .asciz "int" # External Name + .long 0 # End Mark +.LpubTypes_end0: + .ident "clang version 13" + .section ".note.GNU-stack","",@progbits + .addrsig + .addrsig_sym _Z7doStuffi + .addrsig_sym _ZL3foo + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s b/bolt/test/X86/Inputs/dwarf4-df-do-no-convert-low-pc-high-pc-to-ranges.s copy from bolt/test/X86/dwarf4-size-0-inlined_subroutine.s copy to bolt/test/X86/Inputs/dwarf4-df-do-no-convert-low-pc-high-pc-to-ranges.s --- a/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s +++ b/bolt/test/X86/Inputs/dwarf4-df-do-no-convert-low-pc-high-pc-to-ranges.s @@ -1,40 +1,3 @@ -# REQUIRES: system-linux - -# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o -# RUN: %clang %cflags -dwarf-4 %tmain.o -o %t.exe -Wl,-q -# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --use-old-text -# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt > %t.txt -# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe >> %t.txt -# RUN: cat %t.txt | FileCheck --check-prefix=CHECK %s - -# CHECK: DW_TAG_inlined_subroutine -# CHECK: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,ADDR:]]) -# CHECK: DW_AT_ranges [DW_FORM_sec_offset] -# CHECK-NEXT: [0x[[#ADDR]], 0x[[#ADDR]]) - -# CHECK: DW_TAG_inlined_subroutine -# CHECK-NOT: DW_AT_low_pc [DW_FORM_addr] (0x[[#ADDR]]) - - -# Testing BOLT handles correctly when size of DW_AT_inlined_subroutine is 0. -# In other words DW_AT_high_pc is 0 or DW_AT_low_pc == DW_AT_high_pc. - -# Modified assembly manually to set DW_AT_high_pc to 0. -# clang++ -g2 -gdwarf-4 main.cpp -O1 -S -o main4.s - -# static int helper(int i) { -# return ++i; -# } -# void may_not_exist(void) __attribute__ ((weak)); -# int main(int argc, char *argv[]) { -# if (may_not_exist) -# may_not_exist(); -# int j = 0; -# [[clang::always_inline]] j = helper(argc); -# return j; -# } - - .text .file "main.cpp" .globl main # -- Begin function main @@ -77,6 +40,7 @@ #DEBUG_VALUE: main:j <- $ebx .loc 1 10 3 # main.cpp:10:3 movl %ebx, %eax + .loc 1 10 3 epilogue_begin is_stmt 0 # main.cpp:10:3 popq %rbx .Ltmp4: #DEBUG_VALUE: helper:i <- $eax @@ -88,83 +52,264 @@ .size main, .Lfunc_end0-main .cfi_endproc # -- End function - .section .debug_loc,"",@progbits + .section .debug_loc.dwo,"e",@progbits .Ldebug_loc0: - .quad .Lfunc_begin0-.Lfunc_begin0 - .quad .Ltmp1-.Lfunc_begin0 + .byte 3 + .byte 0 + .long .Ltmp1-.Lfunc_begin0 .short 1 # Loc expr size .byte 85 # super-register DW_OP_reg5 - .quad .Ltmp1-.Lfunc_begin0 - .quad .Ltmp3-.Lfunc_begin0 + .byte 3 + .byte 2 + .long .Ltmp3-.Ltmp1 .short 1 # Loc expr size .byte 83 # super-register DW_OP_reg3 - .quad .Ltmp3-.Lfunc_begin0 - .quad .Lfunc_end0-.Lfunc_begin0 + .byte 3 + .byte 3 + .long .Lfunc_end0-.Ltmp3 .short 4 # Loc expr size .byte 243 # DW_OP_GNU_entry_value .byte 1 # 1 .byte 85 # super-register DW_OP_reg5 .byte 159 # DW_OP_stack_value - .quad 0 - .quad 0 + .byte 0 .Ldebug_loc1: - .quad .Lfunc_begin0-.Lfunc_begin0 - .quad .Ltmp2-.Lfunc_begin0 + .byte 3 + .byte 0 + .long .Ltmp2-.Lfunc_begin0 .short 1 # Loc expr size .byte 84 # DW_OP_reg4 - .quad .Ltmp2-.Lfunc_begin0 - .quad .Lfunc_end0-.Lfunc_begin0 + .byte 3 + .byte 1 + .long .Lfunc_end0-.Ltmp2 .short 4 # Loc expr size .byte 243 # DW_OP_GNU_entry_value .byte 1 # 1 .byte 84 # DW_OP_reg4 .byte 159 # DW_OP_stack_value - .quad 0 - .quad 0 + .byte 0 .Ldebug_loc2: - .quad .Ltmp2-.Lfunc_begin0 - .quad .Ltmp3-.Lfunc_begin0 + .byte 3 + .byte 1 + .long .Ltmp3-.Ltmp2 .short 3 # Loc expr size .byte 17 # DW_OP_consts .byte 0 # 0 .byte 159 # DW_OP_stack_value - .quad .Ltmp3-.Lfunc_begin0 - .quad .Ltmp4-.Lfunc_begin0 + .byte 3 + .byte 3 + .long .Ltmp4-.Ltmp3 .short 1 # Loc expr size .byte 83 # super-register DW_OP_reg3 - .quad .Ltmp4-.Lfunc_begin0 - .quad .Lfunc_end0-.Lfunc_begin0 + .byte 3 + .byte 4 + .long .Lfunc_end0-.Ltmp4 .short 1 # Loc expr size .byte 80 # super-register DW_OP_reg0 - .quad 0 - .quad 0 + .byte 0 .section .debug_abbrev,"",@progbits .byte 1 # Abbreviation Code .byte 17 # DW_TAG_compile_unit - .byte 1 # DW_CHILDREN_yes - .byte 37 # DW_AT_producer - .byte 14 # DW_FORM_strp - .byte 19 # DW_AT_language - .byte 5 # DW_FORM_data2 - .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .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 18 # DW_AT_high_pc .byte 6 # DW_FORM_data4 + .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 -5076722043903325778 # DW_AT_GNU_dwo_id + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .long .Laddr_table_base0 # DW_AT_GNU_addr_base +.Ldebug_info_end0: + .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 "_ZL6helperi" # string offset=0 +.Linfo_string1: + .asciz "helper" # string offset=12 +.Linfo_string2: + .asciz "int" # string offset=19 +.Linfo_string3: + .asciz "i" # string offset=23 +.Linfo_string4: + .asciz "_Z13may_not_existv" # string offset=25 +.Linfo_string5: + .asciz "may_not_exist" # string offset=44 +.Linfo_string6: + .asciz "main" # string offset=58 +.Linfo_string7: + .asciz "argc" # string offset=63 +.Linfo_string8: + .asciz "argv" # string offset=68 +.Linfo_string9: + .asciz "char" # string offset=73 +.Linfo_string10: + .asciz "j" # string offset=78 +.Linfo_string11: + .asciz "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" # string offset=80 +.Linfo_string12: + .asciz "main.cpp" # string offset=185 +.Linfo_string13: + .asciz "main.dwo" # string offset=194 + .section .debug_str_offsets.dwo,"e",@progbits + .long 0 + .long 12 + .long 19 + .long 23 + .long 25 + .long 44 + .long 58 + .long 63 + .long 68 + .long 73 + .long 78 + .long 80 + .long 185 + .long 194 + .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:0x88 DW_TAG_compile_unit + .byte 11 # DW_AT_producer + .short 33 # DW_AT_language + .byte 12 # DW_AT_name + .byte 13 # DW_AT_GNU_dwo_name + .quad -5076722043903325778 # DW_AT_GNU_dwo_id + .byte 2 # Abbrev [2] 0x19:0x13 DW_TAG_subprogram + .byte 0 # DW_AT_linkage_name + .byte 1 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 44 # DW_AT_type + .byte 1 # DW_AT_inline + .byte 3 # Abbrev [3] 0x23:0x8 DW_TAG_formal_parameter + .byte 3 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 44 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x2c:0x4 DW_TAG_base_type + .byte 2 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 5 # Abbrev [5] 0x30:0x4f 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 87 + # DW_AT_GNU_all_call_sites + .byte 6 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 5 # DW_AT_decl_line + .long 44 # DW_AT_type + # DW_AT_external + .byte 6 # Abbrev [6] 0x3f:0xc DW_TAG_formal_parameter + .long .Ldebug_loc0-.debug_loc.dwo # DW_AT_location + .byte 7 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 5 # DW_AT_decl_line + .long 44 # DW_AT_type + .byte 6 # Abbrev [6] 0x4b:0xc DW_TAG_formal_parameter + .long .Ldebug_loc1-.debug_loc.dwo # DW_AT_location + .byte 8 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 5 # DW_AT_decl_line + .long 132 # DW_AT_type + .byte 7 # Abbrev [7] 0x57:0xc DW_TAG_variable + .long .Ldebug_loc2-.debug_loc.dwo # DW_AT_location + .byte 10 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 8 # DW_AT_decl_line + .long 44 # DW_AT_type + .byte 8 # Abbrev [8] 0x63:0x15 DW_TAG_inlined_subroutine + .long 25 # DW_AT_abstract_origin + .byte 1 # DW_AT_low_pc + .long .Ltmp3-.Ltmp2 # DW_AT_high_pc + .byte 1 # DW_AT_call_file + .byte 9 # DW_AT_call_line + .byte 32 # DW_AT_call_column + .byte 9 # Abbrev [9] 0x70:0x7 DW_TAG_formal_parameter + .byte 1 # DW_AT_location + .byte 83 + .long 35 # DW_AT_abstract_origin + .byte 0 # End Of Children Mark + .byte 10 # Abbrev [10] 0x78:0x6 DW_TAG_GNU_call_site + .long 127 # DW_AT_abstract_origin + .byte 1 # DW_AT_low_pc + .byte 0 # End Of Children Mark + .byte 11 # Abbrev [11] 0x7f:0x5 DW_TAG_subprogram + .byte 4 # DW_AT_linkage_name + .byte 5 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 4 # DW_AT_decl_line + # DW_AT_declaration + # DW_AT_external + .byte 12 # Abbrev [12] 0x84:0x5 DW_TAG_pointer_type + .long 137 # DW_AT_type + .byte 12 # Abbrev [12] 0x89:0x5 DW_TAG_pointer_type + .long 142 # DW_AT_type + .byte 4 # Abbrev [4] 0x8e: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 110 # DW_AT_linkage_name - .byte 14 # DW_FORM_strp + .ascii "\202>" # DW_FORM_GNU_str_index .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .ascii "\202>" # DW_FORM_GNU_str_index .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -179,7 +324,7 @@ .byte 5 # DW_TAG_formal_parameter .byte 0 # DW_CHILDREN_no .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .ascii "\202>" # DW_FORM_GNU_str_index .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -192,7 +337,7 @@ .byte 36 # DW_TAG_base_type .byte 0 # DW_CHILDREN_no .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .ascii "\202>" # DW_FORM_GNU_str_index .byte 62 # DW_AT_encoding .byte 11 # DW_FORM_data1 .byte 11 # DW_AT_byte_size @@ -203,7 +348,7 @@ .byte 46 # DW_TAG_subprogram .byte 1 # DW_CHILDREN_yes .byte 17 # DW_AT_low_pc - .byte 1 # DW_FORM_addr + .ascii "\201>" # DW_FORM_GNU_addr_index .byte 18 # DW_AT_high_pc .byte 6 # DW_FORM_data4 .byte 64 # DW_AT_frame_base @@ -211,7 +356,7 @@ .ascii "\227B" # DW_AT_GNU_all_call_sites .byte 25 # DW_FORM_flag_present .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .ascii "\202>" # DW_FORM_GNU_str_index .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -228,7 +373,7 @@ .byte 2 # DW_AT_location .byte 23 # DW_FORM_sec_offset .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .ascii "\202>" # DW_FORM_GNU_str_index .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -243,7 +388,7 @@ .byte 2 # DW_AT_location .byte 23 # DW_FORM_sec_offset .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .ascii "\202>" # DW_FORM_GNU_str_index .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -258,7 +403,7 @@ .byte 49 # DW_AT_abstract_origin .byte 19 # DW_FORM_ref4 .byte 17 # DW_AT_low_pc - .byte 1 # DW_FORM_addr + .ascii "\201>" # DW_FORM_GNU_addr_index .byte 18 # DW_AT_high_pc .byte 6 # DW_FORM_data4 .byte 88 # DW_AT_call_file @@ -284,16 +429,16 @@ .byte 49 # DW_AT_abstract_origin .byte 19 # DW_FORM_ref4 .byte 17 # DW_AT_low_pc - .byte 1 # DW_FORM_addr + .ascii "\201>" # DW_FORM_GNU_addr_index .byte 0 # EOM(1) .byte 0 # EOM(2) .byte 11 # Abbreviation Code .byte 46 # DW_TAG_subprogram .byte 0 # DW_CHILDREN_no .byte 110 # DW_AT_linkage_name - .byte 14 # DW_FORM_strp + .ascii "\202>" # DW_FORM_GNU_str_index .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .ascii "\202>" # DW_FORM_GNU_str_index .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -312,131 +457,43 @@ .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:0xcf DW_TAG_compile_unit - .long .Linfo_string0 # DW_AT_producer - .short 33 # DW_AT_language - .long .Linfo_string1 # DW_AT_name - .long .Lline_table_start0 # DW_AT_stmt_list - .long .Linfo_string2 # DW_AT_comp_dir - .quad .Lfunc_begin0 # DW_AT_low_pc - .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc - .byte 2 # Abbrev [2] 0x2a:0x1c DW_TAG_subprogram - .long .Linfo_string3 # DW_AT_linkage_name - .long .Linfo_string4 # DW_AT_name - .byte 1 # DW_AT_decl_file - .byte 1 # DW_AT_decl_line - .long 70 # DW_AT_type - .byte 1 # DW_AT_inline - .byte 3 # Abbrev [3] 0x3a:0xb DW_TAG_formal_parameter - .long .Linfo_string6 # DW_AT_name - .byte 1 # DW_AT_decl_file - .byte 1 # DW_AT_decl_line - .long 70 # DW_AT_type - .byte 0 # End Of Children Mark - .byte 4 # Abbrev [4] 0x46:0x7 DW_TAG_base_type - .long .Linfo_string5 # DW_AT_name - .byte 5 # DW_AT_encoding - .byte 4 # DW_AT_byte_size - .byte 5 # Abbrev [5] 0x4d:0x70 DW_TAG_subprogram - .quad .Lfunc_begin0 # DW_AT_low_pc - .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc - .byte 1 # DW_AT_frame_base - .byte 87 - # DW_AT_GNU_all_call_sites - .long .Linfo_string9 # DW_AT_name - .byte 1 # DW_AT_decl_file - .byte 5 # DW_AT_decl_line - .long 70 # DW_AT_type - # DW_AT_external - .byte 6 # Abbrev [6] 0x66:0xf DW_TAG_formal_parameter - .long .Ldebug_loc0 # DW_AT_location - .long .Linfo_string10 # DW_AT_name - .byte 1 # DW_AT_decl_file - .byte 5 # DW_AT_decl_line - .long 70 # DW_AT_type - .byte 6 # Abbrev [6] 0x75:0xf DW_TAG_formal_parameter - .long .Ldebug_loc1 # DW_AT_location - .long .Linfo_string11 # DW_AT_name - .byte 1 # DW_AT_decl_file - .byte 5 # DW_AT_decl_line - .long 200 # DW_AT_type - .byte 7 # Abbrev [7] 0x84:0xf DW_TAG_variable - .long .Ldebug_loc2 # DW_AT_location - .long .Linfo_string13 # DW_AT_name - .byte 1 # DW_AT_decl_file - .byte 8 # DW_AT_decl_line - .long 70 # DW_AT_type - .byte 8 # Abbrev [8] 0x93:0x1c DW_TAG_inlined_subroutine - .long 42 # DW_AT_abstract_origin - .quad .Ltmp2 # DW_AT_low_pc - .long 0 # DW_AT_high_pc Manually modified - .byte 1 # DW_AT_call_file - .byte 9 # DW_AT_call_line - .byte 32 # DW_AT_call_column - .byte 9 # Abbrev [9] 0xa7:0x7 DW_TAG_formal_parameter - .byte 1 # DW_AT_location - .byte 83 - .long 58 # DW_AT_abstract_origin - .byte 0 # End Of Children Mark - .byte 10 # Abbrev [10] 0xaf:0xd DW_TAG_GNU_call_site - .long 189 # DW_AT_abstract_origin - .quad .Ltmp2 # DW_AT_low_pc - .byte 0 # End Of Children Mark - .byte 11 # Abbrev [11] 0xbd:0xb DW_TAG_subprogram - .long .Linfo_string7 # DW_AT_linkage_name - .long .Linfo_string8 # DW_AT_name - .byte 1 # DW_AT_decl_file - .byte 4 # DW_AT_decl_line - # DW_AT_declaration - # DW_AT_external - .byte 12 # Abbrev [12] 0xc8:0x5 DW_TAG_pointer_type - .long 205 # DW_AT_type - .byte 12 # Abbrev [12] 0xcd:0x5 DW_TAG_pointer_type - .long 210 # DW_AT_type - .byte 4 # Abbrev [4] 0xd2:0x7 DW_TAG_base_type - .long .Linfo_string12 # DW_AT_name - .byte 6 # DW_AT_encoding - .byte 1 # DW_AT_byte_size - .byte 0 # End Of Children Mark -.Ldebug_info_end0: - .section .debug_str,"MS",@progbits,1 -.Linfo_string0: - .asciz "clang version 16.0.0" # string offset=0 -.Linfo_string1: - .asciz "main.cpp" # string offset=105 -.Linfo_string2: - .asciz "." # string offset=114 -.Linfo_string3: - .asciz "_ZL6helperi" # string offset=152 -.Linfo_string4: - .asciz "helper" # string offset=164 -.Linfo_string5: - .asciz "int" # string offset=171 -.Linfo_string6: - .asciz "i" # string offset=175 -.Linfo_string7: - .asciz "_Z13may_not_existv" # string offset=177 -.Linfo_string8: - .asciz "may_not_exist" # string offset=196 -.Linfo_string9: - .asciz "main" # string offset=210 -.Linfo_string10: - .asciz "argc" # string offset=215 -.Linfo_string11: - .asciz "argv" # string offset=220 -.Linfo_string12: - .asciz "char" # string offset=225 -.Linfo_string13: - .asciz "j" # string offset=230 + .section .debug_addr,"",@progbits +.Laddr_table_base0: + .quad .Lfunc_begin0 + .quad .Ltmp2 + .quad .Ltmp1 + .quad .Ltmp3 + .quad .Ltmp4 + .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 48 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "main" # External Name + .long 25 # DIE offset + .byte 176 # Attributes: FUNCTION, STATIC + .asciz "helper" # 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 44 # DIE offset + .byte 144 # Attributes: TYPE, STATIC + .asciz "int" # External Name + .long 142 # DIE offset + .byte 144 # Attributes: TYPE, STATIC + .asciz "char" # External Name + .long 0 # End Mark +.LpubTypes_end0: .weak _Z13may_not_existv - .ident "clang version 16.0.0" + .ident "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z13may_not_existv diff --git a/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s b/bolt/test/X86/Inputs/dwarf4-do-no-convert-low-pc-high-pc-to-ranges.s copy from bolt/test/X86/dwarf4-size-0-inlined_subroutine.s copy to bolt/test/X86/Inputs/dwarf4-do-no-convert-low-pc-high-pc-to-ranges.s --- a/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s +++ b/bolt/test/X86/Inputs/dwarf4-do-no-convert-low-pc-high-pc-to-ranges.s @@ -1,27 +1,4 @@ -# REQUIRES: system-linux - -# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o -# RUN: %clang %cflags -dwarf-4 %tmain.o -o %t.exe -Wl,-q -# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --use-old-text -# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt > %t.txt -# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe >> %t.txt -# RUN: cat %t.txt | FileCheck --check-prefix=CHECK %s - -# CHECK: DW_TAG_inlined_subroutine -# CHECK: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,ADDR:]]) -# CHECK: DW_AT_ranges [DW_FORM_sec_offset] -# CHECK-NEXT: [0x[[#ADDR]], 0x[[#ADDR]]) - -# CHECK: DW_TAG_inlined_subroutine -# CHECK-NOT: DW_AT_low_pc [DW_FORM_addr] (0x[[#ADDR]]) - - -# Testing BOLT handles correctly when size of DW_AT_inlined_subroutine is 0. -# In other words DW_AT_high_pc is 0 or DW_AT_low_pc == DW_AT_high_pc. - -# Modified assembly manually to set DW_AT_high_pc to 0. -# clang++ -g2 -gdwarf-4 main.cpp -O1 -S -o main4.s - +# -g2 -gdwarf-4 main.cpp -O1 # static int helper(int i) { # return ++i; # } @@ -34,7 +11,6 @@ # return j; # } - .text .file "main.cpp" .globl main # -- Begin function main @@ -77,6 +53,7 @@ #DEBUG_VALUE: main:j <- $ebx .loc 1 10 3 # main.cpp:10:3 movl %ebx, %eax + .loc 1 10 3 epilogue_begin is_stmt 0 # main.cpp:10:3 popq %rbx .Ltmp4: #DEBUG_VALUE: helper:i <- $eax @@ -376,7 +353,7 @@ .byte 8 # Abbrev [8] 0x93:0x1c DW_TAG_inlined_subroutine .long 42 # DW_AT_abstract_origin .quad .Ltmp2 # DW_AT_low_pc - .long 0 # DW_AT_high_pc Manually modified + .long .Ltmp3-.Ltmp2 # DW_AT_high_pc .byte 1 # DW_AT_call_file .byte 9 # DW_AT_call_line .byte 32 # DW_AT_call_column @@ -408,7 +385,7 @@ .Ldebug_info_end0: .section .debug_str,"MS",@progbits,1 .Linfo_string0: - .asciz "clang version 16.0.0" # string offset=0 + .asciz "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" # string offset=0 .Linfo_string1: .asciz "main.cpp" # string offset=105 .Linfo_string2: @@ -436,7 +413,7 @@ .Linfo_string13: .asciz "j" # string offset=230 .weak _Z13may_not_existv - .ident "clang version 16.0.0" + .ident "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z13may_not_existv diff --git a/bolt/test/X86/Inputs/dwarf4-subprogram-multiple-ranges-main.s b/bolt/test/X86/Inputs/dwarf4-subprogram-multiple-ranges-main.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarf4-subprogram-multiple-ranges-main.s @@ -0,0 +1,331 @@ +# clang++ -fbasic-block-sections=all -ffunction-sections -g2 -gdwarf-4 +# int doStuff(int val) { +# if (val) +# ++val; +# return val; +# } +# +# int main(int argc, const char** argv) { +# return doStuff(argc); +# } + .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 "/subprogramRanges" "main.cpp" + .loc 1 1 0 # main.cpp:1: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 2 7 prologue_end # main.cpp:2:7 + cmpl $0, -4(%rbp) +.Ltmp1: + .loc 1 2 7 is_stmt 0 # main.cpp:2:7 + je _Z7doStuffi.__part.2 + jmp _Z7doStuffi.__part.1 +.LBB_END0_0: + .cfi_endproc + .section .text._Z7doStuffi,"ax",@progbits,unique,1 +_Z7doStuffi.__part.1: # %if.then + .cfi_startproc + .cfi_def_cfa %rbp, 16 + .cfi_offset %rbp, -16 + .loc 1 3 5 is_stmt 1 # main.cpp:3:5 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) + jmp _Z7doStuffi.__part.2 +.LBB_END0_1: + .size _Z7doStuffi.__part.1, .LBB_END0_1-_Z7doStuffi.__part.1 + .cfi_endproc + .section .text._Z7doStuffi,"ax",@progbits,unique,2 +_Z7doStuffi.__part.2: # %if.end + .cfi_startproc + .cfi_def_cfa %rbp, 16 + .cfi_offset %rbp, -16 + .loc 1 4 10 # main.cpp:4:10 + movl -4(%rbp), %eax + .loc 1 4 3 epilogue_begin is_stmt 0 # main.cpp:4:3 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.LBB_END0_2: + .size _Z7doStuffi.__part.2, .LBB_END0_2-_Z7doStuffi.__part.2 + .cfi_endproc + .section .text._Z7doStuffi,"ax",@progbits +.Lfunc_end0: + .size _Z7doStuffi, .Lfunc_end0-_Z7doStuffi + # -- End function + .section .text.main,"ax",@progbits + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin1: + .loc 1 7 0 is_stmt 1 # main.cpp:7: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 + subq $16, %rsp + movl $0, -4(%rbp) + movl %edi, -8(%rbp) + movq %rsi, -16(%rbp) +.Ltmp2: + .loc 1 8 21 prologue_end # main.cpp:8:21 + movl -8(%rbp), %edi + .loc 1 8 13 is_stmt 0 # main.cpp:8:13 + callq _Z7doStuffi + .loc 1 8 5 epilogue_begin # main.cpp:8:5 + addq $16, %rsp + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.LBB_END1_0: + .cfi_endproc +.Lfunc_end1: + .size main, .Lfunc_end1-main + # -- End function + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 85 # DW_AT_ranges + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 85 # DW_AT_ranges + .byte 23 # DW_FORM_sec_offset + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .byte 110 # DW_AT_linkage_name + .byte 14 # DW_FORM_strp + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .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 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 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .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 4 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .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 14 # DW_FORM_strp + .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 5 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .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 6 # 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 7 # 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_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:0x97 DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 33 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir + .quad 0 # DW_AT_low_pc + .long .Ldebug_ranges1 # DW_AT_ranges + .byte 2 # Abbrev [2] 0x2a:0x24 DW_TAG_subprogram + .long .Ldebug_ranges0 # DW_AT_ranges + .byte 1 # DW_AT_frame_base + .byte 86 + .long .Linfo_string3 # DW_AT_linkage_name + .long .Linfo_string4 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 132 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x3f:0xe DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .long .Linfo_string7 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 132 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x4e:0x36 DW_TAG_subprogram + .quad .Lfunc_begin1 # DW_AT_low_pc + .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .long .Linfo_string6 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 132 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x67:0xe DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 120 + .long .Linfo_string8 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 132 # DW_AT_type + .byte 3 # Abbrev [3] 0x75:0xe DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 112 + .long .Linfo_string9 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 139 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 5 # Abbrev [5] 0x84:0x7 DW_TAG_base_type + .long .Linfo_string5 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 6 # Abbrev [6] 0x8b:0x5 DW_TAG_pointer_type + .long 144 # DW_AT_type + .byte 6 # Abbrev [6] 0x90:0x5 DW_TAG_pointer_type + .long 149 # DW_AT_type + .byte 7 # Abbrev [7] 0x95:0x5 DW_TAG_const_type + .long 154 # DW_AT_type + .byte 5 # Abbrev [5] 0x9a:0x7 DW_TAG_base_type + .long .Linfo_string10 # DW_AT_name + .byte 6 # DW_AT_encoding + .byte 1 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + .section .debug_ranges,"",@progbits +.Ldebug_ranges0: + .quad _Z7doStuffi.__part.1 + .quad .LBB_END0_1 + .quad _Z7doStuffi.__part.2 + .quad .LBB_END0_2 + .quad .Lfunc_begin0 + .quad .Lfunc_end0 + .quad 0 + .quad 0 +.Ldebug_ranges1: + .quad _Z7doStuffi.__part.1 + .quad .LBB_END0_1 + .quad _Z7doStuffi.__part.2 + .quad .LBB_END0_2 + .quad .Lfunc_begin0 + .quad .Lfunc_end0 + .quad .Lfunc_begin1 + .quad .Lfunc_end1 + .quad 0 + .quad 0 + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" # string offset=0 +.Linfo_string1: + .asciz "main.cpp" # string offset=105 +.Linfo_string2: + .asciz "/subprogramRanges" # string offset=114 +.Linfo_string3: + .asciz "_Z7doStuffi" # string offset=169 +.Linfo_string4: + .asciz "doStuff" # string offset=181 +.Linfo_string5: + .asciz "int" # string offset=189 +.Linfo_string6: + .asciz "main" # string offset=193 +.Linfo_string7: + .asciz "val" # string offset=198 +.Linfo_string8: + .asciz "argc" # string offset=202 +.Linfo_string9: + .asciz "argv" # string offset=207 +.Linfo_string10: + .asciz "char" # string offset=212 + .ident "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" + .section ".note.GNU-stack","",@progbits + .addrsig + .addrsig_sym _Z7doStuffi + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/Inputs/dwarf4-subprogram-single-gc-ranges-main.s b/bolt/test/X86/Inputs/dwarf4-subprogram-single-gc-ranges-main.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarf4-subprogram-single-gc-ranges-main.s @@ -0,0 +1,310 @@ +# clang++ -ffunction-sections -g2 -gdwarf-4 +# Manually modified to use ranges like what generates sometimes -fbasic-block-sections=all, +# and changed start of range to 0. +# int doStuff(int val) { +# if (val) +# ++val; +# return val; +# } +# +# int main(int argc, const char** argv) { +# return doStuff(argc); +# } + .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 "/subprogramRanges" "main.cpp" + .loc 1 1 0 # main.cpp:1: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 2 7 prologue_end # main.cpp:2:7 + cmpl $0, -4(%rbp) +.Ltmp1: + .loc 1 2 7 is_stmt 0 # main.cpp:2:7 + je .LBB0_2 +# %bb.1: # %if.then +.Ltmp2: + .loc 1 3 5 is_stmt 1 # main.cpp:3:5 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) +.Ltmp3: +.LBB0_2: # %if.end + .loc 1 4 10 # main.cpp:4:10 + movl -4(%rbp), %eax + .loc 1 4 3 epilogue_begin is_stmt 0 # main.cpp:4:3 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp4: +.Lfunc_end0: + .size _Z7doStuffi, .Lfunc_end0-_Z7doStuffi + .cfi_endproc + # -- End function + .section .text.main,"ax",@progbits + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin1: + .loc 1 7 0 is_stmt 1 # main.cpp:7: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 + subq $16, %rsp + movl $0, -4(%rbp) + movl %edi, -8(%rbp) + movq %rsi, -16(%rbp) +.Ltmp5: + .loc 1 8 21 prologue_end # main.cpp:8:21 + movl -8(%rbp), %edi + .loc 1 8 13 is_stmt 0 # main.cpp:8:13 + callq _Z7doStuffi + .loc 1 8 5 epilogue_begin # main.cpp:8:5 + addq $16, %rsp + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp6: +.Lfunc_end1: + .size main, .Lfunc_end1-main + .cfi_endproc + # -- End function + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 85 # DW_AT_ranges + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 85 # DW_AT_ranges + .byte 23 # DW_FORM_sec_offset + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .byte 110 # DW_AT_linkage_name + .byte 14 # DW_FORM_strp + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .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 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 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .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 4 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .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 14 # DW_FORM_strp + .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 5 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .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 6 # 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 7 # 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_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:0x9f DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 33 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir + .quad 0 # DW_AT_low_pc + .long .Ldebug_ranges0 # DW_AT_ranges + .byte 2 # Abbrev [2] 0x2a:0x2c DW_TAG_subprogram + .long .Ldebug_ranges1 # DW_AT_ranges + .byte 1 # DW_AT_frame_base + .byte 86 + .long .Linfo_string3 # DW_AT_linkage_name + .long .Linfo_string4 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 132 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x47:0xe DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .long .Linfo_string7 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 132 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x56:0x36 DW_TAG_subprogram + .quad .Lfunc_begin1 # DW_AT_low_pc + .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .long .Linfo_string6 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 132 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x6f:0xe DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 120 + .long .Linfo_string8 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 132 # DW_AT_type + .byte 3 # Abbrev [3] 0x7d:0xe DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 112 + .long .Linfo_string9 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 144 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 5 # Abbrev [5] 0x8c:0x7 DW_TAG_base_type + .long .Linfo_string5 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 6 # Abbrev [6] 0x93:0x5 DW_TAG_pointer_type + .long 144 # DW_AT_type + .byte 6 # Abbrev [6] 0x98:0x5 DW_TAG_pointer_type + .long 149 # DW_AT_type + .byte 7 # Abbrev [7] 0x9d:0x5 DW_TAG_const_type + .long 154 # DW_AT_type + .byte 5 # Abbrev [5] 0xa2:0x7 DW_TAG_base_type + .long .Linfo_string10 # DW_AT_name + .byte 6 # DW_AT_encoding + .byte 1 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + .section .debug_ranges,"",@progbits +.Ldebug_ranges0: + .quad .Lfunc_begin0 + .quad .Lfunc_end0 + .quad .Lfunc_begin1 + .quad .Lfunc_end1 + .quad 0 + .quad 0 +.Ldebug_ranges1: + .quad 0 + .quad .Lfunc_end0 + .quad 0 + .quad 0 + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" # string offset=0 +.Linfo_string1: + .asciz "main.cpp" # string offset=105 +.Linfo_string2: + .asciz "/subprogramRanges" # string offset=114 +.Linfo_string3: + .asciz "_Z7doStuffi" # string offset=169 +.Linfo_string4: + .asciz "doStuff" # string offset=181 +.Linfo_string5: + .asciz "int" # string offset=189 +.Linfo_string6: + .asciz "main" # string offset=193 +.Linfo_string7: + .asciz "val" # string offset=198 +.Linfo_string8: + .asciz "argc" # string offset=202 +.Linfo_string9: + .asciz "argv" # string offset=207 +.Linfo_string10: + .asciz "char" # string offset=212 + .ident "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" + .section ".note.GNU-stack","",@progbits + .addrsig + .addrsig_sym _Z7doStuffi + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/Inputs/dwarf4-subprogram-single-ranges-main.s b/bolt/test/X86/Inputs/dwarf4-subprogram-single-ranges-main.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarf4-subprogram-single-ranges-main.s @@ -0,0 +1,309 @@ +# clang++ -ffunction-sections -g2 -gdwarf-4 +# Manually modified to use ranges like what generates sometimes -fbasic-block-sections=all +# int doStuff(int val) { +# if (val) +# ++val; +# return val; +# } +# +# int main(int argc, const char** argv) { +# return doStuff(argc); +# } + .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 "/subprogramRanges" "main.cpp" + .loc 1 1 0 # main.cpp:1: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 2 7 prologue_end # main.cpp:2:7 + cmpl $0, -4(%rbp) +.Ltmp1: + .loc 1 2 7 is_stmt 0 # main.cpp:2:7 + je .LBB0_2 +# %bb.1: # %if.then +.Ltmp2: + .loc 1 3 5 is_stmt 1 # main.cpp:3:5 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) +.Ltmp3: +.LBB0_2: # %if.end + .loc 1 4 10 # main.cpp:4:10 + movl -4(%rbp), %eax + .loc 1 4 3 epilogue_begin is_stmt 0 # main.cpp:4:3 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp4: +.Lfunc_end0: + .size _Z7doStuffi, .Lfunc_end0-_Z7doStuffi + .cfi_endproc + # -- End function + .section .text.main,"ax",@progbits + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin1: + .loc 1 7 0 is_stmt 1 # main.cpp:7: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 + subq $16, %rsp + movl $0, -4(%rbp) + movl %edi, -8(%rbp) + movq %rsi, -16(%rbp) +.Ltmp5: + .loc 1 8 21 prologue_end # main.cpp:8:21 + movl -8(%rbp), %edi + .loc 1 8 13 is_stmt 0 # main.cpp:8:13 + callq _Z7doStuffi + .loc 1 8 5 epilogue_begin # main.cpp:8:5 + addq $16, %rsp + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp6: +.Lfunc_end1: + .size main, .Lfunc_end1-main + .cfi_endproc + # -- End function + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 85 # DW_AT_ranges + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 85 # DW_AT_ranges + .byte 23 # DW_FORM_sec_offset + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .byte 110 # DW_AT_linkage_name + .byte 14 # DW_FORM_strp + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .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 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 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .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 4 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .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 14 # DW_FORM_strp + .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 5 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .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 6 # 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 7 # 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_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:0x9f DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 33 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir + .quad 0 # DW_AT_low_pc + .long .Ldebug_ranges0 # DW_AT_ranges + .byte 2 # Abbrev [2] 0x2a:0x2c DW_TAG_subprogram + .long .Ldebug_ranges1 # DW_AT_ranges + .byte 1 # DW_AT_frame_base + .byte 86 + .long .Linfo_string3 # DW_AT_linkage_name + .long .Linfo_string4 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 132 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x47:0xe DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .long .Linfo_string7 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 132 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x56:0x36 DW_TAG_subprogram + .quad .Lfunc_begin1 # DW_AT_low_pc + .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .long .Linfo_string6 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 132 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x6f:0xe DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 120 + .long .Linfo_string8 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 132 # DW_AT_type + .byte 3 # Abbrev [3] 0x7d:0xe DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 112 + .long .Linfo_string9 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 144 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 5 # Abbrev [5] 0x8c:0x7 DW_TAG_base_type + .long .Linfo_string5 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 6 # Abbrev [6] 0x93:0x5 DW_TAG_pointer_type + .long 144 # DW_AT_type + .byte 6 # Abbrev [6] 0x98:0x5 DW_TAG_pointer_type + .long 149 # DW_AT_type + .byte 7 # Abbrev [7] 0x9d:0x5 DW_TAG_const_type + .long 154 # DW_AT_type + .byte 5 # Abbrev [5] 0xa2:0x7 DW_TAG_base_type + .long .Linfo_string10 # DW_AT_name + .byte 6 # DW_AT_encoding + .byte 1 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + .section .debug_ranges,"",@progbits +.Ldebug_ranges0: + .quad .Lfunc_begin0 + .quad .Lfunc_end0 + .quad .Lfunc_begin1 + .quad .Lfunc_end1 + .quad 0 + .quad 0 +.Ldebug_ranges1: + .quad .Lfunc_begin0 + .quad .Lfunc_end0 + .quad 0 + .quad 0 + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" # string offset=0 +.Linfo_string1: + .asciz "main.cpp" # string offset=105 +.Linfo_string2: + .asciz "/subprogramRanges" # string offset=114 +.Linfo_string3: + .asciz "_Z7doStuffi" # string offset=169 +.Linfo_string4: + .asciz "doStuff" # string offset=181 +.Linfo_string5: + .asciz "int" # string offset=189 +.Linfo_string6: + .asciz "main" # string offset=193 +.Linfo_string7: + .asciz "val" # string offset=198 +.Linfo_string8: + .asciz "argc" # string offset=202 +.Linfo_string9: + .asciz "argv" # string offset=207 +.Linfo_string10: + .asciz "char" # string offset=212 + .ident "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" + .section ".note.GNU-stack","",@progbits + .addrsig + .addrsig_sym _Z7doStuffi + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s b/bolt/test/X86/Inputs/dwarf5-do-no-convert-low-pc-high-pc-to-ranges.s copy from bolt/test/X86/dwarf4-size-0-inlined_subroutine.s copy to bolt/test/X86/Inputs/dwarf5-do-no-convert-low-pc-high-pc-to-ranges.s --- a/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s +++ b/bolt/test/X86/Inputs/dwarf5-do-no-convert-low-pc-high-pc-to-ranges.s @@ -1,27 +1,4 @@ -# REQUIRES: system-linux - -# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o -# RUN: %clang %cflags -dwarf-4 %tmain.o -o %t.exe -Wl,-q -# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --use-old-text -# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt > %t.txt -# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe >> %t.txt -# RUN: cat %t.txt | FileCheck --check-prefix=CHECK %s - -# CHECK: DW_TAG_inlined_subroutine -# CHECK: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,ADDR:]]) -# CHECK: DW_AT_ranges [DW_FORM_sec_offset] -# CHECK-NEXT: [0x[[#ADDR]], 0x[[#ADDR]]) - -# CHECK: DW_TAG_inlined_subroutine -# CHECK-NOT: DW_AT_low_pc [DW_FORM_addr] (0x[[#ADDR]]) - - -# Testing BOLT handles correctly when size of DW_AT_inlined_subroutine is 0. -# In other words DW_AT_high_pc is 0 or DW_AT_low_pc == DW_AT_high_pc. - -# Modified assembly manually to set DW_AT_high_pc to 0. -# clang++ -g2 -gdwarf-4 main.cpp -O1 -S -o main4.s - +# -g2 -gdwarf-4 main.cpp -O1 # static int helper(int i) { # return ++i; # } @@ -34,7 +11,6 @@ # return j; # } - .text .file "main.cpp" .globl main # -- Begin function main @@ -42,8 +18,8 @@ .type main,@function main: # @main .Lfunc_begin0: - .file 1 "." "main.cpp" - .loc 1 5 0 # main.cpp:5:0 + .file 0 "." "main.cpp" md5 0x375df0e93c6d762413bfe2708333ecaf + .loc 0 5 0 # main.cpp:5:0 .cfi_startproc # %bb.0: # %entry #DEBUG_VALUE: main:argc <- $edi @@ -53,14 +29,14 @@ .cfi_offset %rbx, -16 movl %edi, %ebx .Ltmp0: - .loc 1 6 7 prologue_end # main.cpp:6:7 + .loc 0 6 7 prologue_end # main.cpp:6:7 cmpq $0, _Z13may_not_existv@GOTPCREL(%rip) je .LBB0_2 .Ltmp1: # %bb.1: # %if.then #DEBUG_VALUE: main:argc <- $ebx #DEBUG_VALUE: main:argv <- $rsi - .loc 1 7 5 # main.cpp:7:5 + .loc 0 7 5 # main.cpp:7:5 callq _Z13may_not_existv@PLT .Ltmp2: #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi @@ -69,14 +45,15 @@ #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi #DEBUG_VALUE: main:j <- 0 #DEBUG_VALUE: helper:i <- $ebx - .loc 1 2 10 # main.cpp:2:10 + .loc 0 2 10 # main.cpp:2:10 incl %ebx .Ltmp3: #DEBUG_VALUE: main:argc <- [DW_OP_LLVM_entry_value 1] $edi #DEBUG_VALUE: helper:i <- $ebx #DEBUG_VALUE: main:j <- $ebx - .loc 1 10 3 # main.cpp:10:3 + .loc 0 10 3 # main.cpp:10:3 movl %ebx, %eax + .loc 0 10 3 epilogue_begin is_stmt 0 # main.cpp:10:3 popq %rbx .Ltmp4: #DEBUG_VALUE: helper:i <- $eax @@ -88,83 +65,105 @@ .size main, .Lfunc_end0-main .cfi_endproc # -- End function - .section .debug_loc,"",@progbits + .section .debug_loclists,"",@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 3 # Offset entry count +.Lloclists_table_base0: + .long .Ldebug_loc0-.Lloclists_table_base0 + .long .Ldebug_loc1-.Lloclists_table_base0 + .long .Ldebug_loc2-.Lloclists_table_base0 .Ldebug_loc0: - .quad .Lfunc_begin0-.Lfunc_begin0 - .quad .Ltmp1-.Lfunc_begin0 - .short 1 # Loc expr size + .byte 4 # DW_LLE_offset_pair + .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset + .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset + .byte 1 # Loc expr size .byte 85 # super-register DW_OP_reg5 - .quad .Ltmp1-.Lfunc_begin0 - .quad .Ltmp3-.Lfunc_begin0 - .short 1 # Loc expr size + .byte 4 # DW_LLE_offset_pair + .uleb128 .Ltmp1-.Lfunc_begin0 # starting offset + .uleb128 .Ltmp3-.Lfunc_begin0 # ending offset + .byte 1 # Loc expr size .byte 83 # super-register DW_OP_reg3 - .quad .Ltmp3-.Lfunc_begin0 - .quad .Lfunc_end0-.Lfunc_begin0 - .short 4 # Loc expr size - .byte 243 # DW_OP_GNU_entry_value + .byte 4 # DW_LLE_offset_pair + .uleb128 .Ltmp3-.Lfunc_begin0 # starting offset + .uleb128 .Lfunc_end0-.Lfunc_begin0 # ending offset + .byte 4 # Loc expr size + .byte 163 # DW_OP_entry_value .byte 1 # 1 .byte 85 # super-register DW_OP_reg5 .byte 159 # DW_OP_stack_value - .quad 0 - .quad 0 + .byte 0 # DW_LLE_end_of_list .Ldebug_loc1: - .quad .Lfunc_begin0-.Lfunc_begin0 - .quad .Ltmp2-.Lfunc_begin0 - .short 1 # Loc expr size + .byte 4 # DW_LLE_offset_pair + .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset + .uleb128 .Ltmp2-.Lfunc_begin0 # ending offset + .byte 1 # Loc expr size .byte 84 # DW_OP_reg4 - .quad .Ltmp2-.Lfunc_begin0 - .quad .Lfunc_end0-.Lfunc_begin0 - .short 4 # Loc expr size - .byte 243 # DW_OP_GNU_entry_value + .byte 4 # DW_LLE_offset_pair + .uleb128 .Ltmp2-.Lfunc_begin0 # starting offset + .uleb128 .Lfunc_end0-.Lfunc_begin0 # ending offset + .byte 4 # Loc expr size + .byte 163 # DW_OP_entry_value .byte 1 # 1 .byte 84 # DW_OP_reg4 .byte 159 # DW_OP_stack_value - .quad 0 - .quad 0 + .byte 0 # DW_LLE_end_of_list .Ldebug_loc2: - .quad .Ltmp2-.Lfunc_begin0 - .quad .Ltmp3-.Lfunc_begin0 - .short 3 # Loc expr size + .byte 4 # DW_LLE_offset_pair + .uleb128 .Ltmp2-.Lfunc_begin0 # starting offset + .uleb128 .Ltmp3-.Lfunc_begin0 # ending offset + .byte 3 # Loc expr size .byte 17 # DW_OP_consts .byte 0 # 0 .byte 159 # DW_OP_stack_value - .quad .Ltmp3-.Lfunc_begin0 - .quad .Ltmp4-.Lfunc_begin0 - .short 1 # Loc expr size + .byte 4 # DW_LLE_offset_pair + .uleb128 .Ltmp3-.Lfunc_begin0 # starting offset + .uleb128 .Ltmp4-.Lfunc_begin0 # ending offset + .byte 1 # Loc expr size .byte 83 # super-register DW_OP_reg3 - .quad .Ltmp4-.Lfunc_begin0 - .quad .Lfunc_end0-.Lfunc_begin0 - .short 1 # Loc expr size + .byte 4 # DW_LLE_offset_pair + .uleb128 .Ltmp4-.Lfunc_begin0 # starting offset + .uleb128 .Lfunc_end0-.Lfunc_begin0 # ending offset + .byte 1 # Loc expr size .byte 80 # super-register DW_OP_reg0 - .quad 0 - .quad 0 + .byte 0 # DW_LLE_end_of_list +.Ldebug_list_header_end0: .section .debug_abbrev,"",@progbits .byte 1 # Abbreviation Code .byte 17 # DW_TAG_compile_unit .byte 1 # DW_CHILDREN_yes .byte 37 # DW_AT_producer - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 .byte 19 # DW_AT_language .byte 5 # DW_FORM_data2 .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 + .byte 114 # DW_AT_str_offsets_base + .byte 23 # DW_FORM_sec_offset .byte 16 # DW_AT_stmt_list .byte 23 # DW_FORM_sec_offset .byte 27 # DW_AT_comp_dir - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 .byte 17 # DW_AT_low_pc - .byte 1 # DW_FORM_addr + .byte 27 # DW_FORM_addrx .byte 18 # DW_AT_high_pc .byte 6 # DW_FORM_data4 + .byte 115 # DW_AT_addr_base + .byte 23 # DW_FORM_sec_offset + .ascii "\214\001" # DW_AT_loclists_base + .byte 23 # DW_FORM_sec_offset .byte 0 # EOM(1) .byte 0 # EOM(2) .byte 2 # Abbreviation Code .byte 46 # DW_TAG_subprogram .byte 1 # DW_CHILDREN_yes .byte 110 # DW_AT_linkage_name - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -172,14 +171,15 @@ .byte 73 # DW_AT_type .byte 19 # DW_FORM_ref4 .byte 32 # DW_AT_inline - .byte 11 # DW_FORM_data1 + .byte 33 # DW_FORM_implicit_const + .byte 1 .byte 0 # EOM(1) .byte 0 # EOM(2) .byte 3 # Abbreviation Code .byte 5 # DW_TAG_formal_parameter .byte 0 # DW_CHILDREN_no .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -192,7 +192,7 @@ .byte 36 # DW_TAG_base_type .byte 0 # DW_CHILDREN_no .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 .byte 62 # DW_AT_encoding .byte 11 # DW_FORM_data1 .byte 11 # DW_AT_byte_size @@ -203,15 +203,15 @@ .byte 46 # DW_TAG_subprogram .byte 1 # DW_CHILDREN_yes .byte 17 # DW_AT_low_pc - .byte 1 # DW_FORM_addr + .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 - .ascii "\227B" # DW_AT_GNU_all_call_sites + .byte 122 # DW_AT_call_all_calls .byte 25 # DW_FORM_flag_present .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -226,9 +226,9 @@ .byte 5 # DW_TAG_formal_parameter .byte 0 # DW_CHILDREN_no .byte 2 # DW_AT_location - .byte 23 # DW_FORM_sec_offset + .byte 34 # DW_FORM_loclistx .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -241,9 +241,9 @@ .byte 52 # DW_TAG_variable .byte 0 # DW_CHILDREN_no .byte 2 # DW_AT_location - .byte 23 # DW_FORM_sec_offset + .byte 34 # DW_FORM_loclistx .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -258,7 +258,7 @@ .byte 49 # DW_AT_abstract_origin .byte 19 # DW_FORM_ref4 .byte 17 # DW_AT_low_pc - .byte 1 # DW_FORM_addr + .byte 27 # DW_FORM_addrx .byte 18 # DW_AT_high_pc .byte 6 # DW_FORM_data4 .byte 88 # DW_AT_call_file @@ -279,21 +279,21 @@ .byte 0 # EOM(1) .byte 0 # EOM(2) .byte 10 # Abbreviation Code - .ascii "\211\202\001" # DW_TAG_GNU_call_site + .byte 72 # DW_TAG_call_site .byte 0 # DW_CHILDREN_no - .byte 49 # DW_AT_abstract_origin + .byte 127 # DW_AT_call_origin .byte 19 # DW_FORM_ref4 - .byte 17 # DW_AT_low_pc - .byte 1 # DW_FORM_addr + .byte 125 # DW_AT_call_return_pc + .byte 27 # DW_FORM_addrx .byte 0 # EOM(1) .byte 0 # EOM(2) .byte 11 # Abbreviation Code .byte 46 # DW_TAG_subprogram .byte 0 # DW_CHILDREN_no .byte 110 # DW_AT_linkage_name - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp + .byte 37 # DW_FORM_strx1 .byte 58 # DW_AT_decl_file .byte 11 # DW_FORM_data1 .byte 59 # DW_AT_decl_line @@ -316,99 +316,108 @@ .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 + .short 5 # DWARF version number + .byte 1 # DWARF Unit Type .byte 8 # Address Size (in bytes) - .byte 1 # Abbrev [1] 0xb:0xcf DW_TAG_compile_unit - .long .Linfo_string0 # DW_AT_producer + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 1 # Abbrev [1] 0xc:0x8b DW_TAG_compile_unit + .byte 0 # DW_AT_producer .short 33 # DW_AT_language - .long .Linfo_string1 # DW_AT_name + .byte 1 # DW_AT_name + .long .Lstr_offsets_base0 # DW_AT_str_offsets_base .long .Lline_table_start0 # DW_AT_stmt_list - .long .Linfo_string2 # DW_AT_comp_dir - .quad .Lfunc_begin0 # DW_AT_low_pc + .byte 2 # DW_AT_comp_dir + .byte 0 # DW_AT_low_pc .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc - .byte 2 # Abbrev [2] 0x2a:0x1c DW_TAG_subprogram - .long .Linfo_string3 # DW_AT_linkage_name - .long .Linfo_string4 # DW_AT_name - .byte 1 # DW_AT_decl_file + .long .Laddr_table_base0 # DW_AT_addr_base + .long .Lloclists_table_base0 # DW_AT_loclists_base + .byte 2 # Abbrev [2] 0x27:0x12 DW_TAG_subprogram + .byte 3 # DW_AT_linkage_name + .byte 4 # DW_AT_name + .byte 0 # DW_AT_decl_file .byte 1 # DW_AT_decl_line - .long 70 # DW_AT_type - .byte 1 # DW_AT_inline - .byte 3 # Abbrev [3] 0x3a:0xb DW_TAG_formal_parameter - .long .Linfo_string6 # DW_AT_name - .byte 1 # DW_AT_decl_file + .long 57 # DW_AT_type + # DW_AT_inline + .byte 3 # Abbrev [3] 0x30:0x8 DW_TAG_formal_parameter + .byte 6 # DW_AT_name + .byte 0 # DW_AT_decl_file .byte 1 # DW_AT_decl_line - .long 70 # DW_AT_type + .long 57 # DW_AT_type .byte 0 # End Of Children Mark - .byte 4 # Abbrev [4] 0x46:0x7 DW_TAG_base_type - .long .Linfo_string5 # DW_AT_name + .byte 4 # Abbrev [4] 0x39:0x4 DW_TAG_base_type + .byte 5 # DW_AT_name .byte 5 # DW_AT_encoding .byte 4 # DW_AT_byte_size - .byte 5 # Abbrev [5] 0x4d:0x70 DW_TAG_subprogram - .quad .Lfunc_begin0 # DW_AT_low_pc + .byte 5 # Abbrev [5] 0x3d:0x46 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 87 - # DW_AT_GNU_all_call_sites - .long .Linfo_string9 # DW_AT_name - .byte 1 # DW_AT_decl_file + # DW_AT_call_all_calls + .byte 9 # DW_AT_name + .byte 0 # DW_AT_decl_file .byte 5 # DW_AT_decl_line - .long 70 # DW_AT_type + .long 57 # DW_AT_type # DW_AT_external - .byte 6 # Abbrev [6] 0x66:0xf DW_TAG_formal_parameter - .long .Ldebug_loc0 # DW_AT_location - .long .Linfo_string10 # DW_AT_name - .byte 1 # DW_AT_decl_file + .byte 6 # Abbrev [6] 0x4c:0x9 DW_TAG_formal_parameter + .byte 0 # DW_AT_location + .byte 10 # DW_AT_name + .byte 0 # DW_AT_decl_file .byte 5 # DW_AT_decl_line - .long 70 # DW_AT_type - .byte 6 # Abbrev [6] 0x75:0xf DW_TAG_formal_parameter - .long .Ldebug_loc1 # DW_AT_location - .long .Linfo_string11 # DW_AT_name - .byte 1 # DW_AT_decl_file + .long 57 # DW_AT_type + .byte 6 # Abbrev [6] 0x55:0x9 DW_TAG_formal_parameter + .byte 1 # DW_AT_location + .byte 11 # DW_AT_name + .byte 0 # DW_AT_decl_file .byte 5 # DW_AT_decl_line - .long 200 # DW_AT_type - .byte 7 # Abbrev [7] 0x84:0xf DW_TAG_variable - .long .Ldebug_loc2 # DW_AT_location - .long .Linfo_string13 # DW_AT_name - .byte 1 # DW_AT_decl_file + .long 136 # DW_AT_type + .byte 7 # Abbrev [7] 0x5e:0x9 DW_TAG_variable + .byte 2 # DW_AT_location + .byte 13 # DW_AT_name + .byte 0 # DW_AT_decl_file .byte 8 # DW_AT_decl_line - .long 70 # DW_AT_type - .byte 8 # Abbrev [8] 0x93:0x1c DW_TAG_inlined_subroutine - .long 42 # DW_AT_abstract_origin - .quad .Ltmp2 # DW_AT_low_pc - .long 0 # DW_AT_high_pc Manually modified - .byte 1 # DW_AT_call_file + .long 57 # DW_AT_type + .byte 8 # Abbrev [8] 0x67:0x15 DW_TAG_inlined_subroutine + .long 39 # DW_AT_abstract_origin + .byte 1 # DW_AT_low_pc + .long .Ltmp3-.Ltmp2 # DW_AT_high_pc + .byte 0 # DW_AT_call_file .byte 9 # DW_AT_call_line .byte 32 # DW_AT_call_column - .byte 9 # Abbrev [9] 0xa7:0x7 DW_TAG_formal_parameter + .byte 9 # Abbrev [9] 0x74:0x7 DW_TAG_formal_parameter .byte 1 # DW_AT_location .byte 83 - .long 58 # DW_AT_abstract_origin + .long 48 # DW_AT_abstract_origin .byte 0 # End Of Children Mark - .byte 10 # Abbrev [10] 0xaf:0xd DW_TAG_GNU_call_site - .long 189 # DW_AT_abstract_origin - .quad .Ltmp2 # DW_AT_low_pc + .byte 10 # Abbrev [10] 0x7c:0x6 DW_TAG_call_site + .long 131 # DW_AT_call_origin + .byte 1 # DW_AT_call_return_pc .byte 0 # End Of Children Mark - .byte 11 # Abbrev [11] 0xbd:0xb DW_TAG_subprogram - .long .Linfo_string7 # DW_AT_linkage_name - .long .Linfo_string8 # DW_AT_name - .byte 1 # DW_AT_decl_file + .byte 11 # Abbrev [11] 0x83:0x5 DW_TAG_subprogram + .byte 7 # DW_AT_linkage_name + .byte 8 # DW_AT_name + .byte 0 # DW_AT_decl_file .byte 4 # DW_AT_decl_line # DW_AT_declaration # DW_AT_external - .byte 12 # Abbrev [12] 0xc8:0x5 DW_TAG_pointer_type - .long 205 # DW_AT_type - .byte 12 # Abbrev [12] 0xcd:0x5 DW_TAG_pointer_type - .long 210 # DW_AT_type - .byte 4 # Abbrev [4] 0xd2:0x7 DW_TAG_base_type - .long .Linfo_string12 # DW_AT_name + .byte 12 # Abbrev [12] 0x88:0x5 DW_TAG_pointer_type + .long 141 # DW_AT_type + .byte 12 # Abbrev [12] 0x8d:0x5 DW_TAG_pointer_type + .long 146 # DW_AT_type + .byte 4 # Abbrev [4] 0x92:0x4 DW_TAG_base_type + .byte 12 # DW_AT_name .byte 6 # DW_AT_encoding .byte 1 # DW_AT_byte_size .byte 0 # End Of Children Mark .Ldebug_info_end0: + .section .debug_str_offsets,"",@progbits + .long 60 # Length of String Offsets Set + .short 5 + .short 0 +.Lstr_offsets_base0: .section .debug_str,"MS",@progbits,1 .Linfo_string0: - .asciz "clang version 16.0.0" # string offset=0 + .asciz "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" # string offset=0 .Linfo_string1: .asciz "main.cpp" # string offset=105 .Linfo_string2: @@ -435,8 +444,33 @@ .asciz "char" # string offset=225 .Linfo_string13: .asciz "j" # string offset=230 + .section .debug_str_offsets,"",@progbits + .long .Linfo_string0 + .long .Linfo_string1 + .long .Linfo_string2 + .long .Linfo_string3 + .long .Linfo_string4 + .long .Linfo_string5 + .long .Linfo_string6 + .long .Linfo_string7 + .long .Linfo_string8 + .long .Linfo_string9 + .long .Linfo_string10 + .long .Linfo_string11 + .long .Linfo_string12 + .long .Linfo_string13 + .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 .Ltmp2 +.Ldebug_addr_end0: .weak _Z13may_not_existv - .ident "clang version 16.0.0" + .ident "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z13may_not_existv diff --git a/bolt/test/X86/Inputs/dwarf5-subprogram-multiple-ranges-main.s b/bolt/test/X86/Inputs/dwarf5-subprogram-multiple-ranges-main.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarf5-subprogram-multiple-ranges-main.s @@ -0,0 +1,385 @@ +# clang++ -fbasic-block-sections=all -ffunction-sections -g2 -gdwarf-5 +# int doStuff(int val) { +# if (val) +# ++val; +# return val; +# } +# +# int main(int argc, const char** argv) { +# return doStuff(argc); +# } + .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 "/subprogramRanges" "main.cpp" md5 0x45fd34ef778739dca24be206894f1d15 + .loc 0 1 0 # main.cpp:1: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 2 7 prologue_end # main.cpp:2:7 + cmpl $0, -4(%rbp) +.Ltmp1: + .loc 0 2 7 is_stmt 0 # main.cpp:2:7 + je _Z7doStuffi.__part.2 + jmp _Z7doStuffi.__part.1 +.LBB_END0_0: + .cfi_endproc + .section .text._Z7doStuffi,"ax",@progbits,unique,1 +_Z7doStuffi.__part.1: # %if.then + .cfi_startproc + .cfi_def_cfa %rbp, 16 + .cfi_offset %rbp, -16 + .loc 0 3 5 is_stmt 1 # main.cpp:3:5 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) + jmp _Z7doStuffi.__part.2 +.LBB_END0_1: + .size _Z7doStuffi.__part.1, .LBB_END0_1-_Z7doStuffi.__part.1 + .cfi_endproc + .section .text._Z7doStuffi,"ax",@progbits,unique,2 +_Z7doStuffi.__part.2: # %if.end + .cfi_startproc + .cfi_def_cfa %rbp, 16 + .cfi_offset %rbp, -16 + .loc 0 4 10 # main.cpp:4:10 + movl -4(%rbp), %eax + .loc 0 4 3 epilogue_begin is_stmt 0 # main.cpp:4:3 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.LBB_END0_2: + .size _Z7doStuffi.__part.2, .LBB_END0_2-_Z7doStuffi.__part.2 + .cfi_endproc + .section .text._Z7doStuffi,"ax",@progbits +.Lfunc_end0: + .size _Z7doStuffi, .Lfunc_end0-_Z7doStuffi + # -- End function + .section .text.main,"ax",@progbits + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin1: + .loc 0 7 0 is_stmt 1 # main.cpp:7: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 + subq $16, %rsp + movl $0, -4(%rbp) + movl %edi, -8(%rbp) + movq %rsi, -16(%rbp) +.Ltmp2: + .loc 0 8 21 prologue_end # main.cpp:8:21 + movl -8(%rbp), %edi + .loc 0 8 13 is_stmt 0 # main.cpp:8:13 + callq _Z7doStuffi + .loc 0 8 5 epilogue_begin # main.cpp:8:5 + addq $16, %rsp + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.LBB_END1_0: + .cfi_endproc +.Lfunc_end1: + .size main, .Lfunc_end1-main + # -- End function + .section .debug_abbrev,"",@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 114 # DW_AT_str_offsets_base + .byte 23 # DW_FORM_sec_offset + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .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 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 85 # DW_AT_ranges + .byte 35 # DW_FORM_rnglistx + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .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 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 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 4 # 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 5 # 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 6 # 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 7 # 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_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 5 # DWARF version number + .byte 1 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 1 # Abbrev [1] 0xc:0x75 DW_TAG_compile_unit + .byte 0 # DW_AT_producer + .short 33 # DW_AT_language + .byte 1 # DW_AT_name + .long .Lstr_offsets_base0 # DW_AT_str_offsets_base + .long .Lline_table_start0 # DW_AT_stmt_list + .byte 2 # DW_AT_comp_dir + .quad 0 # DW_AT_low_pc + .byte 1 # DW_AT_ranges + .long .Laddr_table_base0 # DW_AT_addr_base + .long .Lrnglists_table_base0 # DW_AT_rnglists_base + .byte 2 # Abbrev [2] 0x2b:0x18 DW_TAG_subprogram + .byte 0 # DW_AT_ranges + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 3 # DW_AT_linkage_name + .byte 4 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 105 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x37:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .byte 7 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 105 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x43:0x26 DW_TAG_subprogram + .byte 3 # DW_AT_low_pc + .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 6 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 105 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x52:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 120 + .byte 8 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 105 # DW_AT_type + .byte 3 # Abbrev [3] 0x5d:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 112 + .byte 9 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 109 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 5 # Abbrev [5] 0x69:0x4 DW_TAG_base_type + .byte 5 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 6 # Abbrev [6] 0x6d:0x5 DW_TAG_pointer_type + .long 114 # DW_AT_type + .byte 6 # Abbrev [6] 0x72:0x5 DW_TAG_pointer_type + .long 119 # DW_AT_type + .byte 7 # Abbrev [7] 0x77:0x5 DW_TAG_const_type + .long 124 # DW_AT_type + .byte 5 # Abbrev [5] 0x7c:0x4 DW_TAG_base_type + .byte 10 # DW_AT_name + .byte 6 # DW_AT_encoding + .byte 1 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.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 2 # Offset entry count +.Lrnglists_table_base0: + .long .Ldebug_ranges0-.Lrnglists_table_base0 + .long .Ldebug_ranges1-.Lrnglists_table_base0 +.Ldebug_ranges0: + .byte 3 # DW_RLE_startx_length + .byte 0 # start index + .uleb128 .LBB_END0_1-_Z7doStuffi.__part.1 # length + .byte 3 # DW_RLE_startx_length + .byte 1 # start index + .uleb128 .LBB_END0_2-_Z7doStuffi.__part.2 # length + .byte 3 # DW_RLE_startx_length + .byte 2 # start index + .uleb128 .Lfunc_end0-.Lfunc_begin0 # length + .byte 0 # DW_RLE_end_of_list +.Ldebug_ranges1: + .byte 3 # DW_RLE_startx_length + .byte 0 # start index + .uleb128 .LBB_END0_1-_Z7doStuffi.__part.1 # length + .byte 3 # DW_RLE_startx_length + .byte 1 # start index + .uleb128 .LBB_END0_2-_Z7doStuffi.__part.2 # length + .byte 3 # DW_RLE_startx_length + .byte 2 # start index + .uleb128 .Lfunc_end0-.Lfunc_begin0 # length + .byte 3 # DW_RLE_startx_length + .byte 3 # start index + .uleb128 .Lfunc_end1-.Lfunc_begin1 # length + .byte 0 # DW_RLE_end_of_list +.Ldebug_list_header_end0: + .section .debug_str_offsets,"",@progbits + .long 48 # Length of String Offsets Set + .short 5 + .short 0 +.Lstr_offsets_base0: + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" # string offset=0 +.Linfo_string1: + .asciz "main.cpp" # string offset=105 +.Linfo_string2: + .asciz "/subprogramRanges" # string offset=114 +.Linfo_string3: + .asciz "_Z7doStuffi" # string offset=169 +.Linfo_string4: + .asciz "doStuff" # string offset=181 +.Linfo_string5: + .asciz "int" # string offset=189 +.Linfo_string6: + .asciz "main" # string offset=193 +.Linfo_string7: + .asciz "val" # string offset=198 +.Linfo_string8: + .asciz "argc" # string offset=202 +.Linfo_string9: + .asciz "argv" # string offset=207 +.Linfo_string10: + .asciz "char" # string offset=212 + .section .debug_str_offsets,"",@progbits + .long .Linfo_string0 + .long .Linfo_string1 + .long .Linfo_string2 + .long .Linfo_string3 + .long .Linfo_string4 + .long .Linfo_string5 + .long .Linfo_string6 + .long .Linfo_string7 + .long .Linfo_string8 + .long .Linfo_string9 + .long .Linfo_string10 + .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 _Z7doStuffi.__part.1 + .quad _Z7doStuffi.__part.2 + .quad .Lfunc_begin0 + .quad .Lfunc_begin1 +.Ldebug_addr_end0: + .ident "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" + .section ".note.GNU-stack","",@progbits + .addrsig + .addrsig_sym _Z7doStuffi + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/Inputs/dwarf5-subprogram-single-gc-ranges-main.s b/bolt/test/X86/Inputs/dwarf5-subprogram-single-gc-ranges-main.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarf5-subprogram-single-gc-ranges-main.s @@ -0,0 +1,359 @@ +# clang++ -ffunction-sections -g2 -gdwarf-5 +# Manually modified to use ranges like what generates sometimes -fbasic-block-sections=all, +# and changed start of range to 0. +# int doStuff(int val) { +# if (val) +# ++val; +# return val; +# } +# +# int main(int argc, const char** argv) { +# return doStuff(argc); +# } + .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 "/subprogramRanges" "main.cpp" md5 0x45fd34ef778739dca24be206894f1d15 + .loc 0 1 0 # main.cpp:1: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 2 7 prologue_end # main.cpp:2:7 + cmpl $0, -4(%rbp) +.Ltmp1: + .loc 0 2 7 is_stmt 0 # main.cpp:2:7 + je .LBB0_2 +# %bb.1: # %if.then +.Ltmp2: + .loc 0 3 5 is_stmt 1 # main.cpp:3:5 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) +.Ltmp3: +.LBB0_2: # %if.end + .loc 0 4 10 # main.cpp:4:10 + movl -4(%rbp), %eax + .loc 0 4 3 epilogue_begin is_stmt 0 # main.cpp:4:3 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp4: +.Lfunc_end0: + .size _Z7doStuffi, .Lfunc_end0-_Z7doStuffi + .cfi_endproc + # -- End function + .section .text.main,"ax",@progbits + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin1: + .loc 0 7 0 is_stmt 1 # main.cpp:7: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 + subq $16, %rsp + movl $0, -4(%rbp) + movl %edi, -8(%rbp) + movq %rsi, -16(%rbp) +.Ltmp5: + .loc 0 8 21 prologue_end # main.cpp:8:21 + movl -8(%rbp), %edi + .loc 0 8 13 is_stmt 0 # main.cpp:8:13 + callq _Z7doStuffi + .loc 0 8 5 epilogue_begin # main.cpp:8:5 + addq $16, %rsp + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp6: +.Lfunc_end1: + .size main, .Lfunc_end1-main + .cfi_endproc + # -- End function + .section .debug_abbrev,"",@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 114 # DW_AT_str_offsets_base + .byte 23 # DW_FORM_sec_offset + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .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 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 85 # DW_AT_ranges + .byte 35 # DW_FORM_rnglistx + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .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 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 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 4 # 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 5 # 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 6 # 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 7 # 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_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 5 # DWARF version number + .byte 1 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 1 # Abbrev [1] 0xc:0x79 DW_TAG_compile_unit + .byte 0 # DW_AT_producer + .short 33 # DW_AT_language + .byte 1 # DW_AT_name + .long .Lstr_offsets_base0 # DW_AT_str_offsets_base + .long .Lline_table_start0 # DW_AT_stmt_list + .byte 2 # DW_AT_comp_dir + .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 + .byte 2 # Abbrev [2] 0x2b:0x1c DW_TAG_subprogram + .byte 1 # DW_AT_ranges + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 3 # DW_AT_linkage_name + .byte 4 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 109 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x3b:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .byte 7 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 109 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x47:0x26 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 + .byte 6 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 109 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x56:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 120 + .byte 8 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 109 # DW_AT_type + .byte 3 # Abbrev [3] 0x61:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 112 + .byte 9 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 105 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 5 # Abbrev [5] 0x6d:0x4 DW_TAG_base_type + .byte 5 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 6 # Abbrev [6] 0x71:0x5 DW_TAG_pointer_type + .long 114 # DW_AT_type + .byte 6 # Abbrev [6] 0x76:0x5 DW_TAG_pointer_type + .long 119 # DW_AT_type + .byte 7 # Abbrev [7] 0x7b:0x5 DW_TAG_const_type + .long 124 # DW_AT_type + .byte 5 # Abbrev [5] 0x80:0x4 DW_TAG_base_type + .byte 10 # DW_AT_name + .byte 6 # DW_AT_encoding + .byte 1 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.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_ranges0-.Lrnglists_table_base0 + .long .Ldebug_ranges1-.Lrnglists_table_base0 +.Ldebug_ranges0: + .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 0 # DW_RLE_end_of_list +.Ldebug_ranges1: + .byte 3 # DW_RLE_startx_length + .byte 2 # start index + .uleb128 .Lfunc_end0-.Lfunc_begin0 # length + .byte 0 # DW_RLE_end_of_list +.Ldebug_list_header_end0: + .section .debug_str_offsets,"",@progbits + .long 48 # Length of String Offsets Set + .short 5 + .short 0 +.Lstr_offsets_base0: + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" # string offset=0 +.Linfo_string1: + .asciz "main.cpp" # string offset=105 +.Linfo_string2: + .asciz "/subprogramRanges" # string offset=114 +.Linfo_string3: + .asciz "_Z7doStuffi" # string offset=169 +.Linfo_string4: + .asciz "doStuff" # string offset=181 +.Linfo_string5: + .asciz "int" # string offset=189 +.Linfo_string6: + .asciz "main" # string offset=193 +.Linfo_string7: + .asciz "val" # string offset=198 +.Linfo_string8: + .asciz "argc" # string offset=202 +.Linfo_string9: + .asciz "argv" # string offset=207 +.Linfo_string10: + .asciz "char" # string offset=212 + .section .debug_str_offsets,"",@progbits + .long .Linfo_string0 + .long .Linfo_string1 + .long .Linfo_string2 + .long .Linfo_string3 + .long .Linfo_string4 + .long .Linfo_string5 + .long .Linfo_string6 + .long .Linfo_string7 + .long .Linfo_string8 + .long .Linfo_string9 + .long .Linfo_string10 + .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 0x0 +.Ldebug_addr_end0: + .ident "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" + .section ".note.GNU-stack","",@progbits + .addrsig + .addrsig_sym _Z7doStuffi + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/Inputs/dwarf5-subprogram-single-ranges-main.s b/bolt/test/X86/Inputs/dwarf5-subprogram-single-ranges-main.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarf5-subprogram-single-ranges-main.s @@ -0,0 +1,357 @@ +# clang++ -ffunction-sections -g2 -gdwarf-5 +# Manually modified to use ranges like what generates sometimes -fbasic-block-sections=all +# int doStuff(int val) { +# if (val) +# ++val; +# return val; +# } +# +# int main(int argc, const char** argv) { +# return doStuff(argc); +# } + .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 "/subprogramRanges" "main.cpp" md5 0x45fd34ef778739dca24be206894f1d15 + .loc 0 1 0 # main.cpp:1: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 2 7 prologue_end # main.cpp:2:7 + cmpl $0, -4(%rbp) +.Ltmp1: + .loc 0 2 7 is_stmt 0 # main.cpp:2:7 + je .LBB0_2 +# %bb.1: # %if.then +.Ltmp2: + .loc 0 3 5 is_stmt 1 # main.cpp:3:5 + movl -4(%rbp), %eax + addl $1, %eax + movl %eax, -4(%rbp) +.Ltmp3: +.LBB0_2: # %if.end + .loc 0 4 10 # main.cpp:4:10 + movl -4(%rbp), %eax + .loc 0 4 3 epilogue_begin is_stmt 0 # main.cpp:4:3 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp4: +.Lfunc_end0: + .size _Z7doStuffi, .Lfunc_end0-_Z7doStuffi + .cfi_endproc + # -- End function + .section .text.main,"ax",@progbits + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin1: + .loc 0 7 0 is_stmt 1 # main.cpp:7: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 + subq $16, %rsp + movl $0, -4(%rbp) + movl %edi, -8(%rbp) + movq %rsi, -16(%rbp) +.Ltmp5: + .loc 0 8 21 prologue_end # main.cpp:8:21 + movl -8(%rbp), %edi + .loc 0 8 13 is_stmt 0 # main.cpp:8:13 + callq _Z7doStuffi + .loc 0 8 5 epilogue_begin # main.cpp:8:5 + addq $16, %rsp + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp6: +.Lfunc_end1: + .size main, .Lfunc_end1-main + .cfi_endproc + # -- End function + .section .debug_abbrev,"",@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 114 # DW_AT_str_offsets_base + .byte 23 # DW_FORM_sec_offset + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .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 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 85 # DW_AT_ranges + .byte 35 # DW_FORM_rnglistx + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .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 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 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 4 # 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 5 # 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 6 # 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 7 # 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_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 5 # DWARF version number + .byte 1 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 1 # Abbrev [1] 0xc:0x79 DW_TAG_compile_unit + .byte 0 # DW_AT_producer + .short 33 # DW_AT_language + .byte 1 # DW_AT_name + .long .Lstr_offsets_base0 # DW_AT_str_offsets_base + .long .Lline_table_start0 # DW_AT_stmt_list + .byte 2 # DW_AT_comp_dir + .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 + .byte 2 # Abbrev [2] 0x2b:0x1c DW_TAG_subprogram + .byte 1 # DW_AT_ranges + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 3 # DW_AT_linkage_name + .byte 4 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 109 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x3b:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .byte 7 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .long 109 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x47:0x26 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 + .byte 6 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 109 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x56:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 120 + .byte 8 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 109 # DW_AT_type + .byte 3 # Abbrev [3] 0x61:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 112 + .byte 9 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 7 # DW_AT_decl_line + .long 105 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 5 # Abbrev [5] 0x6d:0x4 DW_TAG_base_type + .byte 5 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 6 # Abbrev [6] 0x71:0x5 DW_TAG_pointer_type + .long 114 # DW_AT_type + .byte 6 # Abbrev [6] 0x76:0x5 DW_TAG_pointer_type + .long 119 # DW_AT_type + .byte 7 # Abbrev [7] 0x7b:0x5 DW_TAG_const_type + .long 124 # DW_AT_type + .byte 5 # Abbrev [5] 0x80:0x4 DW_TAG_base_type + .byte 10 # DW_AT_name + .byte 6 # DW_AT_encoding + .byte 1 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.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_ranges0-.Lrnglists_table_base0 + .long .Ldebug_ranges1-.Lrnglists_table_base0 +.Ldebug_ranges0: + .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 0 # DW_RLE_end_of_list +.Ldebug_ranges1: + .byte 3 # DW_RLE_startx_length + .byte 0 # start index + .uleb128 .Lfunc_end0-.Lfunc_begin0 # length + .byte 0 # DW_RLE_end_of_list +.Ldebug_list_header_end0: + .section .debug_str_offsets,"",@progbits + .long 48 # Length of String Offsets Set + .short 5 + .short 0 +.Lstr_offsets_base0: + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" # string offset=0 +.Linfo_string1: + .asciz "main.cpp" # string offset=105 +.Linfo_string2: + .asciz "/subprogramRanges" # string offset=114 +.Linfo_string3: + .asciz "_Z7doStuffi" # string offset=169 +.Linfo_string4: + .asciz "doStuff" # string offset=181 +.Linfo_string5: + .asciz "int" # string offset=189 +.Linfo_string6: + .asciz "main" # string offset=193 +.Linfo_string7: + .asciz "val" # string offset=198 +.Linfo_string8: + .asciz "argc" # string offset=202 +.Linfo_string9: + .asciz "argv" # string offset=207 +.Linfo_string10: + .asciz "char" # string offset=212 + .section .debug_str_offsets,"",@progbits + .long .Linfo_string0 + .long .Linfo_string1 + .long .Linfo_string2 + .long .Linfo_string3 + .long .Linfo_string4 + .long .Linfo_string5 + .long .Linfo_string6 + .long .Linfo_string7 + .long .Linfo_string8 + .long .Linfo_string9 + .long .Linfo_string10 + .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 +.Ldebug_addr_end0: + .ident "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 640e07c49037cca41a1bfbeb916b569d8c950aea)" + .section ".note.GNU-stack","",@progbits + .addrsig + .addrsig_sym _Z7doStuffi + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/debug-fission-single.s b/bolt/test/X86/debug-fission-single-convert.s copy from bolt/test/X86/debug-fission-single.s copy to bolt/test/X86/debug-fission-single-convert.s --- a/bolt/test/X86/debug-fission-single.s +++ b/bolt/test/X86/debug-fission-single-convert.s @@ -5,8 +5,8 @@ # RUN: llvm-mc -g \ # RUN: --filetype=obj \ # RUN: --triple x86_64-unknown-unknown \ -# RUN: --split-dwarf-file=debug-fission-simple.dwo \ -# RUN: %p/Inputs/debug-fission-simple.s \ +# RUN: --split-dwarf-file=debug-fission-simple-convert.dwo \ +# RUN: %p/Inputs/debug-fission-simple-convert.s \ # RUN: -o %t.o # RUN: %clangxx %cxxflags -no-pie -g \ # RUN: -Wl,--gc-sections,-q,-nostdlib \ @@ -18,9 +18,10 @@ # RUN: --reorder-blocks=reverse \ # RUN: --update-debug-sections \ # RUN: --dwarf-output-path=%T \ +# RUN: --always-convert-to-ranges=true \ # RUN: -o %t.bolt.1.exe 2>&1 | FileCheck %s # RUN: llvm-dwarfdump --show-form --verbose --debug-ranges %t.bolt.1.exe &> %tAddrIndexTest -# RUN: not llvm-dwarfdump --show-form --verbose --debug-info %T/debug-fission-simple.dwo0.dwo >> %tAddrIndexTest +# RUN: not llvm-dwarfdump --show-form --verbose --debug-info %T/debug-fission-simple-convert.dwo0.dwo >> %tAddrIndexTest # RUN: cat %tAddrIndexTest | FileCheck %s --check-prefix=CHECK-DWO-DWO # RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt.1.exe | FileCheck %s --check-prefix=CHECK-ADDR-SEC @@ -43,7 +44,8 @@ # CHECK-ADDR-SEC: 0x00000000: Addrs: [ # CHECK-ADDR-SEC: 0x0000000000601000 -# RUN: llvm-bolt %t.exe --reorder-blocks=reverse --update-debug-sections --dwarf-output-path=%T -o %t.bolt.2.exe --write-dwp=true +# RUN: llvm-bolt %t.exe --reorder-blocks=reverse --update-debug-sections --dwarf-output-path=%T -o %t.bolt.2.exe --write-dwp=true \ +# RUN: --always-convert-to-ranges=true # RUN: not llvm-dwarfdump --show-form --verbose --debug-info %t.bolt.2.exe.dwp &> %tAddrIndexTestDwp # RUN: cat %tAddrIndexTestDwp | FileCheck %s --check-prefix=CHECK-DWP-DEBUG diff --git a/bolt/test/X86/debug-fission-single.s b/bolt/test/X86/debug-fission-single.s --- a/bolt/test/X86/debug-fission-single.s +++ b/bolt/test/X86/debug-fission-single.s @@ -20,7 +20,7 @@ # RUN: --dwarf-output-path=%T \ # RUN: -o %t.bolt.1.exe 2>&1 | FileCheck %s # RUN: llvm-dwarfdump --show-form --verbose --debug-ranges %t.bolt.1.exe &> %tAddrIndexTest -# RUN: not llvm-dwarfdump --show-form --verbose --debug-info %T/debug-fission-simple.dwo0.dwo >> %tAddrIndexTest +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %T/debug-fission-simple.dwo0.dwo >> %tAddrIndexTest # RUN: cat %tAddrIndexTest | FileCheck %s --check-prefix=CHECK-DWO-DWO # RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt.1.exe | FileCheck %s --check-prefix=CHECK-ADDR-SEC @@ -28,23 +28,22 @@ # CHECK-DWO-DWO: 00000010 # CHECK-DWO-DWO: 00000010 -# CHECK-DWO-DWO: 00000050 # CHECK-DWO-DWO: DW_TAG_subprogram -# CHECK-DWO-DWO-NEXT: DW_AT_low_pc [DW_FORM_GNU_addr_index] (indexed (00000000) -# CHECK-DWO-DWO-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000 +# CHECK-DWO-DWO-NEXT: DW_AT_low_pc [DW_FORM_GNU_addr_index] (indexed (00000001) +# CHECK-DWO-DWO-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x00000031) # CHECK-DWO-DWO: DW_TAG_subprogram -# CHECK-DWO-DWO-NEXT: DW_AT_low_pc [DW_FORM_GNU_addr_index] (indexed (00000000) -# CHECK-DWO-DWO-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000020 +# CHECK-DWO-DWO-NEXT: DW_AT_low_pc [DW_FORM_GNU_addr_index] (indexed (00000002) +# CHECK-DWO-DWO-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x00000012) # CHECK-DWO-DWO: DW_TAG_subprogram -# CHECK-DWO-DWO-NEXT: DW_AT_low_pc [DW_FORM_GNU_addr_index] (indexed (00000000) -# CHECK-DWO-DWO-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000040 +# CHECK-DWO-DWO-NEXT: DW_AT_low_pc [DW_FORM_GNU_addr_index] (indexed (00000003) +# CHECK-DWO-DWO-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x0000001d) # CHECK-ADDR-SEC: .debug_addr contents: # CHECK-ADDR-SEC: 0x00000000: Addrs: [ # CHECK-ADDR-SEC: 0x0000000000601000 # RUN: llvm-bolt %t.exe --reorder-blocks=reverse --update-debug-sections --dwarf-output-path=%T -o %t.bolt.2.exe --write-dwp=true -# RUN: not llvm-dwarfdump --show-form --verbose --debug-info %t.bolt.2.exe.dwp &> %tAddrIndexTestDwp +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt.2.exe.dwp &> %tAddrIndexTestDwp # RUN: cat %tAddrIndexTestDwp | FileCheck %s --check-prefix=CHECK-DWP-DEBUG # CHECK-DWP-DEBUG: DW_TAG_compile_unit [1] * diff --git a/bolt/test/X86/dwarf4-df-do-no-convert-low-pc-high-pc-to-ranges.test b/bolt/test/X86/dwarf4-df-do-no-convert-low-pc-high-pc-to-ranges.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf4-df-do-no-convert-low-pc-high-pc-to-ranges.test @@ -0,0 +1,24 @@ +; REQUIRES: system-linux + +; RUN: rm -rf %t +; RUN: mkdir %t +; RUN: cd %t + +; RUN: llvm-mc -split-dwarf-file=main.dwo -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-df-do-no-convert-low-pc-high-pc-to-ranges.s -o main.o +; RUN: %clang %cflags -gsplit-dwarf=split main.o -o main.exe -Wl,-q +; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections +; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.dwo | FileCheck --check-prefix=PRECHECK %s +; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.dwo.dwo | FileCheck --check-prefix=POSTCHECK %s + +; This test checks that we do not convert low_pc/high_pc to ranges for DW_TAG_inlined_subroutine, +; when there is only one output range entry. + +; PRECHECK: DW_TAG_inlined_subroutine +; PRECHECK: DW_AT_abstract_origin +; PRECHECK: DW_AT_low_pc [DW_FORM_GNU_addr_index] (indexed (00000001) +; PRECHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000002) + +; POSTCHECK: DW_TAG_inlined_subroutine +; POSTCHECK: DW_AT_abstract_origin +; POSTCHECK: DW_AT_low_pc [DW_FORM_GNU_addr_index] (indexed (00000003) +; POSTCHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000002) diff --git a/bolt/test/X86/dwarf4-df-dualcu-loclist.test b/bolt/test/X86/dwarf4-df-dualcu-loclist.test --- a/bolt/test/X86/dwarf4-df-dualcu-loclist.test +++ b/bolt/test/X86/dwarf4-df-dualcu-loclist.test @@ -8,9 +8,9 @@ ; RUN: %clang %cflags -gdwarf-5 -O2 -gsplit-dwarf=split main.o helper.o -o main.exe ; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections ; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.dwo | FileCheck -check-prefix=PRE-BOLT-DWO-MAIN %s -; RUN: not llvm-dwarfdump --show-form --verbose --debug-info main.dwo.dwo | FileCheck -check-prefix=BOLT-DWO-MAIN %s +; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.dwo.dwo | FileCheck -check-prefix=BOLT-DWO-MAIN %s ; RUN: llvm-dwarfdump --show-form --verbose --debug-info helper.dwo | FileCheck -check-prefix=PRE-BOLT-DWO-HELPER %s -; RUN: not llvm-dwarfdump --show-form --verbose --debug-info helper.dwo.dwo | FileCheck -check-prefix=BOLT-DWO-HELPER %s +; RUN: llvm-dwarfdump --show-form --verbose --debug-info helper.dwo.dwo | FileCheck -check-prefix=BOLT-DWO-HELPER %s ; Testing dwarf4 split dwarf for two CUs. Making sure DW_AT_location [DW_FORM_sec_offset] is updated correctly. @@ -27,12 +27,12 @@ ; BOLT-DWO-MAIN: version = 0x0004 ; BOLT-DWO-MAIN: DW_TAG_formal_parameter [10] ; BOLT-DWO-MAIN-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000010: -; BOLT-DWO-MAIN-NEXT: DW_LLE_startx_length (0x0000000000000002, 0x0000000000000014) -; BOLT-DWO-MAIN-NEXT: DW_LLE_startx_length (0x0000000000000003, 0x0000000000000005) +; BOLT-DWO-MAIN-NEXT: DW_LLE_startx_length (0x0000000000000003, 0x0000000000000014) +; BOLT-DWO-MAIN-NEXT: DW_LLE_startx_length (0x0000000000000004, 0x0000000000000005) ; BOLT-DWO-MAIN: DW_TAG_formal_parameter [10] ; BOLT-DWO-MAIN-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000026: -; BOLT-DWO-MAIN-NEXT: DW_LLE_startx_length (0x0000000000000002, 0x000000000000000c) -; BOLT-DWO-MAIN-NEXT: DW_LLE_startx_length (0x0000000000000004, 0x000000000000000d) +; BOLT-DWO-MAIN-NEXT: DW_LLE_startx_length (0x0000000000000003, 0x000000000000000c) +; BOLT-DWO-MAIN-NEXT: DW_LLE_startx_length (0x0000000000000005, 0x000000000000000d) ; PRE-BOLT-DWO-HELPER: version = 0x0004 diff --git a/bolt/test/X86/dwarf4-df-dualcu.test b/bolt/test/X86/dwarf4-df-dualcu.test --- a/bolt/test/X86/dwarf4-df-dualcu.test +++ b/bolt/test/X86/dwarf4-df-dualcu.test @@ -6,7 +6,7 @@ ; RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-df-dualcu-helper.s \ ; RUN: -split-dwarf-file=helper.dwo -o helper.o ; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o helper.o -o main.exe -; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections +; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --always-convert-to-ranges ; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe | FileCheck -check-prefix=PRE-BOLT %s ; RUN: llvm-dwarfdump --show-form --verbose --debug-ranges main.exe.bolt &> %t/foo.txt ; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe.bolt >> %t/foo.txt diff --git a/bolt/test/X86/dwarf4-do-no-convert-low-pc-high-pc-to-ranges.test b/bolt/test/X86/dwarf4-do-no-convert-low-pc-high-pc-to-ranges.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf4-do-no-convert-low-pc-high-pc-to-ranges.test @@ -0,0 +1,20 @@ +# REQUIRES: system-linux + +# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-do-no-convert-low-pc-high-pc-to-ranges.s -o %t1.o +# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q +# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s + +# This test checks that we do not convert low_pc/high_pc to ranges for DW_TAG_inlined_subroutine, +# when there is only one output range entry. + +# PRECHECK: DW_TAG_inlined_subroutine +# PRECHECK: DW_AT_abstract_origin +# PRECHECK: DW_AT_low_pc +# PRECHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000002) + +# POSTCHECK: DW_TAG_inlined_subroutine +# POSTCHECK: DW_AT_abstract_origin +# POSTCHECK: DW_AT_low_pc +# POSTCHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000002) diff --git a/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s b/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s --- a/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s +++ b/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s @@ -9,11 +9,11 @@ # CHECK: DW_TAG_inlined_subroutine # CHECK: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,ADDR:]]) -# CHECK: DW_AT_ranges [DW_FORM_sec_offset] -# CHECK-NEXT: [0x[[#ADDR]], 0x[[#ADDR]]) +# CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000000) # CHECK: DW_TAG_inlined_subroutine # CHECK-NOT: DW_AT_low_pc [DW_FORM_addr] (0x[[#ADDR]]) +# CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000000) # Testing BOLT handles correctly when size of DW_AT_inlined_subroutine is 0. diff --git a/bolt/test/X86/dwarf4-subprogram-multiple-ranges.test b/bolt/test/X86/dwarf4-subprogram-multiple-ranges.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf4-subprogram-multiple-ranges.test @@ -0,0 +1,23 @@ +# REQUIRES: system-linux + +# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-subprogram-multiple-ranges-main.s -o %t1.o +# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q +# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections +# RUN: llvm-objdump %t.bolt --disassemble > %t1.txt +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t1.txt +# RUN: cat %t1.txt | FileCheck --check-prefix=POSTCHECK %s + +# This test checks BOLT correctly handles DW_TAG_subprogram with Ranges with multiple entries. + +# POSTCHECK: _Z7doStuffi>: +# POSTCHECK: [[#%.6x,ADDR:]] +# POSTCHECK: _Z7doStuffi.__part.1>: +# POSTCHECK-NEXT: [[#%.6x,ADDR1:]] +# POSTCHECK: _Z7doStuffi.__part.2>: +# POSTCHECK-NEXT: [[#%.6x,ADDR2:]] + +# POSTCHECK: DW_TAG_subprogram +# POSTCHECK-NEXT: DW_AT_ranges +# POSTCHECK-NEXT: [0x0000000000[[#ADDR1]], 0x0000000000[[#ADDR1 + 0xb]]) +# POSTCHECK-NEXT: [0x0000000000[[#ADDR2]], 0x0000000000[[#ADDR2 + 0x5]]) +# POSTCHECK-NEXT: [0x0000000000[[#ADDR]], 0x0000000000[[#ADDR + 0xf]])) diff --git a/bolt/test/X86/dwarf4-subprogram-single-gc-ranges.test b/bolt/test/X86/dwarf4-subprogram-single-gc-ranges.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf4-subprogram-single-gc-ranges.test @@ -0,0 +1,23 @@ +# REQUIRES: system-linux + +# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-subprogram-single-gc-ranges-main.s -o %t1.o +# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q +# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections &> %t1.txt +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t1.txt +# RUN: cat %t1.txt | FileCheck --check-prefix=POSTCHECK %s + +# This test checks BOLT correctly handles DW_TAG_subprogram with Ranges with single entry, when function was GCed. + +# POSTCHECK: BOLT-WARNING: [internal-dwarf-error]: subprogram got GCed by the linker, DW_AT_ranges is used. + +# POSTCHECK: DW_TAG_subprogram +# POSTCHECK-NEXT: DW_AT_frame_base +# POSTCHECK-NEXT: DW_AT_linkage_name +# POSTCHECK-SAME: _Z7doStuffi +# POSTCHECK-NEXT: DW_AT_name +# POSTCHECK-NEXT: DW_AT_decl_file +# POSTCHECK-NEXT: DW_AT_decl_line +# POSTCHECK-NEXT: DW_AT_type +# POSTCHECK-NEXT: DW_AT_external +# POSTCHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) +# POSTCHECK-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x00000001) diff --git a/bolt/test/X86/dwarf4-subprogram-single-ranges.test b/bolt/test/X86/dwarf4-subprogram-single-ranges.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf4-subprogram-single-ranges.test @@ -0,0 +1,25 @@ +# REQUIRES: system-linux + +# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-subprogram-single-ranges-main.s -o %t1.o +# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q +# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections +# RUN: llvm-objdump %t.bolt --disassemble > %t1.txt +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t1.txt +# RUN: cat %t1.txt | FileCheck --check-prefix=POSTCHECK %s + +# This test checks BOLT correctly handles DW_TAG_subprogram with Ranges with single entry. + +# POSTCHECK: _Z7doStuffi>: +# POSTCHECK: [[#%.6x,ADDR:]] + +# POSTCHECK: DW_TAG_subprogram +# POSTCHECK-NEXT: DW_AT_frame_base +# POSTCHECK-NEXT: DW_AT_linkage_name +# POSTCHECK-SAME: _Z7doStuffi +# POSTCHECK-NEXT: DW_AT_name +# POSTCHECK-NEXT: DW_AT_decl_file +# POSTCHECK-NEXT: DW_AT_decl_line +# POSTCHECK-NEXT: DW_AT_type +# POSTCHECK-NEXT: DW_AT_external +# POSTCHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000[[#ADDR]]) +# POSTCHECK-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x0000001b) diff --git a/bolt/test/X86/dwarf4-types-dwarf5-types.test b/bolt/test/X86/dwarf4-types-dwarf5-types.test --- a/bolt/test/X86/dwarf4-types-dwarf5-types.test +++ b/bolt/test/X86/dwarf4-types-dwarf5-types.test @@ -42,9 +42,9 @@ # POSTCHECK: version = 0x0005 # POSTCHECK: DW_TAG_compile_unit # POSTCHECK: DW_TAG_subprogram -# POSTCHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0048 => {0x{{[0-9a-f]+}}} "int") +# POSTCHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x004b => {0x{{[0-9a-f]+}}} "int") # POSTCHECK: DW_TAG_variable -# POSTCHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x004c => {0x{{[0-9a-f]+}}} "Foo2a") +# POSTCHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x004f => {0x{{[0-9a-f]+}}} "Foo2a") # POSTCHECK: DW_TAG_base_type # POSTCHECK: DW_TAG_structure_type # POSTCHECK: DW_AT_signature [DW_FORM_ref_sig8] (0x104ec427d2ebea6f) diff --git a/bolt/test/X86/dwarf4-types-dwarf5.test b/bolt/test/X86/dwarf4-types-dwarf5.test --- a/bolt/test/X86/dwarf4-types-dwarf5.test +++ b/bolt/test/X86/dwarf4-types-dwarf5.test @@ -19,7 +19,7 @@ # POSTCHECK: version = 0x0005 # POSTCHECK: DW_TAG_compile_unit # POSTCHECK: DW_TAG_subprogram -# POSTCHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0031 => {0x000000d8} "int") +# POSTCHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0034 => {0x000000db} "int") # POSTCHECK: DW_TAG_base_type # POSTCHECKTU: version = 0x0004 diff --git a/bolt/test/X86/dwarf5-df-dualcu-loclist.test b/bolt/test/X86/dwarf5-df-dualcu-loclist.test --- a/bolt/test/X86/dwarf5-df-dualcu-loclist.test +++ b/bolt/test/X86/dwarf5-df-dualcu-loclist.test @@ -29,12 +29,12 @@ ; BOLT-DWO-MAIN: version = 0x0005 ; BOLT-DWO-MAIN: DW_TAG_formal_parameter [10] ; BOLT-DWO-MAIN-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0) loclist = 0x00000014: -; BOLT-DWO-MAIN-NEXT: DW_LLE_base_addressx (0x0000000000000004) +; BOLT-DWO-MAIN-NEXT: DW_LLE_base_addressx (0x0000000000000003) ; BOLT-DWO-MAIN-NEXT: DW_LLE_offset_pair (0x0000000000000000, 0x0000000000000014) ; BOLT-DWO-MAIN-NEXT: DW_LLE_offset_pair (0x0000000000000014, 0x0000000000000019) ; BOLT-DWO-MAIN: DW_TAG_formal_parameter [10] ; BOLT-DWO-MAIN-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x1) loclist = 0x00000024: -; BOLT-DWO-MAIN-NEXT: DW_LLE_base_addressx (0x0000000000000004) +; BOLT-DWO-MAIN-NEXT: DW_LLE_base_addressx (0x0000000000000003) ; BOLT-DWO-MAIN-NEXT: DW_LLE_offset_pair (0x0000000000000000, 0x000000000000000c) ; BOLT-DWO-MAIN-NEXT: DW_LLE_offset_pair (0x000000000000000c, 0x0000000000000019) diff --git a/bolt/test/X86/dwarf5-df-dualcu.test b/bolt/test/X86/dwarf5-df-dualcu.test --- a/bolt/test/X86/dwarf5-df-dualcu.test +++ b/bolt/test/X86/dwarf5-df-dualcu.test @@ -6,7 +6,7 @@ ; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-dualcu-helper.s \ ; RUN: -split-dwarf-file=helper.dwo -o helper.o ; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o helper.o -o main.exe -; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections +; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --always-convert-to-ranges ; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe | FileCheck -check-prefix=PRE-BOLT %s ; RUN: llvm-dwarfdump --show-form --verbose --debug-addr main.exe.bolt &> %t/foo.txt ; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe.bolt >> %t/foo.txt diff --git a/bolt/test/X86/dwarf5-df-mono-dualcu.test b/bolt/test/X86/dwarf5-df-mono-dualcu.test --- a/bolt/test/X86/dwarf5-df-mono-dualcu.test +++ b/bolt/test/X86/dwarf5-df-mono-dualcu.test @@ -5,7 +5,7 @@ ; RUN: -split-dwarf-file=main.dwo -o main.o ; RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux-gnu %p/Inputs/dwarf5-df-mono-helper.s -o=helper.o ; RUN: %clang %cflags -gdwarf-5 main.o helper.o -o main.exe -; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections +; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --always-convert-to-ranges ; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe | FileCheck -check-prefix=PRE-BOLT %s ; RUN: llvm-dwarfdump --show-form --verbose --debug-addr main.exe.bolt &> %t/foo.txt ; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe.bolt >> %t/foo.txt diff --git a/bolt/test/X86/dwarf5-do-no-convert-low-pc-high-pc-to-ranges.test b/bolt/test/X86/dwarf5-do-no-convert-low-pc-high-pc-to-ranges.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf5-do-no-convert-low-pc-high-pc-to-ranges.test @@ -0,0 +1,20 @@ +# REQUIRES: system-linux + +# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-do-no-convert-low-pc-high-pc-to-ranges.s -o %t1.o +# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q +# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s + +# This test checks that we do not convert low_pc/high_pc to ranges for DW_TAG_inlined_subroutine, +# when there is only one output range entry. + +# PRECHECK: DW_TAG_inlined_subroutine +# PRECHECK: DW_AT_abstract_origin +# PRECHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) +# PRECHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000002) + +# POSTCHECK: DW_TAG_inlined_subroutine +# POSTCHECK: DW_AT_abstract_origin +# POSTCHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002) +# POSTCHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000002) diff --git a/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-gdb-generated-gdb11.test b/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-gdb-generated-gdb11.test --- a/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-gdb-generated-gdb11.test +++ b/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-gdb-generated-gdb11.test @@ -11,8 +11,8 @@ # POSTCHECK: Version = 8 # POSTCHECK: CU list offset = 0x18, has 2 entries -# POSTCHECK-NEXT: 0: Offset = 0x40, Length = 0x52 -# POSTCHECK-NEXT: 1: Offset = 0x92, Length = 0x72 +# POSTCHECK-NEXT: 0: Offset = 0x40, Length = 0x55 +# POSTCHECK-NEXT: 1: Offset = 0x95, Length = 0x72 # POSTCHECK: Types CU list offset = 0x38, has 2 entries # POSTCHECK-NEXT: 0: offset = 0x00000000, type_offset = 0x00000023, type_signature = 0x418503b8111e9a7b # POSTCHECK-NEXT: 1: offset = 0x00000000, type_offset = 0x0000001e, type_signature = 0x00f6cca4e3a15118 diff --git a/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-gdb-generated-gdb9.test b/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-gdb-generated-gdb9.test --- a/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-gdb-generated-gdb9.test +++ b/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-gdb-generated-gdb9.test @@ -12,8 +12,8 @@ # POSTCHECK: Version = 8 # POSTCHECK: CU list offset = 0x18, has 3 entries # POSTCHECK-NEXT: 0: Offset = 0x0, Length = 0x40 -# POSTCHECK-NEXT: 1: Offset = 0x40, Length = 0x52 -# POSTCHECK-NEXT: 2: Offset = 0x92, Length = 0x72 +# POSTCHECK-NEXT: 1: Offset = 0x40, Length = 0x55 +# POSTCHECK-NEXT: 2: Offset = 0x95, Length = 0x72 # POSTCHECK: Types CU list offset = 0x48, has 2 entries # POSTCHECK-NEXT: 0: offset = 0x00000000, type_offset = 0x00000023, type_signature = 0x418503b8111e9a7b # POSTCHECK-NEXT: 1: offset = 0x00000000, type_offset = 0x0000001e, type_signature = 0x00f6cca4e3a15118 diff --git a/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-lld-generated.test b/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-lld-generated.test --- a/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-lld-generated.test +++ b/bolt/test/X86/dwarf5-dwarf4-gdb-index-types-lld-generated.test @@ -10,8 +10,8 @@ # POSTCHECK: Version = 7 # POSTCHECK: CU list offset = 0x18, has 2 entries -# POSTCHECK-NEXT: 0: Offset = 0x40, Length = 0x52 -# POSTCHECK-NEXT: 1: Offset = 0x92, Length = 0x72 +# POSTCHECK-NEXT: 0: Offset = 0x40, Length = 0x55 +# POSTCHECK-NEXT: 1: Offset = 0x95, Length = 0x72 # POSTCHECK: Types CU list offset = 0x38, has 0 entries # POSTCHECK: Address area offset = 0x38, has 2 entries # POSTCHECK-NEXT: Low/High address = [0x[[#%.4x,ADDR:]], diff --git a/bolt/test/X86/dwarf5-dwarf4-monolithic.test b/bolt/test/X86/dwarf5-dwarf4-monolithic.test --- a/bolt/test/X86/dwarf5-dwarf4-monolithic.test +++ b/bolt/test/X86/dwarf5-dwarf4-monolithic.test @@ -5,7 +5,7 @@ # RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-helper1.s -o %t1.o # RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-helper2.s -o %t2.o # RUN: %clang %cflags -dwarf-5 %tmain.o %t0.o %t1.o %t2.o -o %t.exe -Wl,-q -# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections +# RUN: llvm-bolt --always-convert-to-ranges %t.exe -o %t.bolt --update-debug-sections # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s # RUN: llvm-dwarfdump --show-form --verbose --debug-line %t.exe > %t_line.txt # RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt diff --git a/bolt/test/X86/dwarf5-dwarf4-types-backward-forward-cross-reference.test b/bolt/test/X86/dwarf5-dwarf4-types-backward-forward-cross-reference.test --- a/bolt/test/X86/dwarf5-dwarf4-types-backward-forward-cross-reference.test +++ b/bolt/test/X86/dwarf5-dwarf4-types-backward-forward-cross-reference.test @@ -15,19 +15,19 @@ # POSTCHECK: version = 0x0005 # POSTCHECK: DW_TAG_compile_unit # POSTCHECK: DW_TAG_variable [14] -# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000000001f8 "Foo2a") +# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x{{[0-9a-f]+}} "Foo2a") # POSTCHECK: version = 0x0005 # POSTCHECK: DW_TAG_compile_unit # POSTCHECK: DW_TAG_variable [14] -# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000199 "Foo") +# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x{{[0-9a-f]+}} "Foo") # POSTCHECK: version = 0x0004 # POSTCHECK: DW_TAG_compile_unit # POSTCHECK: DW_TAG_variable [20] -# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000000002f4 "Foo4a") +# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x{{[0-9a-f]+}} "Foo4a") # POSTCHECK: version = 0x0004 # POSTCHECK: DW_TAG_compile_unit # POSTCHECK: DW_TAG_variable [20] -# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000276 "Foo3a") +# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x{{[0-9a-f]+}} "Foo3a") # POSTCHECKTU: version = 0x0004 # POSTCHECKTU: DW_TAG_type_unit diff --git a/bolt/test/X86/dwarf5-ftypes-dwo-mono-input-dwp-output.test b/bolt/test/X86/dwarf5-ftypes-dwo-mono-input-dwp-output.test --- a/bolt/test/X86/dwarf5-ftypes-dwo-mono-input-dwp-output.test +++ b/bolt/test/X86/dwarf5-ftypes-dwo-mono-input-dwp-output.test @@ -31,13 +31,13 @@ ; BOLT-SAME: 0x675d23e4f33235f2 ; BOLT: 0x0000004b: Type Unit: length = 0x0000003e ; BOLT-SAME: 0x49dc260088be7e56 -; BOLT: 0x0000008d: Compile Unit: length = 0x00000074 +; BOLT: 0x0000008d: Compile Unit: length = 0x00000077 ; BOLT-SAME: 0x4257354d8bb35644 -; BOLT: 0x00000105: Type Unit: length = 0x00000047 +; BOLT: 0x00000108: Type Unit: length = 0x00000047 ; BOLT-SAME: 0x104ec427d2ebea6f -; BOLT: 0x00000150: Type Unit: length = 0x0000003e +; BOLT: 0x00000153: Type Unit: length = 0x0000003e ; BOLT-SAME: 0xb4580bc1535df1e4 -; BOLT: 0x00000192: Compile Unit: length = 0x00000051 +; BOLT: 0x00000195: Compile Unit: length = 0x00000054 ; BOLT-SAME: 0x7738bfb5f3edfb73 ; BOLT-NOT: 0x8f55ac73549bc003 ; BOLT-NOT: 0xe7734af8fed0632e @@ -45,11 +45,11 @@ ; BOLT-DWP-TU-INDEX: version = 5, units = 4, slots = 8 ; BOLT-DWP-TU-INDEX: Index Signature ; BOLT-DWP-TU-INDEX: 3 0x675d23e4f33235f2 [0x0000000000000000, 0x000000000000004b) [0x00000000, 0x00000083) [0x00000000, 0x00000056) [0x00000000, 0x00000044) -; BOLT-DWP-TU-INDEX: 5 0xb4580bc1535df1e4 [0x0000000000000150, 0x0000000000000192) [0x00000083, 0x000000f9) [0x00000056, 0x000000ae) [0x00000044, 0x00000084) +; BOLT-DWP-TU-INDEX: 5 0xb4580bc1535df1e4 [0x0000000000000153, 0x0000000000000195) [0x00000083, 0x000000f9) [0x00000056, 0x000000ae) [0x00000044, 0x00000084) ; BOLT-DWP-TU-INDEX: 7 0x49dc260088be7e56 [0x000000000000004b, 0x000000000000008d) [0x00000000, 0x00000083) [0x00000000, 0x00000056) [0x00000000, 0x00000044) -; BOLT-DWP-TU-INDEX: 8 0x104ec427d2ebea6f [0x0000000000000105, 0x0000000000000150) [0x00000083, 0x000000f9) [0x00000056, 0x000000ae) [0x00000044, 0x00000084) +; BOLT-DWP-TU-INDEX: 8 0x104ec427d2ebea6f [0x0000000000000108, 0x0000000000000153) [0x00000083, 0x000000f9) [0x00000056, 0x000000ae) [0x00000044, 0x00000084) ; BOLT-DWP-CU-INDEX: version = 5, units = 2, slots = 4 ; BOLT-DWP-CU-INDEX: Index Signature -; BOLT-DWP-CU-INDEX: 1 0x4257354d8bb35644 [0x000000000000008d, 0x0000000000000105) [0x00000000, 0x00000083) [0x00000000, 0x00000056) [0x00000000, 0x00000044) -; BOLT-DWP-CU-INDEX: 4 0x7738bfb5f3edfb73 [0x0000000000000192, 0x00000000000001e7) [0x00000083, 0x000000f9) [0x00000056, 0x000000ae) [0x00000044, 0x00000084) +; BOLT-DWP-CU-INDEX: 1 0x4257354d8bb35644 [0x000000000000008d, 0x0000000000000108) [0x00000000, 0x00000083) [0x00000000, 0x00000056) [0x00000000, 0x00000044) +; BOLT-DWP-CU-INDEX: 4 0x7738bfb5f3edfb73 [0x0000000000000195, 0x00000000000001ed) [0x00000083, 0x000000f9) [0x00000056, 0x000000ae) [0x00000044, 0x00000084) diff --git a/bolt/test/X86/dwarf5-gdb-index-types-gdb-generated-gdb11.test b/bolt/test/X86/dwarf5-gdb-index-types-gdb-generated-gdb11.test --- a/bolt/test/X86/dwarf5-gdb-index-types-gdb-generated-gdb11.test +++ b/bolt/test/X86/dwarf5-gdb-index-types-gdb-generated-gdb11.test @@ -11,8 +11,8 @@ # POSTCHECK: Version = 8 # POSTCHECK: CU list offset = 0x18, has 2 entries -# POSTCHECK-NEXT: 0: Offset = 0x80, Length = 0x52 -# POSTCHECK-NEXT: 1: Offset = 0xd2, Length = 0x53 +# POSTCHECK-NEXT: 0: Offset = 0x80, Length = 0x55 +# POSTCHECK-NEXT: 1: Offset = 0xd5, Length = 0x56 # POSTCHECK: Types CU list offset = 0x38, has 2 entries # POSTCHECK-NEXT: 0: offset = 0x00000000, type_offset = 0x00000023, type_signature = 0x418503b8111e9a7b # POSTCHECK-NEXT: 1: offset = 0x00000040, type_offset = 0x00000023, type_signature = 0x00f6cca4e3a15118 diff --git a/bolt/test/X86/dwarf5-gdb-index-types-gdb-generated-gdb9.test b/bolt/test/X86/dwarf5-gdb-index-types-gdb-generated-gdb9.test --- a/bolt/test/X86/dwarf5-gdb-index-types-gdb-generated-gdb9.test +++ b/bolt/test/X86/dwarf5-gdb-index-types-gdb-generated-gdb9.test @@ -13,8 +13,8 @@ # POSTCHECK: CU list offset = 0x18, has 4 entries # POSTCHECK-NEXT: 0: Offset = 0x0, Length = 0x40 # POSTCHECK-NEXT: 1: Offset = 0x40, Length = 0x40 -# POSTCHECK-NEXT: 2: Offset = 0x80, Length = 0x52 -# POSTCHECK-NEXT: 3: Offset = 0xd2, Length = 0x53 +# POSTCHECK-NEXT: 2: Offset = 0x80, Length = 0x55 +# POSTCHECK-NEXT: 3: Offset = 0xd5, Length = 0x56 # POSTCHECK: Types CU list offset = 0x58, has 2 entries # POSTCHECK-NEXT: 0: offset = 0x00000000, type_offset = 0x00000023, type_signature = 0x418503b8111e9a7b # POSTCHECK-NEXT: 1: offset = 0x00000040, type_offset = 0x00000023, type_signature = 0x00f6cca4e3a15118 diff --git a/bolt/test/X86/dwarf5-gdb-index-types-lld-generated.test b/bolt/test/X86/dwarf5-gdb-index-types-lld-generated.test --- a/bolt/test/X86/dwarf5-gdb-index-types-lld-generated.test +++ b/bolt/test/X86/dwarf5-gdb-index-types-lld-generated.test @@ -10,8 +10,8 @@ # POSTCHECK: Version = 7 # POSTCHECK: CU list offset = 0x18, has 2 entries -# POSTCHECK-NEXT: 0: Offset = 0x80, Length = 0x52 -# POSTCHECK-NEXT: 1: Offset = 0xd2, Length = 0x53 +# POSTCHECK-NEXT: 0: Offset = 0x80, Length = 0x55 +# POSTCHECK-NEXT: 1: Offset = 0xd5, Length = 0x56 # POSTCHECK: Types CU list offset = 0x38, has 0 entries # POSTCHECK: Address area offset = 0x38, has 2 entries # POSTCHECK-NEXT: Low/High address = [0x[[#%.4x,ADDR:]], diff --git a/bolt/test/X86/dwarf5-locaddrx.test b/bolt/test/X86/dwarf5-locaddrx.test --- a/bolt/test/X86/dwarf5-locaddrx.test +++ b/bolt/test/X86/dwarf5-locaddrx.test @@ -4,7 +4,7 @@ ; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-locaddrx.s \ ; RUN: -split-dwarf-file=mainlocadddrx.dwo -o mainlocadddrx.o ; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split mainlocadddrx.o -o mainlocadddrx.exe -; RUN: llvm-bolt mainlocadddrx.exe -o mainlocadddrx.exe.bolt --update-debug-sections +; RUN: llvm-bolt mainlocadddrx.exe -o mainlocadddrx.exe.bolt --update-debug-sections --always-convert-to-ranges ; RUN: llvm-dwarfdump --show-form --verbose --debug-info mainlocadddrx.exe | FileCheck -check-prefix=PRE-BOLT %s ; RUN: llvm-dwarfdump --show-form --verbose --debug-addr mainlocadddrx.exe.bolt &> %t/foo.txt ; RUN: llvm-dwarfdump --show-form --verbose --debug-info mainlocadddrx.exe.bolt >> %t/foo.txt diff --git a/bolt/test/X86/dwarf5-locexpr-referrence.test b/bolt/test/X86/dwarf5-locexpr-referrence.test --- a/bolt/test/X86/dwarf5-locexpr-referrence.test +++ b/bolt/test/X86/dwarf5-locexpr-referrence.test @@ -16,6 +16,6 @@ # CHECK: version = 0x0005 # CHECK: DW_TAG_variable # CHECK-NEXT: DW_AT_location -# CHECK-SAME: DW_OP_convert (0x00000028 -> 0x0000008f) -# CHECK-SAME: DW_OP_convert (0x0000002c -> 0x00000093) +# CHECK-SAME: DW_OP_convert (0x00000028 -> 0x00000092) +# CHECK-SAME: DW_OP_convert (0x0000002c -> 0x00000096) # CHECK: version = 0x0005 diff --git a/bolt/test/X86/dwarf5-lowpc-highpc-convert.s b/bolt/test/X86/dwarf5-lowpc-highpc-convert.s --- a/bolt/test/X86/dwarf5-lowpc-highpc-convert.s +++ b/bolt/test/X86/dwarf5-lowpc-highpc-convert.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o # RUN: %clang %cflags -dwarf-5 %t1.o -o %t.exe -Wl,-q -# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections +# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --always-convert-to-ranges # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s # RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt diff --git a/bolt/test/X86/dwarf5-one-loclists-two-bases.test b/bolt/test/X86/dwarf5-one-loclists-two-bases.test --- a/bolt/test/X86/dwarf5-one-loclists-two-bases.test +++ b/bolt/test/X86/dwarf5-one-loclists-two-bases.test @@ -53,5 +53,5 @@ # Checking second CU # POSTCHECK: version = 0x0005 # POSTCHECK: DW_AT_loclists_base [DW_FORM_sec_offset] (0x0000000c) -# POSTCHECK: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000035) +# POSTCHECK: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000025) # POSTCHECK-NOT: DW_AT_location diff --git a/bolt/test/X86/dwarf5-rangeoffset-to-rangeindex.s b/bolt/test/X86/dwarf5-rangeoffset-to-rangeindex.s --- a/bolt/test/X86/dwarf5-rangeoffset-to-rangeindex.s +++ b/bolt/test/X86/dwarf5-rangeoffset-to-rangeindex.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o # RUN: %clang %cflags -dwarf-5 %t1.o -o %t.exe -Wl,-q -# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections +# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --always-convert-to-ranges # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s # RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt diff --git a/bolt/test/X86/dwarf5-split-dwarf4-monolithic.test b/bolt/test/X86/dwarf5-split-dwarf4-monolithic.test --- a/bolt/test/X86/dwarf5-split-dwarf4-monolithic.test +++ b/bolt/test/X86/dwarf5-split-dwarf4-monolithic.test @@ -9,7 +9,7 @@ # RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux -split-dwarf-file=helper1.dwo %p/Inputs/dwarf5-split-dwarf4-monolithic-helper1.s -o helper1.o # RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-helper2.s -o helper2.o # RUN: %clang %cflags -dwarf-5 main.o helper0.o helper1.o helper2.o -o main.exe -Wl,-q -# RUN: llvm-bolt main.exe -o main.bolt --update-debug-sections +# RUN: llvm-bolt --always-convert-to-ranges main.exe -o main.bolt --update-debug-sections # RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe | FileCheck --check-prefix=PRECHECK %s # RUN: llvm-dwarfdump --show-form --verbose --debug-line main.exe | FileCheck --check-prefix=PRECHECK-LINE %s # RUN: llvm-dwarfdump --show-form --verbose --debug-addr main.bolt > boltout.txt diff --git a/bolt/test/X86/dwarf5-subprogram-multiple-ranges.test b/bolt/test/X86/dwarf5-subprogram-multiple-ranges.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf5-subprogram-multiple-ranges.test @@ -0,0 +1,23 @@ +# REQUIRES: system-linux + +# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-subprogram-multiple-ranges-main.s -o %t1.o +# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q +# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections +# RUN: llvm-objdump %t.bolt --disassemble > %t1.txt +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t1.txt +# RUN: cat %t1.txt | FileCheck --check-prefix=POSTCHECK %s + +# This test checks BOLT correctly handles DW_TAG_subprogram with Ranges with multiple entries. + +# POSTCHECK: _Z7doStuffi>: +# POSTCHECK: [[#%.6x,ADDR:]] +# POSTCHECK: _Z7doStuffi.__part.1>: +# POSTCHECK-NEXT: [[#%.6x,ADDR1:]] +# POSTCHECK: _Z7doStuffi.__part.2>: +# POSTCHECK-NEXT: [[#%.6x,ADDR2:]] + +# POSTCHECK: DW_TAG_subprogram +# POSTCHECK-NEXT: DW_AT_ranges +# POSTCHECK-NEXT: [0x0000000000[[#ADDR]], 0x0000000000[[#ADDR + 0xf]]) +# POSTCHECK-NEXT: [0x0000000000[[#ADDR1]], 0x0000000000[[#ADDR1 + 0xb]]) +# POSTCHECK-NEXT: [0x0000000000[[#ADDR2]], 0x0000000000[[#ADDR2 + 0x5]]) diff --git a/bolt/test/X86/dwarf5-subprogram-single-gc-ranges.test b/bolt/test/X86/dwarf5-subprogram-single-gc-ranges.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf5-subprogram-single-gc-ranges.test @@ -0,0 +1,23 @@ +# REQUIRES: system-linux + +# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-subprogram-single-gc-ranges-main.s -o %t1.o +# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q +# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections &> %t1.txt +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t1.txt +# RUN: cat %t1.txt | FileCheck --check-prefix=POSTCHECK %s + +# This test checks BOLT correctly handles DW_TAG_subprogram with Ranges with single entry, when function was GCed. + +# POSTCHECK: BOLT-WARNING: [internal-dwarf-error]: subprogram got GCed by the linker, DW_AT_ranges is used. + +# POSTCHECK: DW_TAG_subprogram +# POSTCHECK-NEXT: DW_AT_frame_base +# POSTCHECK-NEXT: DW_AT_linkage_name +# POSTCHECK-SAME: _Z7doStuffi +# POSTCHECK-NEXT: DW_AT_name +# POSTCHECK-NEXT: DW_AT_decl_file +# POSTCHECK-NEXT: DW_AT_decl_line +# POSTCHECK-NEXT: DW_AT_type +# POSTCHECK-NEXT: DW_AT_external +# POSTCHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000000000000) +# POSTCHECK-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x00000001) diff --git a/bolt/test/X86/dwarf5-subprogram-single-ranges.test b/bolt/test/X86/dwarf5-subprogram-single-ranges.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf5-subprogram-single-ranges.test @@ -0,0 +1,25 @@ +# REQUIRES: system-linux + +# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-subprogram-single-ranges-main.s -o %t1.o +# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q +# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections +# RUN: llvm-objdump %t.bolt --disassemble > %t1.txt +# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t1.txt +# RUN: cat %t1.txt | FileCheck --check-prefix=POSTCHECK %s + +# This test checks BOLT correctly handles DW_TAG_subprogram with Ranges with single entry. + +# POSTCHECK: _Z7doStuffi>: +# POSTCHECK: [[#%.6x,ADDR:]] + +# POSTCHECK: DW_TAG_subprogram +# POSTCHECK-NEXT: DW_AT_frame_base +# POSTCHECK-NEXT: DW_AT_linkage_name +# POSTCHECK-SAME: _Z7doStuffi +# POSTCHECK-NEXT: DW_AT_name +# POSTCHECK-NEXT: DW_AT_decl_file +# POSTCHECK-NEXT: DW_AT_decl_line +# POSTCHECK-NEXT: DW_AT_type +# POSTCHECK-NEXT: DW_AT_external +# POSTCHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000[[#ADDR]]) +# POSTCHECK-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x0000001b) diff --git a/bolt/test/X86/dwarf5-two-loclists.test b/bolt/test/X86/dwarf5-two-loclists.test --- a/bolt/test/X86/dwarf5-two-loclists.test +++ b/bolt/test/X86/dwarf5-two-loclists.test @@ -64,7 +64,7 @@ # Checking second CU # POSTCHECK: version = 0x0005 # POSTCHECK: DW_AT_loclists_base [DW_FORM_sec_offset] (0x00000045) -# POSTCHECK: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000035) +# POSTCHECK: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000025) # POSTCHECK-EMPTY: # POSTCHECK: DW_TAG_variable # POSTCHECK: DW_TAG_variable diff --git a/bolt/test/X86/dwarf5-two-rnglists.test b/bolt/test/X86/dwarf5-two-rnglists.test --- a/bolt/test/X86/dwarf5-two-rnglists.test +++ b/bolt/test/X86/dwarf5-two-rnglists.test @@ -3,7 +3,7 @@ # RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_main.s -o %tmain.o # RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_helper.s -o %thelper.o # RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q -# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections +# RUN: llvm-bolt --always-convert-to-ranges %t.exe -o %t.bolt --update-debug-sections # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s # RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt diff --git a/bolt/test/X86/dwarf5-types-backward-cross-reference.s b/bolt/test/X86/dwarf5-types-backward-cross-reference.s --- a/bolt/test/X86/dwarf5-types-backward-cross-reference.s +++ b/bolt/test/X86/dwarf5-types-backward-cross-reference.s @@ -26,7 +26,7 @@ # POSTCHECK-SAME: version = 0x0005 # POSTCHECK: DW_TAG_variable [9] # POSTCHECK: DW_TAG_variable [12] -# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000199 "Foo") +# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x{{[0-9a-f]+}} "Foo") # main.cpp diff --git a/bolt/test/X86/dwarf5-types-forward-cross-reference.s b/bolt/test/X86/dwarf5-types-forward-cross-reference.s --- a/bolt/test/X86/dwarf5-types-forward-cross-reference.s +++ b/bolt/test/X86/dwarf5-types-forward-cross-reference.s @@ -21,7 +21,7 @@ # POSTCHECK: Compile Unit # POSTCHECK-SAME: version = 0x0005 # POSTCHECK: DW_TAG_variable [9] -# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000000001f8 "Foo2a") +# POSTCHECK: DW_AT_type [DW_FORM_ref_addr] (0x{{[0-9a-f]+}} "Foo2a") # POSTCHECK: Compile Unit # POSTCHECK-SAME: version = 0x0005 # POSTCHECK: DW_TAG_structure_type [11] diff --git a/bolt/test/X86/gdbindex.test b/bolt/test/X86/gdbindex.test --- a/bolt/test/X86/gdbindex.test +++ b/bolt/test/X86/gdbindex.test @@ -18,8 +18,8 @@ ; CHECK: Version = 7 ; CHECK: CU list offset = 0x18, has 2 entries: -; CHECK-NEXT: 0: Offset = 0x0, Length = 0x4b -; CHECK-NEXT: 1: Offset = 0x4b, Length = 0x4f +; CHECK-NEXT: 0: Offset = 0x0, Length = 0x4f +; CHECK-NEXT: 1: Offset = 0x4f, Length = 0x53 ; CHECK: Types CU list offset = 0x38, has 0 entries: