<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 - simple-register-coalescing fails to update/invalidate DBG_VALUE"
   href="https://bugs.llvm.org/show_bug.cgi?id=50613">50613</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>simple-register-coalescing fails to update/invalidate DBG_VALUE
          </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>normal
          </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>markus.lavin@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24922" name="attach_24922" title="Reproducer input for Arm target.">attachment 24922</a> <a href="attachment.cgi?id=24922&action=edit" title="Reproducer input for Arm target.">[details]</a></span>
Reproducer input for Arm target.

With input as follows
---
  bb.0:
    liveins: $r0
    %4:gpr = COPY $r0
    %9:gpr = COPY %4
    %9:gpr = ADDri %9, 4, 14, $noreg, $noreg
    %12:gpr = COPY %9
    B %bb.1
  bb.1:
    %10:gpr = COPY %12
    DBG_VALUE %4, $noreg, !10, !DIExpression(), debug-location !8
    %11:gpr = COPY %10
    %11:gpr = ADDri %11, 4, 14, $noreg, $noreg
    %12:gpr = COPY %11
    B %bb.1
---
after issuing
$ llc dbg-coalesc-arm-reduced.mir -run-pass=liveintervals
-run-pass=simple-register-coalescing -o - -debug-only=regalloc
we get
---
  bb.0:
    successors: %bb.1(0x80000000)
    liveins: $r0

    %2:gpr = COPY $r0
    %2:gpr = ADDri %2, 4, 14 /* CC::al */, $noreg, $noreg
    B %bb.1

  bb.1:
    successors: %bb.1(0x80000000)

    DBG_VALUE %2, $noreg, <0xa03e470>, !DIExpression(), debug-location
!DILocation(line: 1, column: 1, scope: <0xa03e520>)
    %2:gpr = ADDri %2, 4, 14 /* CC::al */, $noreg, $noreg
    B %bb.1
---
That is the DBG_VALUE is now using a register with different value (previously
$r0 but now $r0+4).

I believe this situation should be handled by
---
commit d9c9a4e48d286a04d09a8fdea87f486a9ec02cd0
Author: Jeremy Morse <<a href="mailto:jeremy.morse@sony.com">jeremy.morse@sony.com</a>>
Date:   Mon Nov 25 13:38:27 2019 +0000

    [DebugInfo] Avoid register coalesing unsoundly changing DBG_VALUE locations
---
PS. It took a while to get to this reproducer so obviously it does handle quite
a few similar situations.</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>