[comp.sys.amiga.tech] Another Code generator bug in lattice

dale@boing.UUCP (Dale Luck) (07/16/89)

I'm posting this so that others are aware of this particular
code problem. This is an excerpted section of the Xlib from
X11 that when compiled under Lattice does not work.

Found a bug in Lattice 5.02 code generation.
It seems to loose it on register allocation
and who has what.

foo(dpy, req, valuemask, attributes)
register int *dpy;
long *req;
register unsigned long valuemask;
register long *attributes;
{
	unsigned long values[32];
	register unsigned long *value = values;
	long qwe = 0;
	unsigned int nvalues;

	if (valuemask & 0x1)
		*value++ = *attributes;

	/* following statement is compiler incorrectly */
	qwe += (nvalues = value - values);


	nvalues <<= 2;
	bar(dpy, (long *)values, (long)nvalues);
}


Lattice AMIGA 68000-68020 OBJ Module Disassembler V5.00
Copyright ) 1988 Lattice Inc.  All Rights Reserved.


Amiga Object File Loader V1.00
68000 Instruction Set

EXTERNAL DEFINITIONS

_foo 0000-00

SECTION 00 "bug1.c" 00000054 BYTES
| 0000  4E 55 FF 74          LINK      A5,#FF74
| 0004  BF EC  00 00-XX.2    CMPA.L    __base(A4),A7
| 0008  65 00  00 00-XX.1    BCS.W     __xcovf
| 000C  48 E7 07 30          MOVEM.L   D5-D7/A2-A3,-(A7)
| 0010  26 6F 00 A8          MOVEA.L   00A8(A7),A3
| 0014  2E 2F 00 B0          MOVE.L    00B0(A7),D7
| 0018  24 6F 00 B4          MOVEA.L   00B4(A7),A2
| 001C  41 ED FF 80          LEA       FF80(A5),A0
| 0020  7C 00                MOVEQ     #00,D6
| 0022  2B 48 FF 7C          MOVE.L    A0,FF7C(A5)
| 0026  08 07 00 00          BTST      #0000,D7
| 002A  67 06                BEQ.B     0032
| 002C  20 D2                MOVE.L    (A2),(A0)+
| 002E  2B 48 FF 7C  ******* MOVE.L    A0,FF7C(A5)	; begin bogosity
| 0032  20 08        ******* MOVE.L    A0,D0		;
| 0034  90 88        ******* SUB.L     A0,D0		; this won't work!
| 0036  E4 80                ASR.L     #2,D0
| 0038  2A 00                MOVE.L    D0,D5
| 003A  DC 85                ADD.L     D5,D6
| 003C  E5 85                ASL.L     #2,D5
| 003E  2F 05                MOVE.L    D5,-(A7)
| 0040  2F 08                MOVE.L    A0,-(A7)
| 0042  2F 0B                MOVE.L    A3,-(A7)
| 0044  4E BA  00 00-XX.1    JSR       _bar(PC)
| 0048  4C ED 0C E0 FF 60    MOVEM.L   FF60(A5),D5-D7/A2-A3
| 004E  4E 5D                UNLK      A5
| 0050  4E 75                RTS

So is there a patch somewhere to fix this? If I put
a printf around the statement the bug goes away!

Dale Luck     GfxBase/Boing, Inc. 408-262-1469
{uunet!cbmvax|pyramid}!amiga!boing!dale

Oh, by the way, after I patched around it with printfs I got my first
native compiled, linked X Window lattice program to run on the Amiga.
Good bye unix.

-- 
Dale Luck     GfxBase/Boing, Inc.
{uunet!cbmvax|pyramid}!amiga!boing!dale