glibc 2.0.5 is miscompiled by egcs 970904

Richard Henderson rth@cygnus.com
Sun Sep 7 15:43:00 GMT 1997


>   register long int retval asm ("$0");
[...]
>   asm volatile
>     ("cmoveq %1, 1, %0\n\t"	 
>      "ret $31, (%2), 1"	 
>      : "=r" (retval)
>      : "0" (val), "r" (retpc));

Interesting.  -O yields

        bis $17,$17,$0
        cmoveq $0, 1, $0

as intended, while -O2 yields

        cmoveq $17, 1, $17

At first blush, the code is actually seems broken, but the more proper

	asm volatile("cmoveq %0, 1, %0\n\tret (%1)"
		     : "=r"(retval) : "r"(retpc), "0"(val));

is broken too, while

	asm volatile("cmoveq %1, 1, %0\n\tret (%2)"
		     : "=r"(retval) : "r"(val), "r"(retpc), "0"(val));

works.

Now it does seem to me that explicitly named register variables
should get presidence in an asm than those that aren't.

But as we have a short term solution, and the fact that I've never
been particularly happy with implementing longjmp in C at all, I'm
not terribly motivated to dive into reload to find this.


r~



More information about the Gcc mailing list