Commit 824e918c authored by Russ Cox's avatar Russ Cox

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
parent 656a4025
...@@ -668,8 +668,15 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit) ...@@ -668,8 +668,15 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit)
node = *(Node**)arrayget(vars, i); node = *(Node**)arrayget(vars, i);
switch(node->class & ~PHEAP) { switch(node->class & ~PHEAP) {
case PPARAM: case PPARAM:
case PPARAMOUT:
bvset(uevar, i); 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; break;
} }
} }
......
...@@ -86,3 +86,12 @@ func f6() (_, y string) { ...@@ -86,3 +86,12 @@ func f6() (_, y string) {
y = "hello" y = "hello"
return return
} }
// confusion about addressed results used to cause "live at entry to f7: x".
func f7() (x string) {
_ = &x
x = "hello"
return
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment