diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2015-02-19 16:27:32 +0300 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2015-03-28 16:15:27 +0000 |
| commit | edcc062bdc35a7dd6ac5d33aa85a135b020b72a8 (patch) | |
| tree | dcf12943f01cb1664af7e009e8403c8fa0875f4b /src | |
| parent | 8a2545744b2662fc34c117e769f3dbd2f7167d19 (diff) | |
| download | go-edcc062bdc35a7dd6ac5d33aa85a135b020b72a8.tar.xz | |
test: add tests for escape analysis of interface conversions
The false positives (var incorrectly escapes) are marked with BAD.
Change-Id: If64fabb6ea96de44a1177d9ab12e2ccc579fe0c4
Reviewed-on: https://go-review.googlesource.com/5294
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/internal/gc/esc.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/cmd/internal/gc/esc.go b/src/cmd/internal/gc/esc.go index 76ce87d513..6d9b72019c 100644 --- a/src/cmd/internal/gc/esc.go +++ b/src/cmd/internal/gc/esc.go @@ -653,9 +653,15 @@ func esc(e *EscState, n *Node, up *Node) { } } - case OCONV, - OCONVNOP, - OCONVIFACE: + case OCONV, OCONVNOP: + escassign(e, n, n.Left) + + case OCONVIFACE: + // We don't allocate storage for OCONVIFACE on stack yet, + // but mark it as EscNone merely to get debug output for tests. + n.Esc = EscNone // until proven otherwise + e.noesc = list(e.noesc, n) + n.Escloopdepth = e.loopdepth escassign(e, n, n.Left) case OARRAYLIT: @@ -878,7 +884,8 @@ func escassign(e *EscState, dst *Node, src *Node) { ONEW, OCLOSURE, OCALLPART, - ORUNESTR: + ORUNESTR, + OCONVIFACE: escflows(e, dst, src) // Flowing multiple returns to a single dst happens when @@ -900,7 +907,6 @@ func escassign(e *EscState, dst *Node, src *Node) { // Conversions, field access, slice all preserve the input value. // fallthrough case OCONV, - OCONVIFACE, OCONVNOP, ODOTMETH, // treat recv.meth as a value with recv in it, only happens in ODEFER and OPROC @@ -1342,7 +1348,8 @@ func escwalk(e *EscState, level int, dst *Node, src *Node) { ONEW, OCLOSURE, OCALLPART, - ORUNESTR: + ORUNESTR, + OCONVIFACE: if leaks { src.Esc = EscHeap if Debug['m'] != 0 { |
