<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - The scalarizer pass remove debugloc from call instruction"
   href="https://llvm.org/bugs/show_bug.cgi?id=27938">27938</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The scalarizer pass remove debugloc from call instruction
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>karl-johan.karlsson@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16437" name="attach_16437" title="Reproducer:  opt -S -scalarizer -o - foo.ll">attachment 16437</a> <a href="attachment.cgi?id=16437&action=edit" title="Reproducer:  opt -S -scalarizer -o - foo.ll">[details]</a></span>
Reproducer:  opt -S -scalarizer -o - foo.ll

The scalarizer pass (-scalarizer) remove the debugloc from a call instruction.
The verifier pass later give the error message:

inlinable function call in a function with debug info must have a !dbg location
  %_tmp7 = tail call i16 @f1()
LLVM ERROR: Broken function found, compilation aborted!

The problem seems to be in the method Scalarizer::transferMetadata() that
always transfer the debugloc regardless of if the debugloc that is being
transfered is set or not. I'm also a bit unsure if it is a good idea to
overwrite the debugloc of an instruction that already got a perfectly fine
debugloc, why is it guaranteed that the new one is better?

Reproducer:

opt -S -scalarizer -o - foo.ll</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>