]> Cypherpunks repositories - gostls13.git/commit
cmd/8c: fix store to complex uint64 ptr
authorRuss Cox <rsc@golang.org>
Tue, 10 Apr 2012 14:45:58 +0000 (10:45 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 10 Apr 2012 14:45:58 +0000 (10:45 -0400)
commit30bc5d7bbd8644e044c8c3ecfceca9455326b7a5
treef0cc5efb3dd55dac3751838141dd22741765d56c
parentae382129f1f32b91115ef7d60ce9ec4108253e5d
cmd/8c: fix store to complex uint64 ptr

Assignment of a computed uint64 value to an
address derived with a function call was executing
the call after computing the value, which trashed
the value (held in registers).

long long *f(void) { return 0; }
void g(int x, int y) {
        *f() = (long long)x | (long long)y<<32;
}

Before:

(x.c:3) TEXT g+0(SB),(gok(71))
...
(x.c:4) ORL AX,DX
(x.c:4) ORL CX,BX
(x.c:4) CALL ,f+0(SB)
(x.c:4) MOVL DX,(AX)
(x.c:4) MOVL BX,4(AX)

After:
(x.c:3) TEXT g+0(SB),(gok(71))
(x.c:4) CALL ,f+0(SB)
...
(x.c:4) ORL CX,BX
(x.c:4) ORL DX,BP
(x.c:4) MOVL BX,(AX)
(x.c:4) MOVL BP,4(AX)

Fixes #3501.

R=ken2
CC=golang-dev
https://golang.org/cl/5998043
src/cmd/8c/cgen64.c