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 @@ -542,32 +542,34 @@ DebugLoclistWriter::setAddressWriter(AddrWriter.get()); - size_t CUIndex = 0; - for (std::unique_ptr &CU : BC.DwCtx->compile_units()) { - const uint16_t DwarfVersion = CU->getVersion(); + uint32_t CUIndex = 0; + std::mutex AccessMutex; + // Needs to be invoked in the same order as CUs are processed. + auto createRangeLocList = [&](DWARFUnit &CU) -> DebugLocWriter * { + std::lock_guard Lock(AccessMutex); + const uint16_t DwarfVersion = CU.getVersion(); if (DwarfVersion >= 5) { LocListWritersByCU[CUIndex] = - std::make_unique(*CU.get(), DwarfVersion, false); + std::make_unique(CU, DwarfVersion, false); - if (std::optional DWOId = CU->getDWOId()) { + if (std::optional DWOId = CU.getDWOId()) { assert(RangeListsWritersByCU.count(*DWOId) == 0 && "RangeLists writer for DWO unit already exists."); auto RangeListsSectionWriter = std::make_unique(); - RangeListsSectionWriter->initSection(*CU.get()); + RangeListsSectionWriter->initSection(CU); RangeListsWritersByCU[*DWOId] = std::move(RangeListsSectionWriter); } } else { LocListWritersByCU[CUIndex] = std::make_unique(); } - ++CUIndex; - } + return LocListWritersByCU[CUIndex++].get(); + }; // Unordered maps to handle name collision if output DWO directory is // specified. std::unordered_map NameToIndexMap; - std::mutex AccessMutex; auto updateDWONameCompDir = [&](DWARFUnit &Unit, DIEBuilder &DIEBldr, DIE &UnitDIE) -> std::string { @@ -597,8 +599,7 @@ DWPState State; if (opts::WriteDWP) initDWPState(State); - auto processUnitDIE = [&](size_t CUIndex, DWARFUnit *Unit, - DIEBuilder *DIEBlder) { + auto processUnitDIE = [&](DWARFUnit *Unit, DIEBuilder *DIEBlder) { // Check if the unit is a skeleton and we need special updates for it and // its matching split/DWO CU. std::optional SplitCU; @@ -608,8 +609,7 @@ Unit->getStringOffsetsTableContribution()); if (DWOId) SplitCU = BC.getDWOCU(*DWOId); - - DebugLocWriter *DebugLocWriter = nullptr; + DebugLocWriter *DebugLocWriter = createRangeLocList(*Unit); DebugRangesSectionWriter *RangesSectionWriter = Unit->getVersion() >= 5 ? RangeListsSectionWriter.get() : LegacyRangesSectionWriter.get(); @@ -645,12 +645,6 @@ DebugLocDWoWriter); } - { - std::lock_guard Lock(AccessMutex); - auto LocListWriterIter = LocListWritersByCU.find(CUIndex); - if (LocListWriterIter != LocListWritersByCU.end()) - DebugLocWriter = LocListWriterIter->second.get(); - } if (Unit->getVersion() >= 5) { RangesBase = RangesSectionWriter->getSectionOffset() + getDWARF5RngListLocListHeaderSize(); @@ -666,7 +660,6 @@ AddrWriter->update(*DIEBlder, *Unit); }; - CUIndex = 0; DIEBuilder DIEBlder(BC.DwCtx.get()); DIEBlder.buildTypeUnits(); SmallVector OutBuffer; @@ -687,17 +680,15 @@ for (std::vector &Vec : PartVec) { DIEBlder.buildCompileUnits(Vec); for (DWARFUnit *CU : DIEBlder.getProcessedCUs()) - processUnitDIE(CUIndex++, CU, &DIEBlder); + processUnitDIE(CU, &DIEBlder); finalizeCompileUnits(DIEBlder, *Streamer, OffsetMap, DIEBlder.getProcessedCUs()); } } else { // Update unit debug info in parallel ThreadPool &ThreadPool = ParallelUtilities::getThreadPool(); - for (std::unique_ptr &CU : BC.DwCtx->compile_units()) { - ThreadPool.async(processUnitDIE, CUIndex, CU.get(), &DIEBlder); - CUIndex++; - } + for (std::unique_ptr &CU : BC.DwCtx->compile_units()) + ThreadPool.async(processUnitDIE, CU.get(), &DIEBlder); ThreadPool.wait(); } diff --git a/bolt/test/X86/Inputs/dwarf4-cross-cu-with-loclist.s b/bolt/test/X86/Inputs/dwarf4-cross-cu-with-loclist.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarf4-cross-cu-with-loclist.s @@ -0,0 +1,550 @@ +# clang++ main.cpp -O1 -g2 -gdwarf-4 -emit-llvm -c -o mainLL.o +# clang++ helper1.cpp -O1 -g2 -gdwarf-4 -emit-llvm -c -o helper1LL.o +# llvm-link mainLL.o helper1LL.o -S -o linked.ll +# clang++ -O1 linked.ll -g2 -gdwarf-4 -S -o combinedTest.s + +# main.cpp +# struct Foo { +# int x; +# int y; +# }; +# inline __attribute__((always_inline)) +# static int helper(Foo &f) { +# return f.x + 3; +# } +# int main(int argc, char *argv[]) { +# Foo foo; +# foo.x = argc; +# foo.y = 3; +# return helper(foo) + foo.x + foo.y; +# } +# helper1.cpp +# struct Foo2 { +# int x; +# int y; +# }; +# inline __attribute__((always_inline)) +# static int helper(Foo2 &f) { +# return f.x + 3; +# } +# int foo2(int i) { +# Foo2 foo; +# foo.x = i; +# foo.y = 3; +# return helper(foo); +# } + + .text + .file "llvm-link" + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin0: + .cfi_startproc +# %bb.0: # %entry + #DEBUG_VALUE: main:argc <- $edi + #DEBUG_VALUE: main:argv <- $rsi + #DEBUG_VALUE: main:foo <- [DW_OP_LLVM_fragment 0 32] $edi + # kill: def $edi killed $edi def $rdi + #DEBUG_VALUE: main:foo <- [DW_OP_LLVM_fragment 32 32] 3 + .file 1 "/dwarf4CrossCULocList" "main.cpp" + .loc 1 13 30 prologue_end # main.cpp:13:30 + leal 6(,%rdi,2), %eax + .loc 1 13 3 is_stmt 0 # main.cpp:13:3 + retq +.Ltmp0: +.Lfunc_end0: + .size main, .Lfunc_end0-main + .cfi_endproc + # -- End function + .globl _Z4foo2i # -- Begin function _Z4foo2i + .p2align 4, 0x90 + .type _Z4foo2i,@function +_Z4foo2i: # @_Z4foo2i +.Lfunc_begin1: + .cfi_startproc +# %bb.0: # %entry + #DEBUG_VALUE: foo2:i <- $edi + #DEBUG_VALUE: foo2:foo <- [DW_OP_LLVM_fragment 0 32] $edi + # kill: def $edi killed $edi def $rdi + #DEBUG_VALUE: foo2:foo <- [DW_OP_LLVM_fragment 32 32] 3 + .file 2 "/dwarf4CrossCULocList" "helper1.cpp" + .loc 2 7 14 prologue_end is_stmt 1 # helper1.cpp:7:14 + leal 3(%rdi), %eax +.Ltmp1: + .loc 2 13 3 # helper1.cpp:13:3 + retq +.Ltmp2: +.Lfunc_end1: + .size _Z4foo2i, .Lfunc_end1-_Z4foo2i + .cfi_endproc + # -- End function + .section .debug_loc,"",@progbits +.Ldebug_loc0: + .quad .Lfunc_begin0-.Lfunc_begin0 + .quad .Lfunc_end0-.Lfunc_begin0 + .short 7 # Loc expr size + .byte 85 # super-register DW_OP_reg5 + .byte 147 # DW_OP_piece + .byte 4 # 4 + .byte 51 # DW_OP_lit3 + .byte 159 # DW_OP_stack_value + .byte 147 # DW_OP_piece + .byte 4 # 4 + .quad 0 + .quad 0 +.Ldebug_loc1: + .quad .Lfunc_begin1-.Lfunc_begin1 + .quad .Lfunc_end1-.Lfunc_begin1 + .short 7 # Loc expr size + .byte 85 # super-register DW_OP_reg5 + .byte 147 # DW_OP_piece + .byte 4 # 4 + .byte 51 # DW_OP_lit3 + .byte 159 # DW_OP_stack_value + .byte 147 # DW_OP_piece + .byte 4 # 4 + .quad 0 + .quad 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 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 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 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 + .ascii "\227B" # DW_AT_GNU_all_call_sites + .byte 25 # DW_FORM_flag_present + .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 16 # DW_FORM_ref_addr + .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 16 # DW_FORM_ref_addr + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 4 # 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 5 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 2 # DW_AT_location + .byte 23 # DW_FORM_sec_offset + .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 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 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 8 # Abbreviation Code + .byte 19 # DW_TAG_structure_type + .byte 1 # DW_CHILDREN_yes + .byte 54 # DW_AT_calling_convention + .byte 11 # DW_FORM_data1 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 9 # Abbreviation Code + .byte 13 # DW_TAG_member + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 16 # DW_FORM_ref_addr + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 56 # DW_AT_data_member_location + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 10 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .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 32 # DW_AT_inline + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 11 # Abbreviation Code + .byte 5 # DW_TAG_formal_parameter + .byte 0 # DW_CHILDREN_no + .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 12 # Abbreviation Code + .byte 16 # DW_TAG_reference_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 13 # Abbreviation Code + .byte 13 # DW_TAG_member + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .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 56 # DW_AT_data_member_location + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 14 # 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 + .ascii "\227B" # DW_AT_GNU_all_call_sites + .byte 25 # DW_FORM_flag_present + .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 15 # Abbreviation Code + .byte 29 # DW_TAG_inlined_subroutine + .byte 0 # DW_CHILDREN_no + .byte 49 # DW_AT_abstract_origin + .byte 19 # DW_FORM_ref4 + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 88 # DW_AT_call_file + .byte 11 # DW_FORM_data1 + .byte 89 # DW_AT_call_line + .byte 11 # DW_FORM_data1 + .byte 87 # DW_AT_call_column + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 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:0x96 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:0x43 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_string11 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 9 # DW_AT_decl_line + .long .debug_info+231 # DW_AT_type + # DW_AT_external + .byte 3 # Abbrev [3] 0x43:0xd DW_TAG_formal_parameter + .byte 1 # DW_AT_location + .byte 85 + .long .Linfo_string14 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 9 # DW_AT_decl_line + .long .debug_info+231 # DW_AT_type + .byte 4 # Abbrev [4] 0x50:0xd DW_TAG_formal_parameter + .byte 1 # DW_AT_location + .byte 84 + .long .Linfo_string15 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 9 # DW_AT_decl_line + .long 109 # DW_AT_type + .byte 5 # Abbrev [5] 0x5d:0xf DW_TAG_variable + .long .Ldebug_loc0 # DW_AT_location + .long .Linfo_string17 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 10 # DW_AT_decl_line + .long 126 # DW_AT_type + .byte 0 # End Of Children Mark + .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:0x7 DW_TAG_base_type + .long .Linfo_string16 # DW_AT_name + .byte 6 # DW_AT_encoding + .byte 1 # DW_AT_byte_size + .byte 8 # Abbrev [8] 0x7e:0x22 DW_TAG_structure_type + .byte 5 # DW_AT_calling_convention + .long .Linfo_string18 # DW_AT_name + .byte 8 # DW_AT_byte_size + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .byte 9 # Abbrev [9] 0x87:0xc DW_TAG_member + .long .Linfo_string8 # DW_AT_name + .long .debug_info+231 # DW_AT_type + .byte 1 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .byte 0 # DW_AT_data_member_location + .byte 9 # Abbrev [9] 0x93:0xc DW_TAG_member + .long .Linfo_string9 # DW_AT_name + .long .debug_info+231 # DW_AT_type + .byte 1 # DW_AT_decl_file + .byte 3 # DW_AT_decl_line + .byte 4 # DW_AT_data_member_location + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark +.Ldebug_info_end0: +.Lcu_begin1: + .long .Ldebug_info_end1-.Ldebug_info_start1 # Length of Unit +.Ldebug_info_start1: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0xb8 DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 33 # DW_AT_language + .long .Linfo_string3 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir + .quad .Lfunc_begin1 # DW_AT_low_pc + .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc + .byte 10 # Abbrev [10] 0x2a:0x1c DW_TAG_subprogram + .long .Linfo_string4 # DW_AT_linkage_name + .long .Linfo_string5 # DW_AT_name + .byte 2 # DW_AT_decl_file + .byte 6 # DW_AT_decl_line + .long 70 # DW_AT_type + .byte 1 # DW_AT_inline + .byte 11 # Abbrev [11] 0x3a:0xb DW_TAG_formal_parameter + .long .Linfo_string7 # DW_AT_name + .byte 2 # DW_AT_decl_file + .byte 6 # DW_AT_decl_line + .long 77 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 7 # Abbrev [7] 0x46:0x7 DW_TAG_base_type + .long .Linfo_string6 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 12 # Abbrev [12] 0x4d:0x5 DW_TAG_reference_type + .long 82 # DW_AT_type + .byte 8 # Abbrev [8] 0x52:0x22 DW_TAG_structure_type + .byte 5 # DW_AT_calling_convention + .long .Linfo_string10 # DW_AT_name + .byte 8 # DW_AT_byte_size + .byte 2 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .byte 13 # Abbrev [13] 0x5b:0xc DW_TAG_member + .long .Linfo_string8 # DW_AT_name + .long 70 # DW_AT_type + .byte 2 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .byte 0 # DW_AT_data_member_location + .byte 13 # Abbrev [13] 0x67:0xc DW_TAG_member + .long .Linfo_string9 # DW_AT_name + .long 70 # DW_AT_type + .byte 2 # DW_AT_decl_file + .byte 3 # DW_AT_decl_line + .byte 4 # DW_AT_data_member_location + .byte 0 # End Of Children Mark + .byte 14 # Abbrev [14] 0x74:0x4e 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 87 + # DW_AT_GNU_all_call_sites + .long .Linfo_string12 # DW_AT_linkage_name + .long .Linfo_string13 # DW_AT_name + .byte 2 # DW_AT_decl_file + .byte 9 # DW_AT_decl_line + .long 70 # DW_AT_type + # DW_AT_external + .byte 4 # Abbrev [4] 0x91:0xd DW_TAG_formal_parameter + .byte 1 # DW_AT_location + .byte 85 + .long .Linfo_string19 # DW_AT_name + .byte 2 # DW_AT_decl_file + .byte 9 # DW_AT_decl_line + .long 70 # DW_AT_type + .byte 5 # Abbrev [5] 0x9e:0xf DW_TAG_variable + .long .Ldebug_loc1 # DW_AT_location + .long .Linfo_string17 # DW_AT_name + .byte 2 # DW_AT_decl_file + .byte 10 # DW_AT_decl_line + .long 82 # DW_AT_type + .byte 15 # Abbrev [15] 0xad:0x14 DW_TAG_inlined_subroutine + .long 42 # DW_AT_abstract_origin + .quad .Lfunc_begin1 # DW_AT_low_pc + .long .Ltmp1-.Lfunc_begin1 # DW_AT_high_pc + .byte 2 # DW_AT_call_file + .byte 13 # DW_AT_call_line + .byte 10 # DW_AT_call_column + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark +.Ldebug_info_end1: + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 37d6c1cc7d4dd3a8a47ba62254bc88521bd50d66)" # string offset=0 +.Linfo_string1: + .asciz "main.cpp" # string offset=101 +.Linfo_string2: + .asciz "/dwarf4CrossCULocList" # string offset=110 +.Linfo_string3: + .asciz "helper1.cpp" # string offset=169 +.Linfo_string4: + .asciz "_ZL6helperR4Foo2" # string offset=181 +.Linfo_string5: + .asciz "helper" # string offset=198 +.Linfo_string6: + .asciz "int" # string offset=205 +.Linfo_string7: + .asciz "f" # string offset=209 +.Linfo_string8: + .asciz "x" # string offset=211 +.Linfo_string9: + .asciz "y" # string offset=213 +.Linfo_string10: + .asciz "Foo2" # string offset=215 +.Linfo_string11: + .asciz "main" # string offset=220 +.Linfo_string12: + .asciz "_Z4foo2i" # string offset=225 +.Linfo_string13: + .asciz "foo2" # string offset=234 +.Linfo_string14: + .asciz "argc" # string offset=239 +.Linfo_string15: + .asciz "argv" # string offset=244 +.Linfo_string16: + .asciz "char" # string offset=249 +.Linfo_string17: + .asciz "foo" # string offset=254 +.Linfo_string18: + .asciz "Foo" # string offset=258 +.Linfo_string19: + .asciz "i" # string offset=262 + .ident "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 37d6c1cc7d4dd3a8a47ba62254bc88521bd50d66)" + .ident "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 37d6c1cc7d4dd3a8a47ba62254bc88521bd50d66)" + .section ".note.GNU-stack","",@progbits + .addrsig + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/Inputs/dwarf4-two-entries-loclist.s b/bolt/test/X86/Inputs/dwarf4-two-entries-loclist.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarf4-two-entries-loclist.s @@ -0,0 +1,390 @@ +# clang++ helper2.cpp -O2 -g2 -gdwarf-4 -S -o helper2.s +# int z1 = 0; +# int d1 = 0; +# +# int helper31(int z_, int d_) { +# z1 += z_; +# d1 += d_; +# return z1 * d1; +# } +# +# +# int z = 0; +# int d = 0; +# +# int helper3(int z_, int d_) { +# z += z_; +# d += d_; +# return z * d; +# } + + .text + .file "helper2.cpp" + .file 1 "/dwarf4CrossCULocList" "helper2.cpp" + .globl _Z8helper31ii # -- Begin function _Z8helper31ii + .p2align 4, 0x90 + .type _Z8helper31ii,@function +_Z8helper31ii: # @_Z8helper31ii +.Lfunc_begin0: + .loc 1 4 0 # helper2.cpp:4:0 + .cfi_startproc +# %bb.0: # %entry + #DEBUG_VALUE: helper31:z_ <- $edi + #DEBUG_VALUE: helper31:d_ <- $esi + movl %esi, %eax +.Ltmp0: + .loc 1 5 5 prologue_end # helper2.cpp:5:5 + addl z1(%rip), %edi +.Ltmp1: + #DEBUG_VALUE: helper31:z_ <- [DW_OP_LLVM_entry_value 1] $edi + .loc 1 6 5 # helper2.cpp:6:5 + addl d1(%rip), %eax + .loc 1 5 5 # helper2.cpp:5:5 + movl %edi, z1(%rip) + .loc 1 6 5 # helper2.cpp:6:5 + movl %eax, d1(%rip) + .loc 1 7 12 # helper2.cpp:7:12 + imull %edi, %eax + .loc 1 7 2 is_stmt 0 # helper2.cpp:7:2 + retq +.Ltmp2: +.Lfunc_end0: + .size _Z8helper31ii, .Lfunc_end0-_Z8helper31ii + .cfi_endproc + # -- End function + .globl _Z7helper3ii # -- Begin function _Z7helper3ii + .p2align 4, 0x90 + .type _Z7helper3ii,@function +_Z7helper3ii: # @_Z7helper3ii +.Lfunc_begin1: + .loc 1 14 0 is_stmt 1 # helper2.cpp:14:0 + .cfi_startproc +# %bb.0: # %entry + #DEBUG_VALUE: helper3:z_ <- $edi + #DEBUG_VALUE: helper3:d_ <- $esi + movl %esi, %eax +.Ltmp3: + .loc 1 15 4 prologue_end # helper2.cpp:15:4 + addl z(%rip), %edi +.Ltmp4: + #DEBUG_VALUE: helper3:z_ <- [DW_OP_LLVM_entry_value 1] $edi + .loc 1 16 4 # helper2.cpp:16:4 + addl d(%rip), %eax + .loc 1 15 4 # helper2.cpp:15:4 + movl %edi, z(%rip) + .loc 1 16 4 # helper2.cpp:16:4 + movl %eax, d(%rip) + .loc 1 17 11 # helper2.cpp:17:11 + imull %edi, %eax + .loc 1 17 2 is_stmt 0 # helper2.cpp:17:2 + retq +.Ltmp5: +.Lfunc_end1: + .size _Z7helper3ii, .Lfunc_end1-_Z7helper3ii + .cfi_endproc + # -- End function + .type z1,@object # @z1 + .bss + .globl z1 + .p2align 2, 0x0 +z1: + .long 0 # 0x0 + .size z1, 4 + + .type d1,@object # @d1 + .globl d1 + .p2align 2, 0x0 +d1: + .long 0 # 0x0 + .size d1, 4 + + .type z,@object # @z + .globl z + .p2align 2, 0x0 +z: + .long 0 # 0x0 + .size z, 4 + + .type d,@object # @d + .globl d + .p2align 2, 0x0 +d: + .long 0 # 0x0 + .size d, 4 + + .section .debug_loc,"",@progbits +.Ldebug_loc0: + .quad .Lfunc_begin0-.Lfunc_begin0 + .quad .Ltmp1-.Lfunc_begin0 + .short 1 # Loc expr size + .byte 85 # super-register DW_OP_reg5 + .quad .Ltmp1-.Lfunc_begin0 + .quad .Lfunc_end0-.Lfunc_begin0 + .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 +.Ldebug_loc1: + .quad .Lfunc_begin1-.Lfunc_begin0 + .quad .Ltmp4-.Lfunc_begin0 + .short 1 # Loc expr size + .byte 85 # super-register DW_OP_reg5 + .quad .Ltmp4-.Lfunc_begin0 + .quad .Lfunc_end1-.Lfunc_begin0 + .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 + .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 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .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 + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .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 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 + .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 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 + .ascii "\227B" # DW_AT_GNU_all_call_sites + .byte 25 # DW_FORM_flag_present + .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 5 # Abbreviation Code + .byte 5 # DW_TAG_formal_parameter + .byte 0 # DW_CHILDREN_no + .byte 2 # DW_AT_location + .byte 23 # DW_FORM_sec_offset + .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 6 # 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 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:0xef 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_end1-.Lfunc_begin0 # DW_AT_high_pc + .byte 2 # Abbrev [2] 0x2a:0x15 DW_TAG_variable + .long .Linfo_string3 # DW_AT_name + .long 63 # DW_AT_type + # DW_AT_external + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .byte 9 # DW_AT_location + .byte 3 + .quad z1 + .byte 3 # Abbrev [3] 0x3f:0x7 DW_TAG_base_type + .long .Linfo_string4 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 2 # Abbrev [2] 0x46:0x15 DW_TAG_variable + .long .Linfo_string5 # DW_AT_name + .long 63 # DW_AT_type + # DW_AT_external + .byte 1 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .byte 9 # DW_AT_location + .byte 3 + .quad d1 + .byte 2 # Abbrev [2] 0x5b:0x15 DW_TAG_variable + .long .Linfo_string6 # DW_AT_name + .long 63 # DW_AT_type + # DW_AT_external + .byte 1 # DW_AT_decl_file + .byte 11 # DW_AT_decl_line + .byte 9 # DW_AT_location + .byte 3 + .quad z + .byte 2 # Abbrev [2] 0x70:0x15 DW_TAG_variable + .long .Linfo_string7 # DW_AT_name + .long 63 # DW_AT_type + # DW_AT_external + .byte 1 # DW_AT_decl_file + .byte 12 # DW_AT_decl_line + .byte 9 # DW_AT_location + .byte 3 + .quad d + .byte 4 # Abbrev [4] 0x85:0x3a 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_string8 # DW_AT_linkage_name + .long .Linfo_string9 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 4 # DW_AT_decl_line + .long 63 # DW_AT_type + # DW_AT_external + .byte 5 # Abbrev [5] 0xa2:0xf DW_TAG_formal_parameter + .long .Ldebug_loc0 # DW_AT_location + .long .Linfo_string12 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 4 # DW_AT_decl_line + .long 63 # DW_AT_type + .byte 6 # Abbrev [6] 0xb1:0xd DW_TAG_formal_parameter + .byte 1 # DW_AT_location + .byte 84 + .long .Linfo_string13 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 4 # DW_AT_decl_line + .long 63 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0xbf:0x3a 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 87 + # DW_AT_GNU_all_call_sites + .long .Linfo_string10 # DW_AT_linkage_name + .long .Linfo_string11 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 14 # DW_AT_decl_line + .long 63 # DW_AT_type + # DW_AT_external + .byte 5 # Abbrev [5] 0xdc:0xf DW_TAG_formal_parameter + .long .Ldebug_loc1 # DW_AT_location + .long .Linfo_string12 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 14 # DW_AT_decl_line + .long 63 # DW_AT_type + .byte 6 # Abbrev [6] 0xeb:0xd DW_TAG_formal_parameter + .byte 1 # DW_AT_location + .byte 84 + .long .Linfo_string13 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 14 # DW_AT_decl_line + .long 63 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 37d6c1cc7d4dd3a8a47ba62254bc88521bd50d66)" # string offset=0 +.Linfo_string1: + .asciz "helper2.cpp" # string offset=101 +.Linfo_string2: + .asciz "/dwarf4CrossCULocList" # string offset=113 +.Linfo_string3: + .asciz "z1" # string offset=172 +.Linfo_string4: + .asciz "int" # string offset=175 +.Linfo_string5: + .asciz "d1" # string offset=179 +.Linfo_string6: + .asciz "z" # string offset=182 +.Linfo_string7: + .asciz "d" # string offset=184 +.Linfo_string8: + .asciz "_Z8helper31ii" # string offset=186 +.Linfo_string9: + .asciz "helper31" # string offset=200 +.Linfo_string10: + .asciz "_Z7helper3ii" # string offset=209 +.Linfo_string11: + .asciz "helper3" # string offset=222 +.Linfo_string12: + .asciz "z_" # string offset=230 +.Linfo_string13: + .asciz "d_" # string offset=233 + .ident "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 37d6c1cc7d4dd3a8a47ba62254bc88521bd50d66)" + .section ".note.GNU-stack","",@progbits + .addrsig + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/Inputs/dwarf5-loclist.s b/bolt/test/X86/Inputs/dwarf5-loclist.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarf5-loclist.s @@ -0,0 +1,393 @@ +# helper.cpp -O1 -g2 -gdwarf-5 -S -o helper.s +# struct Foo1 { +# int x; +# int y; +# }; +# inline __attribute__((always_inline)) +# static int helper(Foo1 &f) { +# return f.x + 3; +# } +# int foo(int i) { +# Foo1 foo; +# foo.x = i; +# foo.y = 3; +# return helper(foo); +# } + + .text + .file "helper.cpp" + .globl _Z3fooi # -- Begin function _Z3fooi + .p2align 4, 0x90 + .type _Z3fooi,@function +_Z3fooi: # @_Z3fooi +.Lfunc_begin0: + .file 0 "/home/ayermolo/local/tasks/T160428655/dwarf4CrossCULocList" "helper.cpp" md5 0xc9271b4999165863c559e42d691423d1 + .cfi_startproc +# %bb.0: # %entry + #DEBUG_VALUE: foo:i <- $edi + #DEBUG_VALUE: foo:foo <- [DW_OP_LLVM_fragment 0 32] $edi + # kill: def $edi killed $edi def $rdi + #DEBUG_VALUE: foo:foo <- [DW_OP_LLVM_fragment 32 32] 3 + .loc 0 7 14 prologue_end # helper.cpp:7:14 + leal 3(%rdi), %eax +.Ltmp0: + .loc 0 13 3 # helper.cpp:13:3 + retq +.Ltmp1: +.Lfunc_end0: + .size _Z3fooi, .Lfunc_end0-_Z3fooi + .cfi_endproc + # -- End function + .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 1 # Offset entry count +.Lloclists_table_base0: + .long .Ldebug_loc0-.Lloclists_table_base0 +.Ldebug_loc0: + .byte 4 # DW_LLE_offset_pair + .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset + .uleb128 .Lfunc_end0-.Lfunc_begin0 # ending offset + .byte 7 # Loc expr size + .byte 85 # super-register DW_OP_reg5 + .byte 147 # DW_OP_piece + .byte 4 # 4 + .byte 51 # DW_OP_lit3 + .byte 159 # DW_OP_stack_value + .byte 147 # DW_OP_piece + .byte 4 # 4 + .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 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 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 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 32 # DW_AT_inline + .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 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 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 5 # Abbreviation Code + .byte 16 # DW_TAG_reference_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 6 # Abbreviation Code + .byte 19 # DW_TAG_structure_type + .byte 1 # DW_CHILDREN_yes + .byte 54 # DW_AT_calling_convention + .byte 11 # DW_FORM_data1 + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 7 # Abbreviation Code + .byte 13 # DW_TAG_member + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .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 56 # DW_AT_data_member_location + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 8 # 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 122 # DW_AT_call_all_calls + .byte 25 # DW_FORM_flag_present + .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 9 # 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 10 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 2 # DW_AT_location + .byte 34 # DW_FORM_loclistx + .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 11 # Abbreviation Code + .byte 29 # DW_TAG_inlined_subroutine + .byte 0 # DW_CHILDREN_no + .byte 49 # DW_AT_abstract_origin + .byte 19 # DW_FORM_ref4 + .byte 17 # DW_AT_low_pc + .byte 27 # DW_FORM_addrx + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 88 # DW_AT_call_file + .byte 11 # DW_FORM_data1 + .byte 89 # DW_AT_call_line + .byte 11 # DW_FORM_data1 + .byte 87 # DW_AT_call_column + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 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:0x81 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 + .byte 0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .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 6 # DW_AT_decl_line + .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 6 # DW_AT_decl_line + .long 61 # DW_AT_type + .byte 0 # End Of Children Mark + .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] 0x3d:0x5 DW_TAG_reference_type + .long 66 # DW_AT_type + .byte 6 # Abbrev [6] 0x42:0x19 DW_TAG_structure_type + .byte 5 # DW_AT_calling_convention + .byte 9 # DW_AT_name + .byte 8 # DW_AT_byte_size + .byte 0 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .byte 7 # Abbrev [7] 0x48:0x9 DW_TAG_member + .byte 7 # DW_AT_name + .long 57 # DW_AT_type + .byte 0 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .byte 0 # DW_AT_data_member_location + .byte 7 # Abbrev [7] 0x51:0x9 DW_TAG_member + .byte 8 # DW_AT_name + .long 57 # DW_AT_type + .byte 0 # DW_AT_decl_file + .byte 3 # DW_AT_decl_line + .byte 4 # DW_AT_data_member_location + .byte 0 # End Of Children Mark + .byte 8 # Abbrev [8] 0x5b:0x31 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_call_all_calls + .byte 10 # DW_AT_linkage_name + .byte 11 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 9 # DW_AT_decl_line + .long 57 # DW_AT_type + # DW_AT_external + .byte 9 # Abbrev [9] 0x6b:0xa DW_TAG_formal_parameter + .byte 1 # DW_AT_location + .byte 85 + .byte 12 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 9 # DW_AT_decl_line + .long 57 # DW_AT_type + .byte 10 # Abbrev [10] 0x75:0x9 DW_TAG_variable + .byte 0 # DW_AT_location + .byte 11 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 10 # DW_AT_decl_line + .long 66 # DW_AT_type + .byte 11 # Abbrev [11] 0x7e:0xd DW_TAG_inlined_subroutine + .long 39 # DW_AT_abstract_origin + .byte 0 # DW_AT_low_pc + .long .Ltmp0-.Lfunc_begin0 # DW_AT_high_pc + .byte 0 # DW_AT_call_file + .byte 13 # DW_AT_call_line + .byte 10 # DW_AT_call_column + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + .section .debug_str_offsets,"",@progbits + .long 56 # Length of String Offsets Set + .short 5 + .short 0 +.Lstr_offsets_base0: + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 37d6c1cc7d4dd3a8a47ba62254bc88521bd50d66)" # string offset=0 +.Linfo_string1: + .asciz "helper.cpp" # string offset=101 +.Linfo_string2: + .asciz "/home/ayermolo/local/tasks/T160428655/dwarf4CrossCULocList" # string offset=112 +.Linfo_string3: + .asciz "_ZL6helperR4Foo1" # string offset=171 +.Linfo_string4: + .asciz "helper" # string offset=188 +.Linfo_string5: + .asciz "int" # string offset=195 +.Linfo_string6: + .asciz "f" # string offset=199 +.Linfo_string7: + .asciz "x" # string offset=201 +.Linfo_string8: + .asciz "y" # string offset=203 +.Linfo_string9: + .asciz "Foo1" # string offset=205 +.Linfo_string10: + .asciz "_Z3fooi" # string offset=210 +.Linfo_string11: + .asciz "foo" # string offset=218 +.Linfo_string12: + .asciz "i" # string offset=222 + .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 + .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 +.Ldebug_addr_end0: + .ident "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 37d6c1cc7d4dd3a8a47ba62254bc88521bd50d66)" + .section ".note.GNU-stack","",@progbits + .addrsig + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/bolt/test/X86/dwarf4-cross-cu-loclist-dwarf4-loclist--dwarf5-loclist.test b/bolt/test/X86/dwarf4-cross-cu-loclist-dwarf4-loclist--dwarf5-loclist.test new file mode 100644 --- /dev/null +++ b/bolt/test/X86/dwarf4-cross-cu-loclist-dwarf4-loclist--dwarf5-loclist.test @@ -0,0 +1,60 @@ +# REQUIRES: system-linux + +# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-cross-cu-with-loclist.s -o %t.o +# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-loclist.s -o %t1.o +# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-two-entries-loclist.s -o %t2.o +# RUN: %clang %cflags %t1.o %t2.o %t.o -o %t.exe +# 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 + +# Tests that BOLT correctly handles location list with DWARF5/DWARF4 when order of CUs is not the same as in input. + +# PRECHECK: version = 0x0005 +# PRECHECK: version = 0x0004 +# PRECHECK: version = 0x0004 +# PRECHECK: version = 0x0004 + +# POSTCHECK: version = 0x0004 +# POSTCHECK: DW_TAG_formal_parameter +# POSTCHECK-NEXT: DW_AT_location +# POSTCHECK-NEXT: DW_AT_name +# POSTCHECK-NEXT: DW_AT_decl_file +# POSTCHECK-NEXT: DW_AT_decl_line +# POSTCHECK-NEXT: DW_AT_type [DW_FORM_ref_addr] +# POSTCHECK-SAME: "int") + +# POSTCHECK: DW_TAG_variable +# POSTCHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] +# POSTCHECK-NEXT: [0x[[#%.16x,ADDR1:]] +# POSTCHECK-SAME: 0x[[#ADDR1 + 0x8]]): +# POSTCHECK-SAME: DW_OP_reg5 RDI, DW_OP_piece 0x4, DW_OP_lit3, DW_OP_stack_value, DW_OP_piece 0x4) + +# POSTCHECK: version = 0x0004 +# POSTCHECK: DW_TAG_variable +# POSTCHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] +# POSTCHECK-NEXT: [0x[[#%.16x,ADDR2:]] +# POSTCHECK-SAME: 0x[[#ADDR2 + 0x4]]): +# POSTCHECK-SAME: DW_OP_reg5 RDI, DW_OP_piece 0x4, DW_OP_lit3, DW_OP_stack_value, DW_OP_piece 0x4) + +# POSTCHECK: version = 0x0005 +# POSTCHECK: DW_TAG_variable +# POSTCHECK-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0) loclist +# POSTCHECK-NEXT: [0x[[#%.16x,ADDR3:]] +# POSTCHECK-SAME: 0x[[#ADDR3 + 0x4]]): +# POSTCHECK-SAME: DW_OP_reg5 RDI, DW_OP_piece 0x4, DW_OP_lit3, DW_OP_stack_value, DW_OP_piece 0x4) + +# POSTCHECK: version = 0x0004 +# POSTCHECK: DW_TAG_formal_parameter +# POSTCHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] +# POSTCHECK-NEXT: [0x[[#%.16x,ADDR4:]] +# POSTCHECK-SAME: 0x[[#ADDR4 + 0x8]]): DW_OP_reg5 RDI +# POSTCHECK-NEXT: [0x[[#%.16x,ADDR5:]] +# POSTCHECK-SAME: 0x[[#ADDR5 + 0x16]]): DW_OP_GNU_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value) +# POSTCHECK: DW_TAG_formal_parameter +# POSTCHECK: DW_TAG_formal_parameter +# POSTCHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] +# POSTCHECK-NEXT: [0x[[#%.16x,ADDR6:]] +# POSTCHECK-SAME: 0x[[#ADDR6 + 0x8]]): DW_OP_reg5 RDI +# POSTCHECK-NEXT: [0x[[#%.16x,ADDR7:]] +# POSTCHECK-SAME: 0x[[#ADDR7 + 0x16]]): DW_OP_GNU_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value)