]> Cypherpunks repositories - gostls13.git/commit
cmd/5g, cmd/6g: fix out of registers with array indexing.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 2 Nov 2012 06:50:59 +0000 (07:50 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 2 Nov 2012 06:50:59 +0000 (07:50 +0100)
commit0b2353edcb7fc6ff100f42b1d9cc5613a6c57da1
treef34ed113df23bd103fffe7ea48a78c8da78351b8
parentd659633aff6c56997e4400bce0929ffd1efefb6e
cmd/5g, cmd/6g: fix out of registers with array indexing.

Compiling expressions like:
    s[s[s[s[s[s[s[s[s[s[s[s[i]]]]]]]]]]]]
make 5g and 6g run out of registers. Such expressions can arise
if a slice is used to represent a permutation and the user wants
to iterate it.

This is due to the usual problem of allocating registers before
going down the expression tree, instead of allocating them in a
postfix way.

The functions cgenr and agenr (that generate a value to a newly
allocated register instead of an existing location), are either
introduced or modified when they already existed to allocate
the new register as late as possible, and sudoaddable is disabled
for OINDEX nodes so that igen/agenr is used instead.

Update #4207.

R=dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6733055
src/cmd/5g/cgen.c
src/cmd/5g/gsubr.c
src/cmd/6g/cgen.c
src/cmd/6g/gg.h
src/cmd/6g/gsubr.c
src/cmd/gc/fmt.c
test/torture.go