]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix liveness for addressed results
authorRuss Cox <rsc@golang.org>
Fri, 14 Feb 2014 02:11:50 +0000 (21:11 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 14 Feb 2014 02:11:50 +0000 (21:11 -0500)
Was spuriously marking results live on entry to function.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/63640043

src/cmd/gc/plive.c
test/live.go

index 4e3eadcd74d9bc21f4138c3bda00662dbb270a71..bd146108641683f1fb93ced13e1e3ab60223c47e 100644 (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;
                        }
                }
index c0ea13129465cf9b67b8a8127894bb8688c40455..c3dbc55c0a209932560e8df04140ccf8e0ececba 100644 (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
+}
+