Hello colleagues,
I've come across a suspicious error with inline asm and register allocation,
and am looking for a clarification of the rules.
What aspect of inline asm processing is preventing gcc from allocating
register eax to both %0 and %1's address in the following test case?
gcc -m32 -S foo.c
foo.c: In function 'foo':
foo.c:20: error: can't find a register in class 'GENERAL_REGS' while
reloading 'asm'
I could understand this error if val was an early clobber, "=&r" (val),
as the description of "&" says such operands cannot be assigned to the
same register as an input, or any register used in a memory address.
But since no ampersand is present, it seems eax is available here
for both operands.
int foo(int *ptr) {
int val;
__asm__ __volatile__("junk %0, %1"
: "=r" (val), "+m" (*ptr)
: : "memory" , "ebx" , "ecx" , "edx" , "esi" , "edi");
return val;
}
Looking forward to an answer, thanks!
Mitch Bodart
Intel Corporation