diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/compile/internal/gc/esc.go | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/gc/esc.go b/src/cmd/compile/internal/gc/esc.go index 4215950576..fcb4e96a75 100644 --- a/src/cmd/compile/internal/gc/esc.go +++ b/src/cmd/compile/internal/gc/esc.go @@ -715,6 +715,7 @@ func (e *EscState) esc(n *Node, parent *Node) { fmt.Printf("%v:[%d] %v esc: %v\n", linestr(lineno), e.loopdepth, funcSym(Curfn), n) } +opSwitch: switch n.Op { // Record loop depth at declaration. case ODCL: @@ -1000,13 +1001,6 @@ func (e *EscState) esc(n *Node, parent *Node) { // and keep the current loop depth. if n.Left.Op == ONAME { switch n.Left.Class() { - case PAUTO: - nE := e.nodeEscState(n) - leftE := e.nodeEscState(n.Left) - if leftE.Loopdepth != 0 { - nE.Loopdepth = leftE.Loopdepth - } - // PPARAM is loop depth 1 always. // PPARAMOUT is loop depth 0 for writes // but considered loop depth 1 for address-of, @@ -1016,8 +1010,22 @@ func (e *EscState) esc(n *Node, parent *Node) { case PPARAM, PPARAMOUT: nE := e.nodeEscState(n) nE.Loopdepth = 1 + break opSwitch } } + nE := e.nodeEscState(n) + leftE := e.nodeEscState(n.Left) + if leftE.Loopdepth != 0 { + nE.Loopdepth = leftE.Loopdepth + } + + case ODOT, + ODOTPTR, + OINDEX: + // Propagate the loopdepth of t to t.field. + if n.Left.Op != OLITERAL { // OLITERAL node doesn't have esc state + e.nodeEscState(n).Loopdepth = e.nodeEscState(n.Left).Loopdepth + } } lineno = lno |
