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