[llvm] r374600 - DebugInfo: Use base address selection entries for debug_loc

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 4 17:09:42 PST 2019


On Mon, Nov 4, 2019 at 5:00 PM Reid Kleckner <rnk at google.com> wrote:

> This appears to cause dsymutil to assert: https://crbug.com/1019517
> Assertion failed: (Die >= First && Die < First + DieArray.size()),
> function getDIEIndex, file
> /b/rr/tmp9JWo9i/w/src/third_party/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h,
> line 236.
>
> Should this be conditional on some feature like DWARF 5, gdb tuning, lldb
> tuning, OS, or something else?
>

Ideally not - it's a DWARF 4 feature & some LLDB and dsymutil bugs were
cleaned up when this was first committed - maybe you're running an older
dsymutil? Or are you running dsymutil built from the same (recent) version
of the LLVM tree?


>
> On Fri, Oct 11, 2019 at 2:50 PM David Blaikie via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: dblaikie
>> Date: Fri Oct 11 14:52:41 2019
>> New Revision: 374600
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=374600&view=rev
>> Log:
>> DebugInfo: Use base address selection entries for debug_loc
>>
>> Unify the range and loc emission (for both DWARFv4 and DWARFv5 style
>> lists) and take advantage of that unification to use strategic base
>> addresses for loclists.
>>
>> Differential Revision: https://reviews.llvm.org/D68620
>>
>> Modified:
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>>     llvm/trunk/test/CodeGen/X86/debug-loclists.ll
>>     llvm/trunk/test/DebugInfo/X86/sret.ll
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=374600&r1=374599&r2=374600&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Oct 11 14:52:41
>> 2019
>> @@ -2293,14 +2293,121 @@ static MCSymbol *emitLoclistsTableHeader
>>    return TableEnd;
>>  }
>>
>> +template <typename Ranges, typename PayloadEmitter>
>> +static void emitRangeList(
>> +    DwarfDebug &DD, AsmPrinter *Asm, MCSymbol *Sym, const Ranges &R,
>> +    const DwarfCompileUnit &CU, unsigned BaseAddressx, unsigned
>> OffsetPair,
>> +    unsigned StartxLength, unsigned EndOfList,
>> +    StringRef (*StringifyEnum)(unsigned),
>> +    bool ShouldUseBaseAddress,
>> +    PayloadEmitter EmitPayload) {
>> +
>> +  auto Size = Asm->MAI->getCodePointerSize();
>> +  bool UseDwarf5 = DD.getDwarfVersion() >= 5;
>> +
>> +  // Emit our symbol so we can find the beginning of the range.
>> +  Asm->OutStreamer->EmitLabel(Sym);
>> +
>> +  // Gather all the ranges that apply to the same section so they can
>> share
>> +  // a base address entry.
>> +  MapVector<const MCSection *, std::vector<decltype(&*R.begin())>>
>> SectionRanges;
>> +
>> +  for (const auto &Range : R)
>> +    SectionRanges[&Range.Begin->getSection()].push_back(&Range);
>> +
>> +  const MCSymbol *CUBase = CU.getBaseAddress();
>> +  bool BaseIsSet = false;
>> +  for (const auto &P : SectionRanges) {
>> +    auto *Base = CUBase;
>> +    if (!Base && ShouldUseBaseAddress) {
>> +      const MCSymbol *Begin = P.second.front()->Begin;
>> +      const MCSymbol *NewBase = DD.getSectionLabel(&Begin->getSection());
>> +      if (!UseDwarf5) {
>> +        Base = NewBase;
>> +        BaseIsSet = true;
>> +        Asm->OutStreamer->EmitIntValue(-1, Size);
>> +        Asm->OutStreamer->AddComment("  base address");
>> +        Asm->OutStreamer->EmitSymbolValue(Base, Size);
>> +      } else if (NewBase != Begin || P.second.size() > 1) {
>> +        // Only use a base address if
>> +        //  * the existing pool address doesn't match (NewBase != Begin)
>> +        //  * or, there's more than one entry to share the base address
>> +        Base = NewBase;
>> +        BaseIsSet = true;
>> +        Asm->OutStreamer->AddComment(StringifyEnum(BaseAddressx));
>> +        Asm->emitInt8(BaseAddressx);
>> +        Asm->OutStreamer->AddComment("  base address index");
>> +        Asm->EmitULEB128(DD.getAddressPool().getIndex(Base));
>> +      }
>> +    } else if (BaseIsSet && !UseDwarf5) {
>> +      BaseIsSet = false;
>> +      assert(!Base);
>> +      Asm->OutStreamer->EmitIntValue(-1, Size);
>> +      Asm->OutStreamer->EmitIntValue(0, Size);
>> +    }
>> +
>> +    for (const auto *RS : P.second) {
>> +      const MCSymbol *Begin = RS->Begin;
>> +      const MCSymbol *End = RS->End;
>> +      assert(Begin && "Range without a begin symbol?");
>> +      assert(End && "Range without an end symbol?");
>> +      if (Base) {
>> +        if (UseDwarf5) {
>> +          // Emit offset_pair when we have a base.
>> +          Asm->OutStreamer->AddComment(StringifyEnum(OffsetPair));
>> +          Asm->emitInt8(OffsetPair);
>> +          Asm->OutStreamer->AddComment("  starting offset");
>> +          Asm->EmitLabelDifferenceAsULEB128(Begin, Base);
>> +          Asm->OutStreamer->AddComment("  ending offset");
>> +          Asm->EmitLabelDifferenceAsULEB128(End, Base);
>> +        } else {
>> +          Asm->EmitLabelDifference(Begin, Base, Size);
>> +          Asm->EmitLabelDifference(End, Base, Size);
>> +        }
>> +      } else if (UseDwarf5) {
>> +        Asm->OutStreamer->AddComment(StringifyEnum(StartxLength));
>> +        Asm->emitInt8(StartxLength);
>> +        Asm->OutStreamer->AddComment("  start index");
>> +        Asm->EmitULEB128(DD.getAddressPool().getIndex(Begin));
>> +        Asm->OutStreamer->AddComment("  length");
>> +        Asm->EmitLabelDifferenceAsULEB128(End, Begin);
>> +      } else {
>> +        Asm->OutStreamer->EmitSymbolValue(Begin, Size);
>> +        Asm->OutStreamer->EmitSymbolValue(End, Size);
>> +      }
>> +      EmitPayload(*RS);
>> +    }
>> +  }
>> +
>> +  if (UseDwarf5) {
>> +    Asm->OutStreamer->AddComment(StringifyEnum(EndOfList));
>> +    Asm->emitInt8(EndOfList);
>> +  } else {
>> +    // Terminate the list with two 0 values.
>> +    Asm->OutStreamer->EmitIntValue(0, Size);
>> +    Asm->OutStreamer->EmitIntValue(0, Size);
>> +  }
>> +}
>> +
>> +static void emitLocList(DwarfDebug &DD, AsmPrinter *Asm, const
>> DebugLocStream::List &List) {
>> +  emitRangeList(
>> +      DD, Asm, List.Label, DD.getDebugLocs().getEntries(List), *List.CU,
>> +      dwarf::DW_LLE_base_addressx, dwarf::DW_LLE_offset_pair,
>> +      dwarf::DW_LLE_startx_length, dwarf::DW_LLE_end_of_list,
>> +      llvm::dwarf::LocListEncodingString,
>> +      /* ShouldUseBaseAddress */ true,
>> +      [&](const DebugLocStream::Entry &E) {
>> +        DD.emitDebugLocEntryLocation(E, List.CU);
>> +      });
>> +}
>> +
>>  // Emit locations into the .debug_loc/.debug_rnglists section.
>>  void DwarfDebug::emitDebugLoc() {
>>    if (DebugLocs.getLists().empty())
>>      return;
>>
>> -  bool IsLocLists = getDwarfVersion() >= 5;
>>    MCSymbol *TableEnd = nullptr;
>> -  if (IsLocLists) {
>> +  if (getDwarfVersion() >= 5) {
>>      Asm->OutStreamer->SwitchSection(
>>          Asm->getObjFileLowering().getDwarfLoclistsSection());
>>      TableEnd = emitLoclistsTableHeader(Asm, useSplitDwarf() ?
>> SkeletonHolder
>> @@ -2310,63 +2417,8 @@ void DwarfDebug::emitDebugLoc() {
>>          Asm->getObjFileLowering().getDwarfLocSection());
>>    }
>>
>> -  unsigned char Size = Asm->MAI->getCodePointerSize();
>> -  for (const auto &List : DebugLocs.getLists()) {
>> -    Asm->OutStreamer->EmitLabel(List.Label);
>> -
>> -    const DwarfCompileUnit *CU = List.CU;
>> -    const MCSymbol *Base = CU->getBaseAddress();
>> -    for (const auto &Entry : DebugLocs.getEntries(List)) {
>> -      if (Base) {
>> -        // Set up the range. This range is relative to the entry point
>> of the
>> -        // compile unit. This is a hard coded 0 for low_pc when we're
>> emitting
>> -        // ranges, or the DW_AT_low_pc on the compile unit otherwise.
>> -        if (IsLocLists) {
>> -          Asm->OutStreamer->AddComment("DW_LLE_offset_pair");
>> -          Asm->OutStreamer->EmitIntValue(dwarf::DW_LLE_offset_pair, 1);
>> -          Asm->OutStreamer->AddComment("  starting offset");
>> -          Asm->EmitLabelDifferenceAsULEB128(Entry.Begin, Base);
>> -          Asm->OutStreamer->AddComment("  ending offset");
>> -          Asm->EmitLabelDifferenceAsULEB128(Entry.End, Base);
>> -        } else {
>> -          Asm->EmitLabelDifference(Entry.Begin, Base, Size);
>> -          Asm->EmitLabelDifference(Entry.End, Base, Size);
>> -        }
>> -
>> -        emitDebugLocEntryLocation(Entry, CU);
>> -        continue;
>> -      }
>> -
>> -      // We have no base address.
>> -      if (IsLocLists) {
>> -        // TODO: Use DW_LLE_base_addressx + DW_LLE_offset_pair, or
>> -        // DW_LLE_startx_length in case if there is only a single range.
>> -        // That should reduce the size of the debug data emited.
>> -        // For now just use the DW_LLE_startx_length for all cases.
>> -        Asm->OutStreamer->AddComment("DW_LLE_startx_length");
>> -        Asm->emitInt8(dwarf::DW_LLE_startx_length);
>> -        Asm->OutStreamer->AddComment("  start idx");
>> -        Asm->EmitULEB128(AddrPool.getIndex(Entry.Begin));
>> -        Asm->OutStreamer->AddComment("  length");
>> -        Asm->EmitLabelDifferenceAsULEB128(Entry.End, Entry.Begin);
>> -      } else {
>> -        Asm->OutStreamer->EmitSymbolValue(Entry.Begin, Size);
>> -        Asm->OutStreamer->EmitSymbolValue(Entry.End, Size);
>> -      }
>> -
>> -      emitDebugLocEntryLocation(Entry, CU);
>> -    }
>> -
>> -    if (IsLocLists) {
>> -      // .debug_loclists section ends with DW_LLE_end_of_list.
>> -      Asm->OutStreamer->AddComment("DW_LLE_end_of_list");
>> -      Asm->OutStreamer->EmitIntValue(dwarf::DW_LLE_end_of_list, 1);
>> -    } else {
>> -      // Terminate the .debug_loc list with two 0 values.
>> -      Asm->OutStreamer->EmitIntValue(0, Size);
>> -      Asm->OutStreamer->EmitIntValue(0, Size);
>> -    }
>> -  }
>> +  for (const auto &List : DebugLocs.getLists())
>> +    emitLocList(*this, Asm, List);
>>
>>    if (TableEnd)
>>      Asm->OutStreamer->EmitLabel(TableEnd);
>> @@ -2556,103 +2608,16 @@ void DwarfDebug::emitDebugARanges() {
>>    }
>>  }
>>
>> -template <typename Ranges>
>> -static void emitRangeList(DwarfDebug &DD, AsmPrinter *Asm, MCSymbol *Sym,
>> -                          const Ranges &R, const DwarfCompileUnit &CU,
>> -                          unsigned BaseAddressx, unsigned OffsetPair,
>> -                          unsigned StartxLength, unsigned EndOfList,
>> -                          StringRef (*StringifyEnum)(unsigned)) {
>> -  auto DwarfVersion = DD.getDwarfVersion();
>> -  // Emit our symbol so we can find the beginning of the range.
>> -  Asm->OutStreamer->EmitLabel(Sym);
>> -  // Gather all the ranges that apply to the same section so they can
>> share
>> -  // a base address entry.
>> -  MapVector<const MCSection *, std::vector<const RangeSpan *>>
>> SectionRanges;
>> -  // Size for our labels.
>> -  auto Size = Asm->MAI->getCodePointerSize();
>> -
>> -  for (const RangeSpan &Range : R)
>> -    SectionRanges[&Range.Begin->getSection()].push_back(&Range);
>> -
>> -  const MCSymbol *CUBase = CU.getBaseAddress();
>> -  bool BaseIsSet = false;
>> -  for (const auto &P : SectionRanges) {
>> -    // Don't bother with a base address entry if there's only one range
>> in
>> -    // this section in this range list - for example ranges for a CU will
>> -    // usually consist of single regions from each of many sections
>> -    // (-ffunction-sections, or just C++ inline functions) except under
>> LTO
>> -    // or optnone where there may be holes in a single CU's section
>> -    // contributions.
>> -    auto *Base = CUBase;
>> -    if (!Base && (P.second.size() > 1 || DwarfVersion < 5) &&
>> -        (CU.getCUNode()->getRangesBaseAddress() || DwarfVersion >= 5)) {
>> -      BaseIsSet = true;
>> -      Base = DD.getSectionLabel(&P.second.front()->Begin->getSection());
>> -      if (DwarfVersion >= 5) {
>> -        Asm->OutStreamer->AddComment(StringifyEnum(BaseAddressx));
>> -        Asm->OutStreamer->EmitIntValue(BaseAddressx, 1);
>> -        Asm->OutStreamer->AddComment("  base address index");
>> -        Asm->EmitULEB128(DD.getAddressPool().getIndex(Base));
>> -      } else {
>> -        Asm->OutStreamer->EmitIntValue(-1, Size);
>> -        Asm->OutStreamer->AddComment("  base address");
>> -        Asm->OutStreamer->EmitSymbolValue(Base, Size);
>> -      }
>> -    } else if (BaseIsSet && DwarfVersion < 5) {
>> -      BaseIsSet = false;
>> -      assert(!Base);
>> -      Asm->OutStreamer->EmitIntValue(-1, Size);
>> -      Asm->OutStreamer->EmitIntValue(0, Size);
>> -    }
>> -
>> -    for (const auto *RS : P.second) {
>> -      const MCSymbol *Begin = RS->Begin;
>> -      const MCSymbol *End = RS->End;
>> -      assert(Begin && "Range without a begin symbol?");
>> -      assert(End && "Range without an end symbol?");
>> -      if (Base) {
>> -        if (DwarfVersion >= 5) {
>> -          // Emit DW_RLE_offset_pair when we have a base.
>> -          Asm->OutStreamer->AddComment(StringifyEnum(OffsetPair));
>> -          Asm->emitInt8(OffsetPair);
>> -          Asm->OutStreamer->AddComment("  starting offset");
>> -          Asm->EmitLabelDifferenceAsULEB128(Begin, Base);
>> -          Asm->OutStreamer->AddComment("  ending offset");
>> -          Asm->EmitLabelDifferenceAsULEB128(End, Base);
>> -        } else {
>> -          Asm->EmitLabelDifference(Begin, Base, Size);
>> -          Asm->EmitLabelDifference(End, Base, Size);
>> -        }
>> -      } else if (DwarfVersion >= 5) {
>> -        Asm->OutStreamer->AddComment(StringifyEnum(StartxLength));
>> -        Asm->emitInt8(StartxLength);
>> -        Asm->OutStreamer->AddComment("  start index");
>> -        Asm->EmitULEB128(DD.getAddressPool().getIndex(Begin));
>> -        Asm->OutStreamer->AddComment("  length");
>> -        Asm->EmitLabelDifferenceAsULEB128(End, Begin);
>> -      } else {
>> -        Asm->OutStreamer->EmitSymbolValue(Begin, Size);
>> -        Asm->OutStreamer->EmitSymbolValue(End, Size);
>> -      }
>> -    }
>> -  }
>> -  if (DwarfVersion >= 5) {
>> -    Asm->OutStreamer->AddComment(StringifyEnum(EndOfList));
>> -    Asm->emitInt8(EndOfList);
>> -  } else {
>> -    // Terminate the list with two 0 values.
>> -    Asm->OutStreamer->EmitIntValue(0, Size);
>> -    Asm->OutStreamer->EmitIntValue(0, Size);
>> -  }
>> -}
>> -
>>  /// Emit a single range list. We handle both DWARF v5 and earlier.
>>  static void emitRangeList(DwarfDebug &DD, AsmPrinter *Asm,
>>                            const RangeSpanList &List) {
>>    emitRangeList(DD, Asm, List.getSym(), List.getRanges(), List.getCU(),
>>                  dwarf::DW_RLE_base_addressx, dwarf::DW_RLE_offset_pair,
>>                  dwarf::DW_RLE_startx_length, dwarf::DW_RLE_end_of_list,
>> -                llvm::dwarf::RangeListEncodingString);
>> +                llvm::dwarf::RangeListEncodingString,
>> +                List.getCU().getCUNode()->getRangesBaseAddress() ||
>> +                    DD.getDwarfVersion() >= 5,
>> +                [](auto) {});
>>  }
>>
>>  static void emitDebugRangesImpl(DwarfDebug &DD, AsmPrinter *Asm,
>>
>> Modified: llvm/trunk/test/CodeGen/X86/debug-loclists.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/debug-loclists.ll?rev=374600&r1=374599&r2=374600&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/X86/debug-loclists.ll (original)
>> +++ llvm/trunk/test/CodeGen/X86/debug-loclists.ll Fri Oct 11 14:52:41 2019
>> @@ -1,144 +1,119 @@
>> -; RUN: llc -mtriple=x86_64-pc-linux -filetype=obj -o %t < %s
>> -; RUN: llvm-dwarfdump -v %t | FileCheck %s
>> +; RUN: llc -mtriple=x86_64-pc-linux -filetype=obj -function-sections -o
>> %t < %s
>> +; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | FileCheck %s
>>
>> -; CHECK:      0x00000033: DW_TAG_formal_parameter [3]
>> -; CHECK-NEXT:               DW_AT_location [DW_FORM_sec_offset]
>>  (0x0000000c
>> -; CHECK-NEXT:                  [0x0000000000000000, 0x0000000000000004):
>> DW_OP_breg5 RDI+0
>> -; CHECK-NEXT:                  [0x0000000000000004, 0x0000000000000012):
>> DW_OP_breg3 RBX+0)
>> -; CHECK-NEXT:               DW_AT_name [DW_FORM_strx1]    (indexed
>> (0000000e) string = "a")
>> -; CHECK-NEXT:               DW_AT_decl_file [DW_FORM_data1]
>>  ("/home/folder{{\\|\/}}test.cc")
>> -; CHECK-NEXT:               DW_AT_decl_line [DW_FORM_data1]       (6)
>> -; CHECK-NEXT:               DW_AT_type [DW_FORM_ref4]     (cu + 0x0040
>> => {0x00000040} "A")
>> +; CHECK:      DW_TAG_variable
>> +; FIXME: Use DW_FORM_loclistx to reduce relocations
>> +; CHECK-NEXT:   DW_AT_location [DW_FORM_sec_offset]   (0x0000000c
>> +; CHECK-NEXT:     [0x0000000000000000, 0x0000000000000003): DW_OP_consts
>> +3, DW_OP_stack_value
>> +; CHECK-NEXT:     [0x0000000000000003, 0x0000000000000004): DW_OP_consts
>> +4, DW_OP_stack_value)
>> +; CHECK-NEXT:   DW_AT_name {{.*}} "y"
>> +
>> +; CHECK:      DW_TAG_variable
>> +; FIXME: Use DW_FORM_loclistx to reduce relocations
>> +; CHECK-NEXT:   DW_AT_location [DW_FORM_sec_offset]   (0x0000001d
>> +; CHECK-NEXT:     Addr idx 0 (w/ length 3): DW_OP_consts +5,
>> DW_OP_stack_value)
>> +; CHECK-NEXT:   DW_AT_name {{.*}} "x"
>> +
>> +; CHECK:      DW_TAG_variable
>> +; FIXME: Use DW_FORM_loclistx to reduce relocations
>> +; CHECK-NEXT:   DW_AT_location [DW_FORM_sec_offset]   (0x00000025
>> +; CHECK-NEXT:     [0x0000000000000003, 0x0000000000000004): DW_OP_reg0
>> RAX)
>> +; CHECK-NEXT:   DW_AT_name {{.*}} "r"
>>
>>  ; CHECK:      .debug_loclists contents:
>> -; CHECK-NEXT: 0x00000000: locations list header: length = 0x00000015,
>> version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count =
>> 0x00000000
>> -; CHECK-NEXT: 0x0000000c:
>> -; CHECK-NEXT: DW_LLE_offset_pair(0x0000000000000000, 0x0000000000000004)
>> -; CHECK-NEXT:                => [0x0000000000000000,
>> 0x0000000000000004): DW_OP_breg5 RDI+0
>> -; CHECK-NEXT: DW_LLE_offset_pair(0x0000000000000004, 0x0000000000000012)
>> -; CHECK-NEXT:                => [0x0000000000000004,
>> 0x0000000000000012): DW_OP_breg3 RBX+0
>> -
>> -; There is no way to use llvm-dwarfdump atm (2018, october) to verify
>> the DW_LLE_* codes emited,
>> -; because dumper is not yet implements that. Use asm code to do this
>> check instead.
>> -;
>> -; RUN: llc -mtriple=x86_64-pc-linux -filetype=asm < %s -o - | FileCheck
>> %s --check-prefix=ASM
>> -; ASM:      .section .debug_loclists,"", at progbits
>> -; ASM-NEXT: .long
>> .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0 # Length
>> -; ASM-NEXT: .Ldebug_loclist_table_start0:
>> -; ASM-NEXT:  .short 5                              # Version
>> -; ASM-NEXT:  .byte 8                               # Address size
>> -; ASM-NEXT:  .byte 0                               # Segment selector
>> size
>> -; ASM-NEXT:  .long 0                               # Offset entry count
>> -; ASM-NEXT: .Lloclists_table_base0:
>> -; ASM-NEXT: .Ldebug_loc0:
>> -; ASM-NEXT:  .byte 4                               # DW_LLE_offset_pair
>> -; ASM-NEXT:  .uleb128 .Lfunc_begin0-.Lfunc_begin0  # starting offset
>> -; ASM-NEXT:  .uleb128 .Ltmp0-.Lfunc_begin0         # ending offset
>> -; ASM-NEXT:  .byte 2                               # Loc expr size
>> -; ASM-NEXT:  .byte 117                             # DW_OP_breg5
>> -; ASM-NEXT:  .byte 0                               # 0
>> -; ASM-NEXT:  .byte 4                               # DW_LLE_offset_pair
>> -; ASM-NEXT:  .uleb128 .Ltmp0-.Lfunc_begin0         # starting offset
>> -; ASM-NEXT:  .uleb128 .Ltmp1-.Lfunc_begin0         # ending offset
>> -; ASM-NEXT:  .byte 2                               # Loc expr size
>> -; ASM-NEXT:  .byte 115                             # DW_OP_breg3
>> -; ASM-NEXT:  .byte 0                               # 0
>> -; ASM-NEXT:  .byte 0                               # DW_LLE_end_of_list
>> -; ASM-NEXT: .Ldebug_loclist_table_end0:
>> -
>> -; ModuleID = 'test.cc'
>> -source_filename = "test.cc"
>> -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
>> -target triple = "x86_64-unknown-linux-gnu"
>> -
>> -%struct.A = type { i32 (...)** }
>> -
>> - at _ZTV1A = dso_local unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8*
>> null, i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast (void
>> (%struct.A*)* @_ZN1A3fooEv to i8*), i8* bitcast (void (%struct.A*)*
>> @_ZN1A3barEv to i8*)] }, align 8
>> - at _ZTVN10__cxxabiv117__class_type_infoE = external dso_local global i8*
>> - at _ZTS1A = dso_local constant [3 x i8] c"1A\00", align 1
>> - at _ZTI1A = dso_local constant { i8*, i8* } { i8* bitcast (i8**
>> getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE,
>> i64 2) to i8*), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZTS1A,
>> i32 0, i32 0) }, align 8
>> -
>> -; Function Attrs: noinline optnone uwtable
>> -define dso_local void @_Z3baz1A(%struct.A* %a) #0 !dbg !7 {
>> -entry:
>> -  call void @llvm.dbg.declare(metadata %struct.A* %a, metadata !23,
>> metadata !DIExpression()), !dbg !24
>> -  call void @_ZN1A3fooEv(%struct.A* %a), !dbg !25
>> -  call void @_ZN1A3barEv(%struct.A* %a), !dbg !26
>> -  ret void, !dbg !27
>> -}
>> +; CHECK-NEXT: 0x00000000: locations list header: length = 0x00000029,
>> version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count =
>> 0x00000000
>>
>> -; Function Attrs: nounwind readnone speculatable
>> -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
>> +; Don't use startx_length if there's more than one entry, because the
>> shared
>> +; base address will be useful for both the range that does start at the
>> start of
>> +; the function, and the one that doesn't.
>>
>> -; Function Attrs: noinline nounwind optnone uwtable
>> -define dso_local void @_ZN1A3fooEv(%struct.A* %this) unnamed_addr #2
>> align 2 !dbg !28 {
>> -entry:
>> -  %this.addr = alloca %struct.A*, align 8
>> -  store %struct.A* %this, %struct.A** %this.addr, align 8
>> -  call void @llvm.dbg.declare(metadata %struct.A** %this.addr, metadata
>> !29, metadata !DIExpression()), !dbg !31
>> -  %this1 = load %struct.A*, %struct.A** %this.addr, align 8
>> -  ret void, !dbg !32
>> -}
>> +; CHECK-NEXT: 0x0000000c:
>> +; CHECK-NEXT:             DW_LLE_base_addressx(0x0000000000000000)
>> +; CHECK-NEXT:             DW_LLE_offset_pair  (0x0000000000000000,
>> 0x0000000000000003)
>> +; CHECK-NEXT:                              => [0x0000000000000000,
>> 0x0000000000000003): DW_OP_consts +3, DW_OP_stack_value
>> +; CHECK-NEXT:             DW_LLE_offset_pair  (0x0000000000000003,
>> 0x0000000000000004)
>> +; CHECK-NEXT:                              => [0x0000000000000003,
>> 0x0000000000000004): DW_OP_consts +4, DW_OP_stack_value
>> +; CHECK-NEXT:             DW_LLE_end_of_list  ()
>> +
>> +; Show that startx_length can be used when the address range starts at
>> the start of the function.
>> +
>> +; CHECK:      0x0000001d:
>> +; CHECK-NEXT:             DW_LLE_startx_length(0x0000000000000000,
>> 0x0000000000000003)
>> +; CHECK-NEXT:                              => Addr idx 0 (w/ length 3):
>> DW_OP_consts +5, DW_OP_stack_value
>> +; CHECK-NEXT:             DW_LLE_end_of_list  ()
>> +
>> +; And use a base address when the range doesn't start at an
>> existing/useful
>> +; address in the pool.
>> +
>> +; CHECK:      0x00000025:
>> +; CHECK-NEXT:             DW_LLE_base_addressx(0x0000000000000000)
>> +; CHECK-NEXT:             DW_LLE_offset_pair  (0x0000000000000003,
>> 0x0000000000000004)
>> +; CHECK-NEXT:                              => [0x0000000000000003,
>> 0x0000000000000004): DW_OP_reg0 RAX
>> +; CHECK-NEXT:             DW_LLE_end_of_list  ()
>> +
>> +; Built with clang -O3 -ffunction-sections from source:
>> +;
>> +; int f1(int i, int j) {
>> +;   int x = 5;
>> +;   int y = 3;
>> +;   int r = i + j;
>> +;   int undef;
>> +;   x = undef;
>> +;   y = 4;
>> +;   return r;
>> +; }
>> +; void f2() {
>> +; }
>>
>> -; Function Attrs: noinline nounwind optnone uwtable
>> -define dso_local void @_ZN1A3barEv(%struct.A* %this) unnamed_addr #2
>> align 2 !dbg !33 {
>> +; Function Attrs: norecurse nounwind readnone uwtable
>> +define dso_local i32 @_Z2f1ii(i32 %i, i32 %j) local_unnamed_addr !dbg !7
>> {
>>  entry:
>> -  %this.addr = alloca %struct.A*, align 8
>> -  store %struct.A* %this, %struct.A** %this.addr, align 8
>> -  call void @llvm.dbg.declare(metadata %struct.A** %this.addr, metadata
>> !34, metadata !DIExpression()), !dbg !35
>> -  %this1 = load %struct.A*, %struct.A** %this.addr, align 8
>> -  ret void, !dbg !36
>> +  call void @llvm.dbg.value(metadata i32 %i, metadata !12, metadata
>> !DIExpression()), !dbg !18
>> +  call void @llvm.dbg.value(metadata i32 %j, metadata !13, metadata
>> !DIExpression()), !dbg !18
>> +  call void @llvm.dbg.value(metadata i32 5, metadata !14, metadata
>> !DIExpression()), !dbg !18
>> +  call void @llvm.dbg.value(metadata i32 3, metadata !15, metadata
>> !DIExpression()), !dbg !18
>> +  %add = add nsw i32 %j, %i, !dbg !19
>> +  call void @llvm.dbg.value(metadata i32 %add, metadata !16, metadata
>> !DIExpression()), !dbg !18
>> +  call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata
>> !DIExpression()), !dbg !18
>> +  call void @llvm.dbg.value(metadata i32 4, metadata !15, metadata
>> !DIExpression()), !dbg !18
>> +  ret i32 %add, !dbg !20
>>  }
>>
>> -; Function Attrs: noinline norecurse nounwind optnone uwtable
>> -define dso_local i32 @main() #3 !dbg !37 {
>> +; Function Attrs: norecurse nounwind readnone uwtable
>> +define dso_local void @_Z2f2v() local_unnamed_addr !dbg !21 {
>>  entry:
>> -  %retval = alloca i32, align 4
>> -  store i32 0, i32* %retval, align 4
>> -  ret i32 0, !dbg !38
>> +  ret void, !dbg !24
>>  }
>>
>> +; Function Attrs: nounwind readnone speculatable willreturn
>> +declare void @llvm.dbg.value(metadata, metadata, metadata)
>>
>>  !llvm.dbg.cu = !{!0}
>>  !llvm.module.flags = !{!3, !4, !5}
>>  !llvm.ident = !{!6}
>>
>> -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1,
>> producer: "clang version 8.0.0 (trunk 344035)", isOptimized: false,
>> runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
>> -!1 = !DIFile(filename: "test.cc", directory: "/home/folder",
>> checksumkind: CSK_MD5, checksum: "e0f357ad6dcb791a774a0dae55baf5e7")
>> +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1,
>> producer: "clang version 10.0.0 (trunk 374581) (llvm/trunk 374579)",
>> isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2,
>> nameTableKind: None)
>> +!1 = !DIFile(filename: "loc2.cpp", directory:
>> "/usr/local/google/home/blaikie/dev/scratch", checksumkind: CSK_MD5,
>> checksum: "91e0069c680e2a63f4f885ec93f5d07e")
>>  !2 = !{}
>>  !3 = !{i32 2, !"Dwarf Version", i32 5}
>>  !4 = !{i32 2, !"Debug Info Version", i32 3}
>>  !5 = !{i32 1, !"wchar_size", i32 4}
>> -!6 = !{!"clang version 8.0.0 (trunk 344035)"}
>> -!7 = distinct !DISubprogram(name: "baz", linkageName: "_Z3baz1A", scope:
>> !1, file: !1, line: 6, type: !8, isLocal: false, isDefinition: true,
>> scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0,
>> retainedNodes: !2)
>> +!6 = !{!"clang version 10.0.0 (trunk 374581) (llvm/trunk 374579)"}
>> +!7 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1ii", scope:
>> !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped |
>> DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized,
>> unit: !0, retainedNodes: !11)
>>  !8 = !DISubroutineType(types: !9)
>> -!9 = !{null, !10}
>> -!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A",
>> file: !1, line: 1, size: 64, flags: DIFlagTypePassByReference, elements:
>> !11, vtableHolder: !10, identifier: "_ZTS1A")
>> -!11 = !{!12, !18, !22}
>> -!12 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$A", scope: !1,
>> file: !1, baseType: !13, size: 64, flags: DIFlagArtificial)
>> -!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)
>> -!14 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type",
>> baseType: !15, size: 64)
>> -!15 = !DISubroutineType(types: !16)
>> -!16 = !{!17}
>> -!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
>> -!18 = !DISubprogram(name: "foo", linkageName: "_ZN1A3fooEv", scope: !10,
>> file: !1, line: 2, type: !19, isLocal: false, isDefinition: false,
>> scopeLine: 2, containingType: !10, virtuality: DW_VIRTUALITY_virtual,
>> virtualIndex: 0, flags: DIFlagPrototyped, isOptimized: false)
>> -!19 = !DISubroutineType(types: !20)
>> -!20 = !{null, !21}
>> -!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64,
>> flags: DIFlagArtificial | DIFlagObjectPointer)
>> -!22 = !DISubprogram(name: "bar", linkageName: "_ZN1A3barEv", scope: !10,
>> file: !1, line: 3, type: !19, isLocal: false, isDefinition: false,
>> scopeLine: 3, containingType: !10, virtuality: DW_VIRTUALITY_virtual,
>> virtualIndex: 1, flags: DIFlagPrototyped, isOptimized: false)
>> -!23 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 6,
>> type: !10)
>> -!24 = !DILocation(line: 6, column: 19, scope: !7)
>> -!25 = !DILocation(line: 7, column: 6, scope: !7)
>> -!26 = !DILocation(line: 8, column: 6, scope: !7)
>> -!27 = !DILocation(line: 9, column: 1, scope: !7)
>> -!28 = distinct !DISubprogram(name: "foo", linkageName: "_ZN1A3fooEv",
>> scope: !10, file: !1, line: 12, type: !19, isLocal: false, isDefinition:
>> true, scopeLine: 12, flags: DIFlagPrototyped, isOptimized: false, unit: !0,
>> declaration: !18, retainedNodes: !2)
>> -!29 = !DILocalVariable(name: "this", arg: 1, scope: !28, type: !30,
>> flags: DIFlagArtificial | DIFlagObjectPointer)
>> -!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
>> -!31 = !DILocation(line: 0, scope: !28)
>> -!32 = !DILocation(line: 12, column: 16, scope: !28)
>> -!33 = distinct !DISubprogram(name: "bar", linkageName: "_ZN1A3barEv",
>> scope: !10, file: !1, line: 13, type: !19, isLocal: false, isDefinition:
>> true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: false, unit: !0,
>> declaration: !22, retainedNodes: !2)
>> -!34 = !DILocalVariable(name: "this", arg: 1, scope: !33, type: !30,
>> flags: DIFlagArtificial | DIFlagObjectPointer)
>> -!35 = !DILocation(line: 0, scope: !33)
>> -!36 = !DILocation(line: 13, column: 16, scope: !33)
>> -!37 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line:
>> 15, type: !15, isLocal: false, isDefinition: true, scopeLine: 15, flags:
>> DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
>> -!38 = !DILocation(line: 16, column: 3, scope: !37)
>> +!9 = !{!10, !10, !10}
>> +!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
>> +!11 = !{!12, !13, !14, !15, !16, !17}
>> +!12 = !DILocalVariable(name: "i", arg: 1, scope: !7, file: !1, line: 1,
>> type: !10)
>> +!13 = !DILocalVariable(name: "j", arg: 2, scope: !7, file: !1, line: 1,
>> type: !10)
>> +!14 = !DILocalVariable(name: "x", scope: !7, file: !1, line: 2, type:
>> !10)
>> +!15 = !DILocalVariable(name: "y", scope: !7, file: !1, line: 3, type:
>> !10)
>> +!16 = !DILocalVariable(name: "r", scope: !7, file: !1, line: 4, type:
>> !10)
>> +!17 = !DILocalVariable(name: "undef", scope: !7, file: !1, line: 5,
>> type: !10)
>> +!18 = !DILocation(line: 0, scope: !7)
>> +!19 = !DILocation(line: 4, column: 13, scope: !7)
>> +!20 = !DILocation(line: 8, column: 3, scope: !7)
>> +!21 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope:
>> !1, file: !1, line: 10, type: !22, scopeLine: 10, flags: DIFlagPrototyped |
>> DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized,
>> unit: !0, retainedNodes: !2)
>> +!22 = !DISubroutineType(types: !23)
>> +!23 = !{null}
>> +!24 = !DILocation(line: 11, column: 1, scope: !21)
>>
>> Modified: llvm/trunk/test/DebugInfo/X86/sret.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/sret.ll?rev=374600&r1=374599&r2=374600&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/DebugInfo/X86/sret.ll (original)
>> +++ llvm/trunk/test/DebugInfo/X86/sret.ll Fri Oct 11 14:52:41 2019
>> @@ -11,6 +11,7 @@
>>  ; CHECK: _ZN1B9AInstanceEv
>>  ; CHECK: DW_TAG_variable
>>  ; CHECK-NEXT:   DW_AT_location [DW_FORM_sec_offset] (0x00000000
>> +; CHECK-NEXT:     [0xffffffffffffffff, {{.*}}): {{$}}
>>  ; CHECK-NEXT:     [{{.*}}, {{.*}}): DW_OP_breg5 RDI+0
>>  ; CHECK-NEXT:     [{{.*}}, {{.*}}): DW_OP_breg6 RBP-24, DW_OP_deref)
>>  ; CHECK-NEXT:   DW_AT_name {{.*}}"a"
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191104/ad772299/attachment-0001.html>


More information about the llvm-commits mailing list