<html>
    <head>
      <base href="http://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 --- - Assertion failed: (!CS.getInstruction() || !CS.getCalledFunction() || !CS.getCalledFunction()->isIntrinsic())"
   href="http://llvm.org/bugs/show_bug.cgi?id=22857">22857</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion failed: (!CS.getInstruction() || !CS.getCalledFunction() || !CS.getCalledFunction()->isIntrinsic())
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jonathan.sauer@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14014" name="attach_14014" title="Full log">attachment 14014</a> <a href="attachment.cgi?id=14014&action=edit" title="Full log">[details]</a></span>
Full log

The following code crashes clang r231653 when compiling with -Ofast:

struct Vector3 {
    float   m[3];
};

static Vector3 operator*(Vector3 lhs, float rhs)
{
    return {{ lhs.m[0] * rhs, lhs.m[1] * rhs, lhs.m[2] * rhs }};
}

static float dot(Vector3 lhs, Vector3 rhs)
{
    return lhs.m[0] * rhs.m[0] + lhs.m[1] * rhs.m[1] + lhs.m[2] * rhs.m[2];
}

static Vector3 projectOnLine(Vector3 vector, Vector3 lineNormal)
{
    return lineNormal * dot(vector, lineNormal);
}

static float intersectsWithCylindryObject(Vector3 obstacleOrientation, Vector3
obstaclePosition)
{
    Vector3 v = projectOnLine(obstaclePosition, obstacleOrientation);
    return __builtin_sqrtf(dot(v, v));
}

float intersect(Vector3 obstaclePosition)
{
    return ::intersectsWithCylindryObject({{ 0.0f, 0.0f, 1.0f }},
obstaclePosition);
}


This results in (full log attached):

% ~/LLVM/build/Release+Asserts/bin/clang++ -std=c++11 -Ofast -c clang.cpp
Assertion failed: (!CS.getInstruction() || !CS.getCalledFunction() ||
!CS.getCalledFunction()->isIntrinsic()), function addCalledFunction, file
/Users/rynnsauer/LLVM/llvm/include/llvm/Analysis/CallGraph.h, line 232.
...

It does not crash when removing the call to __buildin_sqrtf. It also does not
crash when compiling with clang 3.6.0 (tags/RELEASE_360/final).

This looks very similar to <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Assertion "Dangling pointers found in call sites map" with -ffast-math and __builtin_sqrtf"
   href="show_bug.cgi?id=21403">bug 21403</a>.</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>