diff options
author | Russ Cox <rsc@golang.org> | 2014-02-15 10:58:55 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-02-15 10:58:55 -0500 |
commit | 2efa8cf2ee4df13201b7038c07c439a0c9dfae16 (patch) | |
tree | 700e5edd9ff95dcc7e214100432f8a35675ed277 /test/live.go | |
parent | d5bec7f3a722f435e04fb6d66c68b400742a15b6 (diff) | |
download | go-2efa8cf2ee4df13201b7038c07c439a0c9dfae16.tar.gz |
cmd/gc: correct liveness for fat variables
The VARDEF placement must be before the initialization
but after any final use. If you have something like s = ... using s ...
the rhs must be evaluated, then the VARDEF, then the lhs
assigned.
There is a large comment in pgen.c on gvardef explaining
this in more detail.
This CL also includes Ian's suggestions from earlier CLs,
namely commenting the use of mode in link.h and fixing
the precedence of the ~r check in dcl.c.
This CL enables the check that if liveness analysis decides
a variable is live on entry to the function, that variable must
be a function parameter (not a result, and not a local variable).
If this check fails, it indicates a bug in the liveness analysis or
in the generated code being analyzed.
The race detector generates invalid code for append(x, y...).
The code declares a temporary t and then uses cap(t) before
initializing t. The new liveness check catches this bug and
stops the compiler from writing out the buggy code.
Consequently, this CL disables the race detector tests in
run.bash until the race detector bug can be fixed
(golang.org/issue/7334).
Except for the race detector bug, the liveness analysis check
does not detect any problems (this CL and the previous CLs
fixed all the detected problems).
The net test still fails with GOGC=0 but the rest of the tests
now pass or time out (because GOGC=0 is so slow).
TBR=iant
CC=golang-codereviews
https://codereview.appspot.com/64170043
Diffstat (limited to 'test/live.go')
-rw-r--r-- | test/live.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/live.go b/test/live.go index 9c4e754c1..077a9b676 100644 --- a/test/live.go +++ b/test/live.go @@ -182,3 +182,15 @@ func f12() *int { return nil } } + +// incorrectly placed VARDEF annotations can cause missing liveness annotations. +// this used to be missing the fact that s is live during the call to g13 (because it is +// needed for the call to h13). + +func f13() { + s := "hello" + s = h13(s, g13(s)) // ERROR "live at call to g13: s" +} + +func g13(string) string +func h13(string, string) string |