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