[PATCH] D79778: [CodeGen] Remove buggy handling of input operands in inline asm

Victor Campos via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 28 06:30:22 PDT 2020


vhscampos added a comment.

This is the problematic case:

  void fn(int fd, int arg)
  {
    register int r7 __asm__("r7");
    __asm__ __volatile__ ( "svc 0" : : "r"(r7), "r"(fd), "r"(arg) : "memory");
  }

Note that, differently from bug 34165, 'r7' is not written to here.

gcc gives no warning or error. Clang, however:

  b.c:4:26: error: write to reserved register 'R7'
    __asm__ __volatile__ ( "svc 0" : : "r"(r7), "r"(fd), "r"(arg) : "memory");

And this is because the current code considers as an error any use of 'r7' as input operand, regardless of it being written to or not.

A correct implementation should trigger an error only when the input operand is written to. This is what motivates me to remove the handling of input operands while we come up with a correct implementation, likely in Clang rather than LLVM as you suggested.

The handling of output operands will remain present as it has not been shown to be wrong.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79778/new/

https://reviews.llvm.org/D79778





More information about the llvm-commits mailing list