[gnu.gcc.bug] '-fforce-addr' generates illegal MC68000 instruction

lgm@ODDJOB.UCHICAGO.EDU (11/27/88)

SYNOPSIS:
The '-fforce-addr' option can generate illegal MC68000 instructions
for the passing of a structure by value as a function argument.

MACHINE AND OS:
AT&T UNIX PC 3B1 (based on Motorola 68010 microprocessor) running
OS Version 3.5 (compatible with UNIX System V Release 2).

CONFIGURATION FILES:
(usual for the UNIX PC)
"tm-3b1.h"
"xm-3b1.h"
"m68k.md"
"output-m68k.c"

TRANSCRIPT (INPUT FILE, COMMAND LINE, OUTPUT):
_______________________________________
$ cat struc.c
struct	S {
	short	s[ 6 ];
};

extern	void	g();

void
f( s )
struct	S	s;
{
	g( s );
}
$ gcc -v -S -O -fforce-addr struc.c
gcc version 1.31
 /usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68k -Dunix -Dunixpc -D__OPTIMIZE__ struc.c /tmp/cca04406.cpp
GNU CPP version 1.31
 /usr/local/lib/gcc-cc1 /tmp/cca04406.cpp -quiet -dumpbase struc.c -fforce-addr -O -version -o struc.s
GNU C version 1.31 (68k, SGS/AT&T unixpc syntax) compiled by GNU C version 1.31.
$ cat struc.s
	file	"struc.c"
text
	even
	global f
f:
	link.w %a6,&0
	lea 20(%fp),%a0
	lea -(%sp),%a1		# Illegal addressing mode for 'lea'
	mov.l -(%a0),(%a1)
	lea -(%sp),%a1		# Similarly illegal
	mov.l -(%a0),(%a1)
	lea -(%sp),%a1		# Similarly illegal
	mov.l -(%a0),(%a1)
	jsr g
	unlk %a6
	rts
$
_______________________________________

EXPLANATION OF TRANSCRIPT:
'lea' does not accept the predecrement addressing mode.  Ironically,
in this case the wiser course is not to generate the 'lea' instructions
at all, but rather to leave the original sequence (i.e., the one
that is generated without the '-fforce-addr' option), which uses

	mov.l	-(%a0),-(%sp)


	Lawrence G. Mayka
	Aurora, Illinois

	chinet!lmayk!lgm