<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 --- - [ARM] MC crashes with LDREXD inline assembly"
   href="https://llvm.org/bugs/show_bug.cgi?id=31721">31721</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ARM] MC crashes with LDREXD inline assembly
          </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>Backend: ARM
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>renato.golin@linaro.org
          </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>While investigating <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Integrated assembler rejects ldrexd/strexd in thumb mode"
   href="show_bug.cgi?id=31058">Bug #31058</a>, I found that the MC layer is crashing on a
syntax previously accepted by 3.9 Clang on ARM mode:

void foo(long long *ptr, long long value) {
  int store_failed;
  __asm__ __volatile__(
      "1:\n"
      // Dummy load to lock cache line.
      "ldrexd  %1, [%2]\n"
      "teq     %0, #0\n"
      "bne     1b"
      : "=&r" (store_failed)
      : "r"(value), "r" (ptr)
      : "cc", "memory");
}

$ clang -S -O2 -target armv7a ldrexd.c -o -

llvm/include/llvm/MC/MCInst.h:75: int64_t llvm::MCOperand::getImm() const:
Assertion `isImm() && "This is not an immediate"' failed.

However, since the syntax proposed in <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Integrated assembler rejects ldrexd/strexd in thumb mode"
   href="show_bug.cgi?id=31058">bug #31058</a> works:

void foo(long long *ptr, long long value) {
  int store_failed;
  __asm__ __volatile__(
      "1:\n"
      // Dummy load to lock cache line.
      "ldrexd  %1, %H1, [%2]\n"
      "teq     %0, #0\n"
      "bne     1b"
      : "=&r" (store_failed)
      : "r"(value), "r" (ptr)
      : "cc", "memory");
}

and is preferred, we may just emit an error for this GNU syntax. Or we can fix
it and make it work on Thumb and ARM. Whatever is easier.

Also, LLVM is currently emitting an error for Thumb:

strexd.c:7:8: error: instruction requires: arm-mode
      "ldrexd  %1, [%3]\n"
strexd.c:8:8: error: instruction requires: arm-mode
      "strexd  %0, %2, [%3]\n"

which may or may not be related to <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [ARM] LLVM allows {LD,ST}REX{B,H,D} on Thumb1 targets"
   href="show_bug.cgi?id=31720">bug #31720</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>