plan9fox/sys
cinap_lenrek 95609d520e 8c: fix double compiling FNX complex lvalue in cgen64()
sugen() calls cgen64() speculatively so that when cgen64() returns
zero, it will fall back and compile 64-bit copy.

the bug was that cgen64() compiled the left hand side and then recursively
called cgen64() again, which didnt handle the memory copy so it returned
zero and sugen() would compile the left hand side again resulting in two
function calls being emited.

some code that reproduced the issue:

#include <u.h>
#include <libc.h>

typedef struct
{
	char x[10];
	vlong a;
} X;

X a;
X *f(void) { return &a; }

void
main(int argc, char *argv[])
{
	f()->a = a.a;
}

producing:

TEXT	f+0(SB),0,$0
	MOVL	$a+0(SB),AX
	RET	,
	RET	,
	TEXT	main+0(SB),0,$0
	CALL	,f+0(SB)
	CALL	,f+0(SB)			<- bug
	MOVL	AX,CX
	LEAL	a+12(SB),DX
	MOVL	(DX),AX
	MOVL	AX,12(CX)
	MOVL	4(DX),AX
	MOVL	AX,16(CX)
	RET	,
	GLOBL	a+0(SB),$20
	END	,
2016-10-30 23:30:13 +01:00
..
doc closed spew branch 2016-04-28 20:52:36 +02:00
games/lib fortunes: does that me a dipshit 2016-10-16 14:16:17 -04:00
include ape/libsec: add secp384r1 curve parameters for tls 2016-10-30 20:32:03 +01:00
lib fix wrong manpage section index generation for rc-httpd(8) 2016-08-27 22:37:08 +02:00
man winwatch: no more 'l' key labeling 2016-10-26 14:01:13 -05:00
src 8c: fix double compiling FNX complex lvalue in cgen64() 2016-10-30 23:30:13 +01:00