]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: relax liveness restrictions on ambiguously live
authorThan McIntosh <thanm@google.com>
Thu, 14 Jul 2016 17:23:11 +0000 (13:23 -0400)
committerIan Lance Taylor <iant@golang.org>
Mon, 3 Oct 2016 18:07:32 +0000 (18:07 +0000)
Update gc liveness to remove special conservative treatment
of ambiguously live vars, since there is no longer a need to
protect against GCDEBUG=gcdead.

Change-Id: Id6e2d03218f7d67911e8436d283005a124e6957f
Reviewed-on: https://go-review.googlesource.com/24896
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

src/cmd/compile/internal/gc/plive.go
test/live.go

index 26e2ce9239c3a3b205c3186678ec6b95ac7c14e1..fed21c0c84d45d21a6c1ec7662ff2f0e6fb7a8e0 100644 (file)
@@ -1188,17 +1188,18 @@ func livenessepilogue(lv *Liveness) {
        avarinit := bvalloc(nvars)
        any := bvalloc(nvars)
        all := bvalloc(nvars)
-       ambig := bvalloc(localswords())
+       pparamout := bvalloc(localswords())
 
-       // Set ambig bit for the pointers to heap-allocated pparamout variables.
-       // These are implicitly read by post-deferreturn code and thus must be
-       // kept live throughout the function (if there is any defer that recovers).
+       // Record pointers to heap-allocated pparamout variables.  These
+       // are implicitly read by post-deferreturn code and thus must be
+       // kept live throughout the function (if there is any defer that
+       // recovers).
        if hasdefer {
                for _, n := range lv.vars {
                        if n.IsOutputParamHeapAddr() {
                                n.Name.Needzero = true
                                xoffset := n.Xoffset + stkptrsize
-                               onebitwalktype1(n.Type, &xoffset, ambig)
+                               onebitwalktype1(n.Type, &xoffset, pparamout)
                        }
                }
        }
@@ -1250,11 +1251,6 @@ func livenessepilogue(lv *Liveness) {
                                                        if debuglive >= 1 {
                                                                Warnl(p.Lineno, "%v: %L is ambiguously live", Curfn.Func.Nname, n)
                                                        }
-
-                                                       // Record in 'ambiguous' bitmap.
-                                                       xoffset := n.Xoffset + stkptrsize
-
-                                                       onebitwalktype1(n.Type, &xoffset, ambig)
                                                }
                                        }
                                }
@@ -1355,11 +1351,9 @@ func livenessepilogue(lv *Liveness) {
                                locals := lv.livepointers[pos]
                                onebitlivepointermap(lv, liveout, lv.vars, args, locals)
 
-                               // Ambiguously live variables are zeroed immediately after
-                               // function entry. Mark them live for all the non-entry bitmaps
-                               // so that GODEBUG=gcdead=1 mode does not poison them.
+                               // Mark pparamout variables (as described above)
                                if p.As == obj.ACALL {
-                                       bvor(locals, locals, ambig)
+                                       bvor(locals, locals, pparamout)
                                }
 
                                // Show live pointer bitmaps.
index b4d569a1bab8136798eb393f5dabda17bde642c7..74548231dd0d6e46701c1599bdd05ce8b12d5dd1 100644 (file)
@@ -47,24 +47,25 @@ func f2(b bool) {
 }
 
 func f3(b1, b2 bool) {
-       // Because x and y are ambiguously live, they appear
-       // live throughout the function, to avoid being poisoned
-       // in GODEBUG=gcdead=1 mode.
+       // Here x and y are ambiguously live. In previous go versions they
+       // were marked as live throughout the function to avoid being
+       // poisoned in GODEBUG=gcdead=1 mode; this is now no longer the
+       // case.
 
-       printint(0) // ERROR "live at call to printint: x y$"
+       printint(0)
        if b1 == false {
-               printint(0) // ERROR "live at call to printint: x y$"
+               printint(0)
                return
        }
 
        if b2 {
                var x *int
-               printpointer(&x) // ERROR "live at call to printpointer: x y$"
-               printpointer(&x) // ERROR "live at call to printpointer: x y$"
+               printpointer(&x) // ERROR "live at call to printpointer: x$"
+               printpointer(&x) // ERROR "live at call to printpointer: x$"
        } else {
                var y *int
-               printpointer(&y) // ERROR "live at call to printpointer: y$"
-               printpointer(&y) // ERROR "live at call to printpointer: y$"
+               printpointer(&y) // ERROR "live at call to printpointer: y$"
+               printpointer(&y) // ERROR "live at call to printpointer: y$"
        }
        printint(0) // ERROR "f3: x \(type \*int\) is ambiguously live$" "f3: y \(type \*int\) is ambiguously live$" "live at call to printint: x y$"
 }