<div dir="ltr">Sounds like the test should be fixed instead - doesn't look like there's any reason DWARFv4 should get different behavior here, only a bug in the test?</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 30, 2018 at 3:23 PM <<a href="mailto:wolfgang.pieb@sony.com">wolfgang.pieb@sony.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div class="m_8655487292426916382WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">In emitDebugRanges() in DwarfDebug.cpp my original change returns early when there are no ranges to be emitted. This means no __debug_ranges section is created.
 The test looks for __debug_ranges anyway, even though there is only  a trivial function.  I just re-enabled this behavior for DWARF4 and earlier. Reverse patch:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console";color:#40ff40">Index: DwarfDebug.cpp<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">===================================================================<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console";color:#40ff40">--- DwarfDebug.cpp      (revision 338127)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console";color:#40ff40">+++ DwarfDebug.cpp      (working copy)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console";color:#ffff40">@@ -2136,7 +2136,7 @@<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">     return;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">   }<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console";color:#ff4040">-  if (getDwarfVersion() >= 5 && NoRangesPresent())<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console";color:#40ffff">+  if (NoRangesPresent())<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">     return;<u></u><u></u></span></p></div></div><div lang="EN-US" link="blue" vlink="purple"><div class="m_8655487292426916382WordSection1">
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">   // Start the dwarf ranges section.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
</div></div><div lang="EN-US" link="blue" vlink="purple"><div class="m_8655487292426916382WordSection1"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">-- wolfgang<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>]
<br>
<b>Sent:</b> Monday, July 30, 2018 1:44 PM<br>
<b>To:</b> Pieb, Wolfgang; Adrian Prantl; Jonas Devlieghere<br>
<b>Cc:</b> <a href="mailto:arphaman@gmail.com" target="_blank">arphaman@gmail.com</a>; <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a></span></p></div></div></div></div></div><div lang="EN-US" link="blue" vlink="purple"><div class="m_8655487292426916382WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt"><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""><br>
<b>Subject:</b> Re: [llvm] r337981 - [DWARF v5] Don't emit multiple DW_AT_rnglists_base attributes. Some refactoring of<u></u><u></u></span></p></div></div></div></div></div><div lang="EN-US" link="blue" vlink="purple"><div class="m_8655487292426916382WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Adrian, Jonas - could you two take a look at this test failure/issue & see if it could be fixed.<br>
<br>
Wolfgang - what was the change you made/undid from your original patch?<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">On Thu, Jul 26, 2018 at 3:53 PM via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks, Alex.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I resubmitted the patch as r338081 with a fix. It’s a bit unfortunate, b/c the compiler was actually
 being more efficient about not emitting a __debug_ranges section when none is needed. The test, however, checks for it anyway. I didn’t want to mess with the test because its purpose is a bit different, so I restored the old behavior for dwarf version 4 and
 earlier.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Let me know if you see any more problems.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">-- wolfgang</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> llvm-commits [mailto:<a href="mailto:llvm-commits-bounces@lists.llvm.org" target="_blank">llvm-commits-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Alex L via llvm-commits<br>
<b>Sent:</b> Wednesday, July 25, 2018 8:23 PM<br>
<b>To:</b> Pieb, Wolfgang<br>
<b>Cc:</b> Alex Lorenz via llvm-commits<br>
<b>Subject:</b> Re: [llvm] r337981 - [DWARF v5] Don't emit multiple DW_AT_rnglists_base attributes. Some refactoring of</span><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Unfortunately I had to revert this commit (revert in r337997) as it caused a regression in the debuginfo-tests:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.5pt;font-family:"Courier New";color:#333333">FAIL: debuginfo-tests :: apple-accel.cpp (40748 of 46595)
</span><span style="font-size:11.5pt;font-family:"Courier New";color:white;background:red">******************** TEST 'debuginfo-tests :: apple-accel.cpp' FAILED ********************
</span><span style="font-size:11.5pt;font-family:"Courier New";color:#333333">Script: -- : 'RUN: at line 6'; /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/clang-build/bin/clang /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/tools/clang/test/debuginfo-tests/apple-accel.cpp
 --target=x86_64-apple-darwin17.6.0 -gdwarf-2 -O0 -c -g -o /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/clang-build/tools/clang/test/debuginfo-tests/Output/apple-accel.cpp.tmp-ex : 'RUN: at line 7'; llvm-objdump -section-headers /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/clang-build/tools/clang/test/debuginfo-tests/Output/apple-accel.cpp.tmp-ex
 | /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/clang-build/bin/FileCheck /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/tools/clang/test/debuginfo-tests/apple-accel.cpp : 'RUN: at line 8'; /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/clang-build/bin/clang
 /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/tools/clang/test/debuginfo-tests/apple-accel.cpp --target=x86_64-apple-darwin17.6.0 -gdwarf-4 -O0 -c -g -o /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/clang-build/tools/clang/test/debuginfo-tests/Output/apple-accel.cpp.tmp-ex
 : 'RUN: at line 9'; llvm-objdump -section-headers /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/clang-build/tools/clang/test/debuginfo-tests/Output/apple-accel.cpp.tmp-ex | /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/clang-build/bin/FileCheck
 /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/tools/clang/test/debuginfo-tests/apple-accel.cpp -- Exit Code: 1 Command Output (stderr): --
</span><span style="font-size:11.5pt;font-family:"Courier New";color:white;background:red">/Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/tools/clang/test/debuginfo-tests/apple-accel.cpp:16:16: error: CHECK-NEXT: expected string not found
 in input </span><span style="font-size:11.5pt;font-family:"Courier New";color:#333333">// CHECK-NEXT: __debug_ranges ^ <stdin>:9:17: note: scanning from here 3 __debug_info 00000087 0000000000000182 DATA ^ <stdin>:10:4: note: possible intended match here 4
 __debug_macinfo 00000001 0000000000000209 DATA ^ -- ********************</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Here's the failure in our CI:
<a href="http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/47691/consoleFull" target="_blank">
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/47691/consoleFull</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Let me know if you need assistance investigating/verifying a fix.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Alex<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On 25 July 2018 at 16:03, Wolfgang Pieb via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal">Author: wolfgangp<br>
Date: Wed Jul 25 16:03:22 2018<br>
New Revision: 337981<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=337981&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=337981&view=rev</a><br>
Log:<br>
[DWARF v5] Don't emit multiple DW_AT_rnglists_base attributes. Some refactoring of<br>
range lists emissions and added test cases.<br>
<br>
Reviewer: dblaikie<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D49522" target="_blank">
https://reviews.llvm.org/D49522</a><br>
<br>
Added:<br>
    llvm/trunk/test/DebugInfo/X86/rnglists_base_attr.ll<br>
    llvm/trunk/test/DebugInfo/X86/rnglists_curanges.ll<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
    llvm/trunk/test/DebugInfo/X86/cu-ranges.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=337981&r1=337980&r2=337981&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=337981&r1=337980&r2=337981&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Wed Jul 25 16:03:22 2018<br>
@@ -420,8 +420,6 @@ void DwarfCompileUnit::addScopeRangeList<br>
   } else {<br>
     addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges, List.getSym(),<br>
                     RangeSectionSym);<br>
-    if (DD->getDwarfVersion() >= 5)<br>
-      addRnglistsBase();<br>
   }<br>
<br>
   // Add the range list to the set of ranges to be emitted.<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=337981&r1=337980&r2=337981&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=337981&r1=337980&r2=337981&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Jul 25 16:03:22 2018<br>
@@ -820,6 +820,10 @@ void DwarfDebug::finalizeModuleInfo() {<br>
       U.attachRangesOrLowHighPC(U.getUnitDie(), TheCU.takeRanges());<br>
     }<br>
<br>
+    if (getDwarfVersion() >= 5 && !useSplitDwarf() &&<br>
+        !U.getRangeLists().empty())<br>
+      U.addRnglistsBase();<br>
+<br>
     auto *CUNode = cast<DICompileUnit>(P.first);<br>
     // If compile Unit has macros, emit "DW_AT_macro_info" attribute.<br>
     if (CUNode->getMacros())<br>
@@ -2086,23 +2090,10 @@ static void emitRangeList(AsmPrinter *As<br>
   }<br>
 }<br>
<br>
-void DwarfDebug::emitDebugRnglists() {<br>
-<br>
-  // Don't emit a rangelist table if there are no ranges.<br>
-  if (llvm::all_of(CUMap,<br>
-                   [](const decltype(CUMap)::const_iterator::value_type &Pair) {<br>
-                     DwarfCompileUnit *TheCU = Pair.second;<br>
-                     if (auto *Skel = TheCU->getSkeleton())<br>
-                       TheCU = Skel;<br>
-                     return TheCU->getRangeLists().empty();<br>
-                   }))<br>
-    return;<br>
-<br>
-  assert(getDwarfVersion() >= 5 && "Dwarf version must be 5 or greater");<br>
-  // FIXME: As long as we don't support DW_RLE_base_addrx, we cannot generate<br>
-  // any tables in the .debug_rnglists.dwo section.<br>
-  Asm->OutStreamer->SwitchSection(<br>
-      Asm->getObjFileLowering().getDwarfRnglistsSection());<br>
+// Emit the header of a DWARF 5 range list table. Returns the symbol that<br>
+// designates the end of the table for the caller to emit when the table is<br>
+// complete.<br>
+static MCSymbol *emitRnglistsTableHeader(AsmPrinter *Asm, DwarfFile &Holder) {<br>
   // The length is described by a starting label right after the length field<br>
   // and an end label.<br>
   MCSymbol *TableStart = Asm->createTempSymbol("debug_rnglist_table_start");<br>
@@ -2111,56 +2102,52 @@ void DwarfDebug::emitDebugRnglists() {<br>
   Asm->EmitLabelDifference(TableEnd, TableStart, 4);<br>
   Asm->OutStreamer->EmitLabel(TableStart);<br>
   // Version number (DWARF v5 and later).<br>
-  Asm->emitInt16(getDwarfVersion());<br>
+  Asm->emitInt16(Asm->OutStreamer->getContext().getDwarfVersion());<br>
   // Address size.<br>
   Asm->emitInt8(Asm->MAI->getCodePointerSize());<br>
   // Segment selector size.<br>
   Asm->emitInt8(0);<br>
<br>
-  MCSymbol *RnglistTableBaseSym =<br>
-      (useSplitDwarf() ? SkeletonHolder : InfoHolder).getRnglistsTableBaseSym();<br>
+  MCSymbol *RnglistTableBaseSym = Holder.getRnglistsTableBaseSym();<br>
<br>
   // FIXME: Generate the offsets table and use DW_FORM_rnglistx with the<br>
   // DW_AT_ranges attribute. Until then set the number of offsets to 0.<br>
   Asm->emitInt32(0);<br>
   Asm->OutStreamer->EmitLabel(RnglistTableBaseSym);<br>
-<br>
-  // Emit the individual range lists.<br>
-  for (const auto &I : CUMap) {<br>
-    DwarfCompileUnit *TheCU = I.second;<br>
-    if (auto *Skel = TheCU->getSkeleton())<br>
-      TheCU = Skel;<br>
-    for (const RangeSpanList &List : TheCU->getRangeLists())<br>
-      emitRangeList(Asm, TheCU, List);<br>
-  }<br>
-<br>
-  Asm->OutStreamer->EmitLabel(TableEnd);<br>
+  return TableEnd;<br>
 }<br>
<br>
-/// Emit address ranges into the .debug_ranges section or DWARF v5 rangelists<br>
-/// into the .debug_rnglists section.<br>
+/// Emit address ranges into the .debug_ranges section or into the DWARF v5<br>
+/// .debug_rnglists section.<br>
 void DwarfDebug::emitDebugRanges() {<br>
   if (CUMap.empty())<br>
     return;<br>
<br>
+  auto NoRangesPresent = [this]() {<br>
+    return llvm::all_of(<br>
+        CUMap, [](const decltype(CUMap)::const_iterator::value_type &Pair) {<br>
+          return Pair.second->getRangeLists().empty();<br>
+        });<br>
+  };<br>
+<br>
   if (!useRangesSection()) {<br>
-    assert(llvm::all_of(<br>
-               CUMap,<br>
-               [](const decltype(CUMap)::const_iterator::value_type &Pair) {<br>
-                 return Pair.second->getRangeLists().empty();<br>
-               }) &&<br>
-           "No debug ranges expected.");<br>
+    assert(NoRangesPresent() && "No debug ranges expected.");<br>
     return;<br>
   }<br>
<br>
-  if (getDwarfVersion() >= 5) {<br>
-    emitDebugRnglists();<br>
+  if (NoRangesPresent())<br>
     return;<br>
-  }<br>
<br>
   // Start the dwarf ranges section.<br>
-  Asm->OutStreamer->SwitchSection(<br>
-      Asm->getObjFileLowering().getDwarfRangesSection());<br>
+  MCSymbol *TableEnd = nullptr;<br>
+  if (getDwarfVersion() >= 5) {<br>
+    Asm->OutStreamer->SwitchSection(<br>
+        Asm->getObjFileLowering().getDwarfRnglistsSection());<br>
+    TableEnd = emitRnglistsTableHeader(Asm, useSplitDwarf() ? SkeletonHolder<br>
+                                                            : InfoHolder);<br>
+  } else<br>
+    Asm->OutStreamer->SwitchSection(<br>
+        Asm->getObjFileLowering().getDwarfRangesSection());<br>
<br>
   // Grab the specific ranges for the compile units in the module.<br>
   for (const auto &I : CUMap) {<br>
@@ -2173,6 +2160,9 @@ void DwarfDebug::emitDebugRanges() {<br>
     for (const RangeSpanList &List : TheCU->getRangeLists())<br>
       emitRangeList(Asm, TheCU, List);<br>
   }<br>
+<br>
+  if (TableEnd)<br>
+    Asm->OutStreamer->EmitLabel(TableEnd);<br>
 }<br>
<br>
 void DwarfDebug::handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U) {<br>
@@ -2248,9 +2238,6 @@ void DwarfDebug::initSkeletonUnit(const<br>
   SkeletonHolder.addUnit(std::move(NewU));<br>
 }<br>
<br>
-// This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,<br>
-// DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,<br>
-// DW_AT_addr_base, DW_AT_ranges_base or DW_AT_rnglists_base.<br>
 DwarfCompileUnit &DwarfDebug::constructSkeletonCU(const DwarfCompileUnit &CU) {<br>
<br>
   auto OwnedUnit = llvm::make_unique<DwarfCompileUnit>(<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=337981&r1=337980&r2=337981&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=337981&r1=337980&r2=337981&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Jul 25 16:03:22 2018<br>
@@ -423,8 +423,13 @@ class DwarfDebug : public DebugHandlerBa<br>
   void initSkeletonUnit(const DwarfUnit &U, DIE &Die,<br>
                         std::unique_ptr<DwarfCompileUnit> NewU);<br>
<br>
-  /// Construct the split debug info compile unit for the debug info<br>
-  /// section.<br>
+  /// Construct the split debug info compile unit for the debug info section.<br>
+  /// In DWARF v5, the skeleton unit DIE may have the following attributes:<br>
+  /// DW_AT_addr_base, DW_AT_comp_dir, DW_AT_dwo_name, DW_AT_high_pc,<br>
+  /// DW_AT_low_pc, DW_AT_ranges, DW_AT_stmt_list, and DW_AT_str_offsets_base.<br>
+  /// Prior to DWARF v5 it may also have DW_AT_GNU_dwo_id. DW_AT_GNU_dwo_name<br>
+  /// is used instead of DW_AT_dwo_name, Dw_AT_GNU_addr_base instead of<br>
+  /// DW_AT_addr_base, and DW_AT_GNU_ranges_base instead of DW_AT_rnglists_base.<br>
   DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);<br>
<br>
   /// Emit the debug info dwo section.<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/cu-ranges.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/cu-ranges.ll?rev=337981&r1=337980&r2=337981&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/cu-ranges.ll?rev=337981&r1=337980&r2=337981&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/cu-ranges.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/cu-ranges.ll Wed Jul 25 16:03:22 2018<br>
@@ -5,6 +5,9 @@<br>
 ; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t<br>
 ; RUN: llvm-dwarfdump -debug-abbrev %t | FileCheck --check-prefix=NO-FUNCTION-SECTIONS %s<br>
<br>
+; RUN: llc -dwarf-version=5 -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t<br>
+; RUN: llvm-dwarfdump -v %t | FileCheck --check-prefix=DWARF5 %s<br>
+<br>
 ; From:<br>
 ; int foo (int a) {<br>
 ;   return a+1;<br>
@@ -24,6 +27,14 @@<br>
 ; NO-FUNCTION-SECTIONS: DW_AT_low_pc DW_FORM_addr<br>
 ; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges<br>
<br>
+; For Dwarf 5 check that we neither generate DW_AT_rnglists_base for the CU DIE nor
<br>
+; a .debug_rnglists section. There is only 1 CU range with no scope ranges.<br>
+;<br>
+; DWARF5:     .debug_info contents:<br>
+; DWARF5:     DW_TAG_compile_unit<br>
+; DWARF5-NOT: DW_AT_rnglists_base [DW_FORM_sec_offset]   <br>
+; DWARF5-NOT: .debug_rnglists contents:<br>
+<br>
 ; Function Attrs: nounwind uwtable<br>
 define i32 @foo(i32 %a) #0 !dbg !4 {<br>
 entry:<br>
<br>
Added: llvm/trunk/test/DebugInfo/X86/rnglists_base_attr.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/rnglists_base_attr.ll?rev=337981&view=auto" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/rnglists_base_attr.ll?rev=337981&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/rnglists_base_attr.ll (added)<br>
+++ llvm/trunk/test/DebugInfo/X86/rnglists_base_attr.ll Wed Jul 25 16:03:22 2018<br>
@@ -0,0 +1,89 @@<br>
+; RUN: llc -dwarf-version=5 -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t<br>
+; RUN: llvm-dwarfdump -v %t | FileCheck %s<br>
+<br>
+; Make sure we don't generate a duplicate DW_AT_rnglists_base attribute in the CU DIE<br>
+; when more than one range list is emitted.<br>
+; From the source:<br>
+;<br>
+; void f1();<br>
+; void f2() {<br>
+;   f1();<br>
+;   {<br>
+;     bool b;<br>
+;     f1();<br>
+;     f1();<br>
+;   }<br>
+; }<br>
+; __attribute__((section(".text.foo"))) void f3() { }<br>
+ <br>
+; Compile with clang -gwarf5 -S -emit-llvm<br>
+; and change the resulting IR to move the first call to f1() to between<br>
+; the second and the third call. This, along with the dbg.declare instruction<br>
+; for the variable b, creates a gap in the code range for the nested lexical<br>
+; scope that is b's immediate parent scope. A range list is emitted for that scope.<br>
+;<br>
+; In addition, the placement of f3() in a different section forces a <br>
+; rangelist to be emitted for the CU instead of simply using low/high pc <br>
+; attributes.<br>
+<br>
+; CHECK:      .debug_info contents:<br>
+; CHECK:      DW_TAG_compile_unit<br>
+; Make sure we have 2 CU ranges.<br>
+; CHECK:      DW_AT_ranges<br>
+; CHECK-NEXT: [0x{{[0-9a-f]+, 0x[0-9a-f]+}}) ".text"<br>
+; CHECK-NEXT: [0x{{[0-9a-f]+, 0x[0-9a-f]+}}) ".text.foo"<br>
+; We should not see any duplicate DW_AT_rnglists_base attributes.<br>
+; CHECK:      DW_AT_rnglists_base [DW_FORM_sec_offset]                   (0x0000000c)<br>
+; CHECK-NOT:  DW_AT_rnglists_base<br>
+;<br>
+; Make sure we see 2 ranges in the lexical block DIE.<br>
+; CHECK:      DW_TAG_lexical_block<br>
+; CHECK-NOT:  DW_TAG<br>
+; CHECK:      DW_AT_ranges<br>
+; CHECK-NEXT: [0x{{[0-9a-f]+, 0x[0-9a-f]+}}) ".text"<br>
+; CHECK-NEXT: [0x{{[0-9a-f]+, 0x[0-9a-f]+}}) ".text"<br>
+<br>
+define dso_local void @_Z2f2v() !dbg !7 {<br>
+entry:<br>
+  %b = alloca i8, align 1<br>
+  call void @llvm.dbg.declare(metadata i8* %b, metadata !11, metadata !DIExpression()), !dbg !14<br>
+  call void @_Z2f1v(), !dbg !15<br>
+  ; The following call has been moved here from right after the alloca<br>
+  call void @_Z2f1v(), !dbg !10  <br>
+  call void @_Z2f1v(), !dbg !16<br>
+  ret void, !dbg !17<br>
+}<br>
+<br>
+declare dso_local void @_Z2f1v()<br>
+<br>
+declare void @llvm.dbg.declare(metadata, metadata, metadata)<br>
+<br>
+define dso_local void @_Z2f3v() section ".text.foo" !dbg !18 {<br>
+entry:<br>
+  ret void, !dbg !19<br>
+}<br>
+<br>
+!<a href="http://llvm.dbg.cu" 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 7.0.0 (trunk 337837)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<br>
+!1 = !DIFile(filename: "t3.cpp", directory: "/home/test/rangelists", checksumkind: CSK_MD5, checksum: "1ba81b564a832caa8114cd008c199048")<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 7.0.0 (trunk 337837)"}<br>
+!7 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)<br>
+!8 = !DISubroutineType(types: !9)<br>
+!9 = !{null}<br>
+!10 = !DILocation(line: 3, column: 3, scope: !7)<br>
+!11 = !DILocalVariable(name: "b", scope: !12, file: !1, line: 5, type: !13)<br>
+!12 = distinct !DILexicalBlock(scope: !7, file: !1, line: 4, column: 3)<br>
+!13 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)<br>
+!14 = !DILocation(line: 5, column: 10, scope: !12)<br>
+!15 = !DILocation(line: 6, column: 5, scope: !12)<br>
+!16 = !DILocation(line: 7, column: 5, scope: !12)<br>
+!17 = !DILocation(line: 9, column: 1, scope: !7)<br>
+!18 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !1, file: !1, line: 10, type: !8, isLocal: false, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)<br>
+!19 = !DILocation(line: 10, column: 51, scope: !18)<br>
<br>
Added: llvm/trunk/test/DebugInfo/X86/rnglists_curanges.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/rnglists_curanges.ll?rev=337981&view=auto" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/rnglists_curanges.ll?rev=337981&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/rnglists_curanges.ll (added)<br>
+++ llvm/trunk/test/DebugInfo/X86/rnglists_curanges.ll Wed Jul 25 16:03:22 2018<br>
@@ -0,0 +1,50 @@<br>
+; RUN: llc -dwarf-version=5 -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t<br>
+; RUN: llvm-dwarfdump -v %t | FileCheck %s<br>
+;<br>
+; Check that we generate DW_AT_rnglists_base in the CU die, as well as a range <br>
+; list table when we have more than 1 CU range and no scope range.<br>
+;<br>
+; Generated from:<br>
+; <br>
+; __attribute__((section("text.foo"))) void f1() {}<br>
+; __attribute__((section("text.bar"))) void f2() {}<br>
+;<br>
+; Compile with clangc -gdwarf-5 -O0 -S -emit-llvm<br>
+;<br>
+; CHECK:      .debug_info contents:<br>
+; CHECK:      DW_TAG_compile_unit<br>
+; CHECK-NOT:  DW_TAG<br>
+; CHECK:      DW_AT_rnglists_base [DW_FORM_sec_offset]                   (0x0000000c)<br>
+; CHECK:      .debug_rnglists contents:<br>
+; CHECK:      0x00000000: range list header: length = 0x0000001d, version = 0x0005,<br>
+; CHECK-SAME: addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000<br>
+<br>
+; Function Attrs: noinline nounwind optnone uwtable<br>
+define dso_local void @f1() section "text.foo" !dbg !7 {<br>
+entry:<br>
+  ret void, !dbg !10<br>
+}<br>
+<br>
+; Function Attrs: noinline nounwind optnone uwtable<br>
+define dso_local void @f2() section "text.bar" !dbg !11 {<br>
+entry:<br>
+  ret void, !dbg !12<br>
+}<br>
+<br>
+!<a href="http://llvm.dbg.cu" 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_C99, file: !1, producer: "clang version 7.0.0 (trunk 337470)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<br>
+!1 = !DIFile(filename: "test3.c", directory: "/home/test/rangelists", checksumkind: CSK_MD5, checksum: "f3b46bc2e5bc55bdd511ae4ec29577b6")<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 7.0.0 (trunk 337470)"}<br>
+!7 = distinct !DISubprogram(name: "f1", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0, retainedNodes: !2)<br>
+!8 = !DISubroutineType(types: !9)<br>
+!9 = !{null}<br>
+!10 = !DILocation(line: 1, column: 49, scope: !7)<br>
+!11 = distinct !DISubprogram(name: "f2", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, retainedNodes: !2)<br>
+!12 = !DILocation(line: 2, column: 49, scope: !11)<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal">_______________________________________________<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</div></div></div></blockquote></div>