<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 - Inline asm fails to notify on bad inline asm eventually crashing"
   href="https://bugs.llvm.org/show_bug.cgi?id=37860">37860</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inline asm fails to notify on bad inline asm eventually crashing
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Found via a crash on invalid, there was an inline asm that looked like:

__attribute__((target("avx,avx2,fma"))) void Accumulate(__m256 a, __m256 b,
                                                        __m256 *acc) {

  asm("vfmadd132ps %0 %1 (%2)" : : "r"(a), "r"(b), "r"(acc) :);
}

The somewhat more correct version would look like:

__attribute__((target("avx,avx2,fma"))) void Accumulate(__m256 a, __m256 b,
                                                        __m256 *acc) {

  asm("vfmadd132ps %0,%1,%2" : "+x"(a) : "x"(b), "x"(*acc) :);
}


Filing this bug to get better diagnostics and so I don't forget it.

The register constraints are wrong and we should have identified them,
unfortunately the code that looks at that isn't looking at the attributes on
the target to make those determinations and so wouldn't identify either them or
what's going on in a number of places.

The inline asm checker would have failed even on the correct code because it's
using the -msse4.2 command line to do the verification thus thinking that the
'x' constraint corresponds to 128 bits rather than 256 bits.

This means that we need subtarget/verification checking here for target
attribute code in addition to the code that verifies for intrinsics so we don't
incorrectly warn/error on valid code.</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>