<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 4, 2019 at 7:50 AM <<a href="mailto:paul.robinson@sony.com">paul.robinson@sony.com</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"><br>
<br>
> -----Original Message-----<br>
> From: llvm-commits <<a href="mailto:llvm-commits-bounces@lists.llvm.org" target="_blank">llvm-commits-bounces@lists.llvm.org</a>> On Behalf Of<br>
> David Blaikie via llvm-commits<br>
> Sent: Thursday, October 03, 2019 4:56 PM<br>
> To: <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> Subject: [llvm] r373663 - DebugInfo: Generalize rnglist emission as a<br>
> precursor to reusing it for loclist emission<br>
> <br>
> Author: dblaikie<br>
> Date: Thu Oct  3 13:56:23 2019<br>
> New Revision: 373663<br>
> <br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=373663&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=373663&view=rev</a><br>
> Log:<br>
> DebugInfo: Generalize rnglist emission as a precursor to reusing it for<br>
> loclist emission<br>
> <br>
> Modified:<br>
>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
> <br>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=373663&r1=373<br>
> 662&r2=373663&view=diff<br>
> ==========================================================================<br>
> ====<br>
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Oct  3 13:56:23<br>
> 2019<br>
> @@ -2556,23 +2556,24 @@ void DwarfDebug::emitDebugARanges() {<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>
> -<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(List.getSym());<br>
> +  Asm->OutStreamer->EmitLabel(Sym);<br>
>    // Gather all the ranges that apply to the same section so they can<br>
> share<br>
>    // a base address entry.<br>
>    MapVector<const MCSection *, std::vector<const RangeSpan *>><br>
> SectionRanges;<br>
>    // Size for our labels.<br>
>    auto Size = Asm->MAI->getCodePointerSize();<br>
> <br>
> -  for (const RangeSpan &Range : List.getRanges())<br>
> +  for (const RangeSpan &Range : R)<br>
>      SectionRanges[&Range.Begin->getSection()].push_back(&Range);<br>
> <br>
> -  const DwarfCompileUnit &CU = List.getCU();<br>
>    const MCSymbol *CUBase = CU.getBaseAddress();<br>
>    bool BaseIsSet = false;<br>
>    for (const auto &P : SectionRanges) {<br>
> @@ -2588,8 +2589,8 @@ static void emitRangeList(DwarfDebug &DD<br>
>        BaseIsSet = true;<br>
>        Base = DD.getSectionLabel(&P.second.front()->Begin->getSection());<br>
>        if (DwarfVersion >= 5) {<br>
> -        Asm->OutStreamer->AddComment("DW_RLE_base_addressx");<br>
> -        Asm->OutStreamer->EmitIntValue(dwarf::DW_RLE_base_addressx, 1);<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>
> @@ -2612,8 +2613,8 @@ static void emitRangeList(DwarfDebug &DD<br>
>        if (Base) {<br>
>          if (DwarfVersion >= 5) {<br>
>            // Emit DW_RLE_offset_pair when we have a base.<br>
<br>
This comment should also go, or be rephrased.<br></blockquote><div><br>Ah, yeah - dropping that & a few other things that don't make sense once this is generalized over RLE and LLE in the following patches.<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
--paulr<br>
<br>
> -          Asm->OutStreamer->AddComment("DW_RLE_offset_pair");<br>
> -          Asm->OutStreamer->EmitIntValue(dwarf::DW_RLE_offset_pair, 1);<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>
> @@ -2623,8 +2624,8 @@ static void emitRangeList(DwarfDebug &DD<br>
>            Asm->EmitLabelDifference(End, Base, Size);<br>
>          }<br>
>        } else if (DwarfVersion >= 5) {<br>
> -        Asm->OutStreamer->AddComment("DW_RLE_startx_length");<br>
> -        Asm->OutStreamer->EmitIntValue(dwarf::DW_RLE_startx_length, 1);<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>
> @@ -2636,8 +2637,8 @@ static void emitRangeList(DwarfDebug &DD<br>
>      }<br>
>    }<br>
>    if (DwarfVersion >= 5) {<br>
> -    Asm->OutStreamer->AddComment("DW_RLE_end_of_list");<br>
> -    Asm->OutStreamer->EmitIntValue(dwarf::DW_RLE_end_of_list, 1);<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>
> @@ -2645,6 +2646,15 @@ static void emitRangeList(DwarfDebug &DD<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>
> +}<br>
> +<br>
>  static void emitDebugRangesImpl(DwarfDebug &DD, AsmPrinter *Asm,<br>
>                                  const DwarfFile &Holder, MCSymbol<br>
> *TableEnd) {<br>
>    for (const RangeSpanList &List : Holder.getRangeLists())<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></div>