[Bug c++/11807] Wrong usage of registers on ARM
Richard Earnshaw
rearnsha@arm.com
Tue Aug 5 17:51:00 GMT 2003
> I'm not using fp explicitely in my code, as you can see in test.ii. I just
> preserve it across system calls. The compiler uses fp to store non-pointer
> values in fp and later uses it as pointer!
>
> So it is seemingly a BUG.
No, this asm statement clobbers fp (or appears to):
extern __inline__ l4_threadid_t l4_myself(void)
{
l4_threadid_t id;
asm volatile
(
" stmdb sp!, {fp} \n"
" mov r0, %2 \n"
" mov lr, pc \n"
" mov pc, %1 \n"
" mov %0, r1 \n"
" ldmia sp!, {fp} \n"
:"=r" (id)
:"i" ((-0x00000008-8)),
"i" (((l4_threadid_t) { raw : 0 }).raw)
:"r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
"r10", "r11", "r12", "r14", "memory");
return id;
}
This *will* confuse the compiler.
R.
More information about the Gcc-bugs
mailing list