<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 --- - llvm::CallInst::hasStructRetAttr cause unexpected assert"
   href="https://llvm.org/bugs/show_bug.cgi?id=25662">25662</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm::CallInst::hasStructRetAttr cause unexpected assert
          </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>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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>xiulipan@outlook.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>This bug happens when change llvm into 3.8 from svn, it will cause assert of
CallInst::paramHasAttr "Param index out of bounds!"(increased from
<a href="http://reviews.llvm.org/D14304">http://reviews.llvm.org/D14304</a>)\

In our case, the assert will happen when the CallInst has no
argument(getNumArgOperands() returns 0), and the code for
CallInst::hasStructRetAttr is:

01733     // Be friendly and also check the callee.
01732   bool hasStructRetAttr() const {
01734     return paramHasAttr(1, Attribute::StructRet);
01735   }

It seems the hasStructRetAttr has no bound check and passes invalid value to
paramHasAttr.

Or maybe we used the hasStructRetAttr function incorrectly, and it could not
use to CallInst with no arg. For now we just use a workaround to check the
getNumArgOperands() > 0 first. If we used hasStructRetAttr incorrectly, there
should be a assert in it before it passes some invalid value to others.</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>