<div dir="ltr">I reverted this commit as it was causing msan buildbot failures, like the <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/25452/steps/check-llvm%20msan/logs/stdio">following</a>:<div><pre style="font-family:"Courier New",courier,monotype,monospace;font-size:medium"><span class="inbox-inbox-stdout">[ RUN      ] DWARFDebugInfo.TestDwarfVerifyCUDontShareLineTable
==42558==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x36bc80a in llvm::DWARFVerifier::verifyDieRanges(llvm::DWARFDie const&, llvm::DWARFVerifier::DieRangeInfo&) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp:417:21
    #1 0x36b6b96 in llvm::DWARFVerifier::verifyUnitContents(llvm::DWARFUnit&) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp:222:20
    #2 0x36be884 in llvm::DWARFVerifier::verifyUnitSection(llvm::DWARFSection const&, llvm::DWARFSectionKind) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp:350:29
    #3 0x36bfdec in llvm::DWARFVerifier::handleDebugInfo() /b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp:369:21
    #4 0x3620883 in llvm::DWARFContext::verify(llvm::raw_ostream&, llvm::DIDumpOptions) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:652:25
    #5 0x7a901a in (anonymous namespace)::VerifyError(llvm::DWARFContext&, llvm::StringRef) /b/sanitizer-x86_64-linux-fast/build/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp:1871:3
    #6 0x7ae9df in (anonymous namespace)::DWARFDebugInfo_TestDwarfVerifyCUDontShareLineTable_Test::TestBody() /b/sanitizer-x86_64-linux-fast/build/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp:2505:3
    #7 0x3b0a041 in HandleExceptionsInMethodIfSupported<testing::Test, void> /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc
    #8 0x3b0a041 in testing::Test::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2474
    #9 0x3b0d6e6 in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
    #10 0x3b0ea6f in testing::TestCase::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
    #11 0x3b2a9d8 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
    #12 0x3b29748 in HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc
    #13 0x3b29748 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4257
    #14 0x3af5ccb in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
    #15 0x3af5ccb in main /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:51
    #16 0x7fcd6ed8c2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #17 0x562e39 in _start (/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/unittests/DebugInfo/DWARF/DebugInfoDWARFTests+0x562e39)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp:417:21 in llvm::DWARFVerifier::verifyDieRanges(llvm::DWARFDie const&, llvm::DWARFVerifier::DieRangeInfo&)</span></pre></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Oct 26, 2018 at 5:51 PM Saleem Abdulrasool 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: compnerd<br>
Date: Fri Oct 26 17:49:33 2018<br>
New Revision: 345441<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=345441&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=345441&view=rev</a><br>
Log:<br>
DebugInfo: reduce DIE range verification on object files<br>
<br>
Relocatable content may have overlapping ranges until the sections are<br>
finalized.  This reduces the amount of verification that is done on an object<br>
file so that invalid errors are not raised.<br>
<br>
Added:<br>
    llvm/trunk/test/tools/llvm-dwarfdump/X86/debug-verify-object.s<br>
Modified:<br>
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h<br>
    llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h?rev=345441&r1=345440&r2=345441&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h?rev=345441&r1=345440&r2=345441&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h Fri Oct 26 17:49:33 2018<br>
@@ -97,6 +97,9 @@ private:<br>
   /// lies between to valid DIEs.<br>
   std::map<uint64_t, std::set<uint32_t>> ReferenceToDIEOffsets;<br>
   uint32_t NumDebugLineErrors = 0;<br>
+  // Used to relax some checks that do not currently work portably<br>
+  bool IsObjectFile;<br>
+  bool IsMachOObject;<br>
<br>
   raw_ostream &error() const;<br>
   raw_ostream &warn() const;<br>
@@ -286,8 +289,8 @@ private:<br>
<br>
 public:<br>
   DWARFVerifier(raw_ostream &S, DWARFContext &D,<br>
-                DIDumpOptions DumpOpts = DIDumpOptions::getForSingleDIE())<br>
-      : OS(S), DCtx(D), DumpOpts(std::move(DumpOpts)) {}<br>
+                DIDumpOptions DumpOpts = DIDumpOptions::getForSingleDIE());<br>
+<br>
   /// Verify the information in any of the following sections, if available:<br>
   /// .debug_abbrev, debug_abbrev.dwo<br>
   ///<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp?rev=345441&r1=345440&r2=345441&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp?rev=345441&r1=345440&r2=345441&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp Fri Oct 26 17:49:33 2018<br>
@@ -394,20 +394,42 @@ unsigned DWARFVerifier::verifyDieRanges(<br>
   // Build RI for this DIE and check that ranges within this DIE do not<br>
   // overlap.<br>
   DieRangeInfo RI(Die);<br>
-  for (auto Range : Ranges) {<br>
-    if (!Range.valid()) {<br>
-      ++NumErrors;<br>
-      error() << "Invalid address range " << Range << "\n";<br>
-      continue;<br>
-    }<br>
<br>
-    // Verify that ranges don't intersect.<br>
-    const auto IntersectingRange = RI.insert(Range);<br>
-    if (IntersectingRange != RI.Ranges.end()) {<br>
-      ++NumErrors;<br>
-      error() << "DIE has overlapping address ranges: " << Range << " and "<br>
-              << *IntersectingRange << "\n";<br>
-      break;<br>
+  // TODO support object files better<br>
+  //<br>
+  // Some object file formats (i.e. non-MachO) support COMDAT.  ELF in<br>
+  // particular does so by placing each function into a section.  The DWARF data<br>
+  // for the function at that point uses a section relative DW_FORM_addrp for<br>
+  // the DW_AT_low_pc and a DW_FORM_data4 for the offset as the DW_AT_high_pc.<br>
+  // In such a case, when the Die is the CU, the ranges will overlap, and we<br>
+  // will flag valid conflicting ranges as invalid.<br>
+  //<br>
+  // For such targets, we should read the ranges from the CU and partition them<br>
+  // by the section id.  The ranges within a particular section should be<br>
+  // disjoint, although the ranges across sections may overlap.  We would map<br>
+  // the child die to the entity that it references and the section with which<br>
+  // it is associated.  The child would then be checked against the range<br>
+  // information for the associated section.<br>
+  //<br>
+  // For now, simply elide the range verification for the CU DIEs if we are<br>
+  // processing an object file.<br>
+<br>
+  if (!IsObjectFile || IsMachOObject || Die.getTag() == DW_TAG_subprogram) {<br>
+    for (auto Range : Ranges) {<br>
+      if (!Range.valid()) {<br>
+        ++NumErrors;<br>
+        error() << "Invalid address range " << Range << "\n";<br>
+        continue;<br>
+      }<br>
+<br>
+      // Verify that ranges don't intersect.<br>
+      const auto IntersectingRange = RI.insert(Range);<br>
+      if (IntersectingRange != RI.Ranges.end()) {<br>
+        ++NumErrors;<br>
+        error() << "DIE has overlapping address ranges: " << Range << " and "<br>
+                << *IntersectingRange << "\n";<br>
+        break;<br>
+      }<br>
     }<br>
   }<br>
<br>
@@ -745,6 +767,15 @@ void DWARFVerifier::verifyDebugLineRows(<br>
   }<br>
 }<br>
<br>
+DWARFVerifier::DWARFVerifier(raw_ostream &S, DWARFContext &D,<br>
+                             DIDumpOptions DumpOpts)<br>
+    : OS(S), DCtx(D), DumpOpts(std::move(DumpOpts)) {<br>
+  if (const auto *F = DCtx.getDWARFObj().getFile()) {<br>
+    IsObjectFile = F->isRelocatableObject();<br>
+    IsMachOObject = F->isMachO();<br>
+  }<br>
+}<br>
+<br>
 bool DWARFVerifier::handleDebugLine() {<br>
   NumDebugLineErrors = 0;<br>
   OS << "Verifying .debug_line...\n";<br>
<br>
Added: llvm/trunk/test/tools/llvm-dwarfdump/X86/debug-verify-object.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/debug-verify-object.s?rev=345441&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/debug-verify-object.s?rev=345441&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/debug-verify-object.s (added)<br>
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/debug-verify-object.s Fri Oct 26 17:49:33 2018<br>
@@ -0,0 +1,57 @@<br>
+# RUN: llvm-mc -filetype obj -o - %s | llvm-dwarfdump --verify -<br>
+<br>
+       .text<br>
+<br>
+       .section        .text.f,"ax",@progbits<br>
+       .globl  f<br>
+       .type   f,@function<br>
+f:<br>
+.Lfunc_begin0:<br>
+       pushq   $32<br>
+       popq    %rax<br>
+       retq<br>
+.Lfunc_end0:<br>
+       .size   f, .Lfunc_end0-f<br>
+<br>
+       .section        .text.g,"ax",@progbits<br>
+       .globl  g<br>
+       .type   g,@function<br>
+g:<br>
+.Lfunc_begin1:<br>
+       pushq   $64<br>
+       popq    %rax<br>
+       retq<br>
+.Lfunc_end1:<br>
+       .size   g, .Lfunc_end1-g<br>
+<br>
+       .section        .debug_abbrev,"",@progbits<br>
+       .byte   1                       # Abbreviation Code<br>
+       .byte   17                      # DW_TAG_compile_unit<br>
+       .byte   0                       # DW_CHILDREN_no<br>
+       .byte   17                      # DW_AT_low_pc<br>
+       .byte   1                       # DW_FORM_addr<br>
+       .byte   85                      # DW_AT_ranges<br>
+       .byte   23                      # DW_FORM_sec_offset<br>
+       .byte   0                       # EOM(1)<br>
+       .byte   0                       # EOM(2)<br>
+       .byte   0                       # EOM(3)<br>
+<br>
+       .section        .debug_info,"",@progbits<br>
+.Lcu_begin0:<br>
+       .long   20                      # Length of Unit<br>
+       .short  4                       # DWARF version number<br>
+       .long   .debug_abbrev           # Offset Into Abbrev. Section<br>
+       .byte   8                       # Address Size (in bytes)<br>
+       .byte   1                       # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit<br>
+       .quad   0                       # DW_AT_low_pc<br>
+       .long   .Ldebug_ranges0         # DW_AT_ranges<br>
+<br>
+       .section        .debug_ranges,"",@progbits<br>
+.Ldebug_ranges0:<br>
+       .quad   .Lfunc_begin0<br>
+       .quad   .Lfunc_end0<br>
+       .quad   .Lfunc_begin1<br>
+       .quad   .Lfunc_end1<br>
+       .quad   0<br>
+       .quad   0<br>
+<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" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>