From: Russ Cox Date: Fri, 14 Feb 2014 02:11:50 +0000 (-0500) Subject: cmd/gc: fix liveness for addressed results X-Git-Tag: go1.3beta1~710 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=824e918ca4f799c4105ef1b96d81894a137a1b29;p=gostls13.git cmd/gc: fix liveness for addressed results Was spuriously marking results live on entry to function. TBR=iant CC=golang-codereviews https://golang.org/cl/63640043 --- diff --git a/src/cmd/gc/plive.c b/src/cmd/gc/plive.c index 4e3eadcd74..bd14610864 100644 --- a/src/cmd/gc/plive.c +++ b/src/cmd/gc/plive.c @@ -668,8 +668,15 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit) node = *(Node**)arrayget(vars, i); switch(node->class & ~PHEAP) { case PPARAM: - case PPARAMOUT: bvset(uevar, i); + case PPARAMOUT: + // If the result had its address taken, it is being tracked + // by the avarinit code, which does not use uevar. + // If we added it to uevar too, we'd not see any kill + // and decide that the varible was live entry, which it is not. + // So only use uevar in the non-addrtaken case. + if(!node->addrtaken) + bvset(uevar, i); break; } } diff --git a/test/live.go b/test/live.go index c0ea131294..c3dbc55c0a 100644 --- a/test/live.go +++ b/test/live.go @@ -86,3 +86,12 @@ func f6() (_, y string) { y = "hello" return } + +// confusion about addressed results used to cause "live at entry to f7: x". + +func f7() (x string) { + _ = &x + x = "hello" + return +} +