mirror of
https://github.com/golang/go
synced 2024-10-06 08:00:07 +00:00
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:
parent
656a402545
commit
824e918ca4
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue