<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 - [PostRA Machine Sink] Ensure dbg value consistency when moving dbg instructions across other dbg instructions."
   href="https://bugs.llvm.org/show_bug.cgi?id=37897">37897</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[PostRA Machine Sink] Ensure dbg value consistency when moving dbg instructions across other dbg instructions.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>matthew.davis@sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>A discussion in <a href="https://reviews.llvm.org/D45637">https://reviews.llvm.org/D45637</a> mentions a possible
inconsistent debug representation when sinking debug-info instructions across
other debug-info instructions associated to the same user variable.  I'll try
to distill the issue below, but the review provides a more detailed discussion.

While we have not yet seen such a case occur from user source code, it seems
that such a case might occur.  To better illustrate this idea, the following
example was ripped from the link referenced above:
    ...
    renamable $eax = COPY $edi
    DBG_VALUE debug-use $eax, debug-use $noreg, !14, !DIExpression(),
debug-location !16
    $esi = ADD $edi, 7
    DBG_VALUE debug-use $esi, debug-use $noreg, !14, !DIExpression(),
debug-location !17
   ...

In this hypothetical example, both DBG_VALUEs are associated with some user
variable !14.  If the MachineSink code were to sink the COPY and its associated
DBG_VALUE to some successor block, not displayed in the example above, then
there is the potential that a debugger will show incorrect data (old/original
debug data) when stepping pass the sunken instruction.

Another similar example, also ripped from the review is the following:
    if (p == NULL)
      b = 1;
    p = q;
    bar()
Represented as IR:
    call dbg.value(!DIVariable("p", ...), null, !DIExpression(DW_OP_constu 0))
    %b = predicated_move(%p, i32 1) // assuming such an instruction exists :-)
    %p.1 = %q
    call dbg.value(!DIVariable("p", ...), %p.1,  !DIExpression()

In this example, moving the original dbg_value after the second would have the
effect of making variable 'p' appear NULL when stepping/inspecting instructions
after the second dbg.intrinsic.</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>