https://bugs.llvm.org/show_bug.cgi?id=50754

            Bug ID: 50754
           Summary: AArch64 inline asm does not explain why X19 is
                    reserved
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedb...@nondot.org
          Reporter: david.spick...@linaro.org
                CC: arnaud.degrandmai...@arm.com,
                    llvm-bugs@lists.llvm.org, smithp...@googlemail.com,
                    ties.st...@arm.com

Compiling the following:
extern void fn1(char*);
extern void fn2(int*);

int a;
int main() {
  char b[a];
  fn1(b);
  __asm("nop" : : : "x19");
  int c[64];
  fn2(c);
  return 0;
}

With:
./bin/clang --target=aarch64-linux-gnu -c -O0 test.c

Gives the following warning:
warning: inline asm clobber list contains reserved registers: X19
[-Winline-asm]
  __asm("nop" : : : "x19");
        ^
note: Reserved registers on the clobber list may not be preserved across the
asm statement, and clobbering them may lead to undefined behaviour.
1 warning generated.

The warning is not present when compiling with GCC.

https://godbolt.org/z/3r74Gq6c8

This is because llvm uses X19 as the base pointer for the stack frame. Or at
least, it does when it needs to. So small changes to the code shown can mean
you get a warning or not. (which is correct, but confusing if you're trying to
understand what's going on)

For the frame pointer X29 you get "FP" instead which is more obvious. Even if
you just got "X29" you could look at the ABI docs.

inline asm clobber list contains reserved registers: X19, FP [-Winline-asm]

The base pointer register is not assigned by the ABI it's up to the compiler so
it'd be good to add some explanation to this message.

Perhaps:
note: llvm uses X19 as the stack frame base pointer register.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to