[net.bugs.4bsd] /lib/c2 bug in 4.1

chris@umcp-cs.UUCP (11/19/83)

Index: 4.1 lib/c2

Description:

/lib/c2 will, in certain cases (which the compiler never generates by
itself, it seems) eat labels that are needed.  Compiling the following
program demonstrates the bug.

(For the curious:  this came up in an experiment to determine just
how much less efficient it is to use calls/ret rather than jsb/rsb.
The answer?  Much, much, less efficient, at least when there are no
parameters.  Looks like about 13 usec / call difference.  Haven't
gotten to parameters yet...)

Repeat-By:

main () {
	register int i = 100000;

	while (--i >= 0)
		asm ("jsb foo");
	exit (0);
}

foo () {
	/*
	 * The symbol L22: is eaten by c2, even though it is
	 * being used by the jbr generated at the top of the
	 * function (the one for getting stack space).
	 */

	/* asm ("L22:");		/* get around c2 bug */

	asm ("foo:.globl foo");
	asm ("rsb");
}
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris.umcp-cs@CSNet-Relay