<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 - sccp pass drop debug location unnecessarily"
   href="https://bugs.llvm.org/show_bug.cgi?id=48722">48722</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>sccp pass drop debug location unnecessarily
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>yuanboli233@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24370" name="attach_24370" title="abc_debug.ll">attachment 24370</a> <a href="attachment.cgi?id=24370&action=edit" title="abc_debug.ll">[details]</a></span>
abc_debug.ll

Overview: In the attached example, the sccp pass will drop debug location
unnecessarily.

Steps to reproduce:

Here is the version of llvm:
$ clang++ --version
clang version 12.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
b8d28420885a42d16a57e02c28129d0eb92474a1)
Target: x86_64-unknown-linux-gnu
Thread model: posix

$ opt -sccp abc_debug.ll > result.bc
$ llvm-dis result.bc

$ diff abc_debug.ll result.ll 
...(irrelevant text)...
33,34c33,34
<   %tmp10 = sext i32 %tmp9 to i64, !dbg !30
<   call void @llvm.dbg.value(metadata i64 %tmp10, metadata !19, metadata
!DIExpression()), !dbg !30
---
<span class="quote">>   %0 = zext i32 %tmp9 to i64
>   call void @llvm.dbg.value(metadata i64 %0, metadata !19, metadata !DIExpression()), !dbg !30</span >

the variable %tmp10 seems to have a one-to-one relationship with %0, so it
seems that the debug location !30 is unnecessarily dropped, according to the
principles in:
    <a href="https://llvm.org/docs/HowToUpdateDebugInfo.html">https://llvm.org/docs/HowToUpdateDebugInfo.html</a>
There's a one-to-one relationship between the new and old instruction, and it's
placed in the same location, so the DebugLoc should be preserved in the
reproducer.</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>