From 923a74ce7710c1e3b24b4cc3220e2ba38d7673af Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Tue, 6 Sep 2016 14:48:47 -0700 Subject: [PATCH] cmd/compile: ignore contentEscapes for marking nodes as escaping We can still stack allocate and VarKill nodes which don't escape but their content does. Fixes #16996 Change-Id: If8aa0fcf2c327b4cb880a3d5af8d213289e6f6bf Reviewed-on: https://go-review.googlesource.com/28575 Run-TryBot: Keith Randall TryBot-Result: Gobot Gobot Reviewed-by: David Chase --- src/cmd/compile/internal/gc/esc.go | 2 +- test/live.go | 10 ++++++++++ test/live_ssa.go | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/gc/esc.go b/src/cmd/compile/internal/gc/esc.go index c5597d7f48..0fd514fbaf 100644 --- a/src/cmd/compile/internal/gc/esc.go +++ b/src/cmd/compile/internal/gc/esc.go @@ -1572,7 +1572,7 @@ func esccall(e *EscState, n *Node, up *Node) { } if haspointers(t.Type) { - if escassignfromtag(e, note, nE.Escretval, src) == EscNone && up.Op != ODEFER && up.Op != OPROC { + if escassignfromtag(e, note, nE.Escretval, src)&EscMask == EscNone && up.Op != ODEFER && up.Op != OPROC { a := src for a.Op == OCONVNOP { a = a.Left diff --git a/test/live.go b/test/live.go index db47e14e93..ef0ade23c7 100644 --- a/test/live.go +++ b/test/live.go @@ -643,3 +643,13 @@ func good40() { printnl() // ERROR "live at call to printnl: autotmp_[0-9]+ ret$" _ = t } + +func ddd1(x, y *int) { // ERROR "live at entry to ddd1: x y$" + ddd2(x, y) // ERROR "live at call to ddd2: autotmp_[0-9]+$" + printnl() // nothing live here. See issue 16996. +} +func ddd2(a ...*int) { // ERROR "live at entry to ddd2: a$" + sink = a[0] +} + +var sink *int diff --git a/test/live_ssa.go b/test/live_ssa.go index 27c4528dc1..cf06141b44 100644 --- a/test/live_ssa.go +++ b/test/live_ssa.go @@ -646,3 +646,11 @@ func good40() { printnl() // ERROR "live at call to printnl: autotmp_[0-9]+ ret$" _ = t } + +func ddd1(x, y *int) { // ERROR "live at entry to ddd1: x y$" + ddd2(x, y) // ERROR "live at call to ddd2: autotmp_[0-9]+$" + printnl() // nothing live here. See issue 16996. +} +func ddd2(a ...*int) { // ERROR "live at entry to ddd2: a$" + sink = a[0] +}