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
This commit is contained in:
Russ Cox 2014-02-13 21:11:50 -05:00
parent 656a402545
commit 824e918ca4
2 changed files with 17 additions and 1 deletions

View file

@ -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;
}
}

View file

@ -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
}