<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 --- - Stripping location information off of hoisted readnone calls conflicts with DI verification assertions for inlinable calls"
   href="https://llvm.org/bugs/show_bug.cgi?id=31891">31891</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Stripping location information off of hoisted readnone calls conflicts with DI verification assertions for inlinable calls
          </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>Windows NT
          </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>DebugInfo
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rnk@google.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>Recently r294250 / <a href="https://reviews.llvm.org/D29377">https://reviews.llvm.org/D29377</a> made GVNHoist use
DILocation::getMergedLocation. By design, getMergedLocation appears to return
null when the two locations are sufficiently different that preserving one or
the other would produce a "jumpy" line table.

Unfortunately, if the instruction being hoisted is an inlinable call, this
conflicts with the verifier's assertions that require accurate scope
information on inlinable calls. Typically a call can be hoisted if it is
readnone, i.e. it is a pure function of its arguments.

Consider:

$ cat t.c
void useit1(float);
void useit2(float);
double fabs(double);
float fabsf(float f) {
  return (float)fabs((double)f);
}
void hoistit(int cond, float f) {
  if (cond) {
    useit1(fabsf(f));
  } else {
    useit2(fabsf(f));
  }
}

$ clang -S t.c -o - -emit-llvm -g | opt -functionattrs -gvn-hoist -S
inlinable function call in a function with debug info must have a !dbg location
  %call = call float @fabsf(float %1) #1
LLVM ERROR: Broken function found, compilation aborted!

If I revert r294250, we leave the location of the first call to fabsf, and the
problem goes away.

I'm filing the bug rather than simply reverting because this seems to raise a
higher level design question about stripping location information when
hoisting.</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>