-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Description
Bugzilla Link | 50754 |
Version | trunk |
OS | Linux |
CC | @Arnaud-de-Grandmaison-ARM,@smithp35 |
Extended Description
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.