]> Cypherpunks repositories - gostls13.git/commit
cmd/gc: shorten more temporary lifetimes
authorRuss Cox <rsc@golang.org>
Wed, 2 Apr 2014 00:02:54 +0000 (20:02 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 2 Apr 2014 00:02:54 +0000 (20:02 -0400)
commitdaca06f2e35035ea2c9d508f9f52a23baa406885
tree5fcdb66368e71890bf930cb18d26c4d1cbef68d4
parent2f3776ac2765a6d9cede9894efafb980c670ddb1
cmd/gc: shorten more temporary lifetimes

1. In functions with heap-allocated result variables or with
defer statements, the return sequence requires more than
just a single RET instruction. There is an optimization that
arranges for all returns to jump to a single copy of the return
epilogue in this case. Unfortunately, that optimization is
fundamentally incompatible with PC-based liveness information:
it takes PCs at many different points in the function and makes
them all land at one PC, making the combined liveness information
at that target PC a mess. Disable this optimization, so that each
return site gets its own copy of the 'call deferreturn' and the
copying of result variables back from the heap.
This removes quite a few spurious 'ambiguously live' variables.

2. Let orderexpr allocate temporaries that are passed by address
to a function call and then die on return, so that we can arrange
an appropriate VARKILL.

2a. Do this for ... slices.

2b. Do this for closure structs.

2c. Do this for runtime.concatstring, which is the implementation
of large string additions. Change representation of OADDSTR to
an explicit list in typecheck to avoid reconstructing list in both
walk and order.

3. Let orderexpr allocate the temporary variable copies used for
range loops, so that they can be killed when the loop is over.
Similarly, let it allocate the temporary holding the map iterator.

CL 81940043 reduced the number of ambiguously live temps
in the godoc binary from 860 to 711.

This CL reduces the number to 121. Still more to do, but another
good checkpoint.

Update #7345

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/83090046
15 files changed:
src/cmd/5g/ggen.c
src/cmd/6g/ggen.c
src/cmd/8g/ggen.c
src/cmd/gc/closure.c
src/cmd/gc/const.c
src/cmd/gc/esc.c
src/cmd/gc/fmt.c
src/cmd/gc/go.h
src/cmd/gc/order.c
src/cmd/gc/pgen.c
src/cmd/gc/range.c
src/cmd/gc/sinit.c
src/cmd/gc/typecheck.c
src/cmd/gc/walk.c
test/live.go