Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[ARM] MC crashes with LDREXD inline assembly #30694

Open Quuxplusone opened 7 years ago

Quuxplusone commented 7 years ago
Bugzilla Link PR31721
Status NEW
Importance P normal
Reported by Renato Golin (rengolin@gmail.com)
Reported on 2017-01-23 10:21:39 -0800
Last modified on 2019-05-03 09:17:41 -0700
Version trunk
Hardware PC Linux
CC diana.picus@linaro.org, llvm-bugs@lists.llvm.org, nicolasweber@gmx.de
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
While investigating Bug #31058, 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 bug #31058 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 bug #31720.
Quuxplusone commented 5 years ago

This still reproduces at today's trunk.