<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [DebugInfo] Malformed DWARF produced when using split dwarf"
   href="https://bugs.llvm.org/show_bug.cgi?id=49159">49159</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[DebugInfo] Malformed DWARF produced when using split dwarf
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jeremy.morse.llvm@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dblaikie@gmail.com, llvm-bugs@lists.llvm.org, paul.robinson@am.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>While looking at MaskRays reproducer [0] for problems in D94976 and <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [DebugInfo] Malformed DWARF produced during LTO build"
   href="show_bug.cgi?id=48790">bug 48790</a>,
I noticed that llvm-dwarfdump reports "invalid DIE reference (...) Offset is
between DIEs" for that reproducer too. This is present regardless of whether
D94976 is applied or whether isShareableAcrossCUs allows subprograms to be
shared across CUs. The specific problem is a DW_TAG_inlined_subroutine with an
illegal abstract origin reference:

    DW_AT_abstract_origin (0x0000002c)

llvm-dwarfdump -v says that it's a DW_FORM_ref4.

To narrow down the problem: within the reproducer metadata, look at metadata
node !1596 for the definition of "SlowLock". This has an inlined instance of
"Now" coming from node !1743, the abstract subprogram for which is created in
the skeleton unit by [1], apparently this is part of the "keep inlining
information in skeleton unit for backtracing" feature. However: because it's
not being created in a DWO unit [2], the subprogram DIE is placed in the
dwarf-file global list of abstract subprograms.

Later on, DwarfCompileUnit::constructInlinedScopeDIE [3] tries to create a
DW_TAG_inlined_subroutine site for an inlined copy of "Now" in a _different_
skeleton unit. However it picks out the abstract subprogram from the first unit
through [2], and attaches it with DW_TAG_inlined_subroutine to the DIE it's
constructing. The addDIEEntry method [4] assumes that the
DW_TAG_inlined_subroutine DIE and the abstract origin are in the same unit, and
uses a DW_FORM_ref4 for a cross-CU reference, leading to invalid DWARF being
emitted later.

Once again I'm still getting to grips with the nuances of DWARF emission, so
don't know exactly where we go wrong here.

[0] <a href="https://gist.github.com/MaskRay/4c67b29bb038d5a016260437c9e25a7a">https://gist.github.com/MaskRay/4c67b29bb038d5a016260437c9e25a7a</a>
[1]
<a href="https://github.com/llvm/llvm-project/blob/530d6ea97b884656d59e4701b40d9e6d546b4bef/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp#L573">https://github.com/llvm/llvm-project/blob/530d6ea97b884656d59e4701b40d9e6d546b4bef/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp#L573</a>
[2]
<a href="https://github.com/llvm/llvm-project/blob/530d6ea97b884656d59e4701b40d9e6d546b4bef/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h#L96">https://github.com/llvm/llvm-project/blob/530d6ea97b884656d59e4701b40d9e6d546b4bef/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h#L96</a>
[3]
<a href="https://github.com/llvm/llvm-project/blob/530d6ea97b884656d59e4701b40d9e6d546b4bef/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#L641">https://github.com/llvm/llvm-project/blob/530d6ea97b884656d59e4701b40d9e6d546b4bef/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#L641</a>
[4]
<a href="https://github.com/llvm/llvm-project/blob/530d6ea97b884656d59e4701b40d9e6d546b4bef/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp#L384">https://github.com/llvm/llvm-project/blob/530d6ea97b884656d59e4701b40d9e6d546b4bef/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp#L384</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>