diff options
| author | Iskander Sharipov <iskander.sharipov@intel.com> | 2018-09-05 18:49:52 +0300 |
|---|---|---|
| committer | Iskander Sharipov <iskander.sharipov@intel.com> | 2018-09-17 11:06:01 +0000 |
| commit | 2d82465d18520820c52fea6b5e400a692ffdb92a (patch) | |
| tree | e8af195bdb3d8880810afe788e95b048c9fd8b4c | |
| parent | 930ce09ca3a1ab5f886c2327fc143b9ae075807b (diff) | |
| download | go-2d82465d18520820c52fea6b5e400a692ffdb92a.tar.xz | |
cmd/compile/internal/gc: treat cap/len as safe in mayAffectMemory
OLEN and OCAP can't affect memory state as long as their
arguments don't.
Re-organized case bodies to avoid duplicating same branches for
recursive invocations.
Change-Id: I30407143429f7dd1891badb70df88969ed267535
Reviewed-on: https://go-review.googlesource.com/133555
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
| -rw-r--r-- | src/cmd/compile/internal/gc/esc.go | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/cmd/compile/internal/gc/esc.go b/src/cmd/compile/internal/gc/esc.go index 9db6c8e0b4..254427be4f 100644 --- a/src/cmd/compile/internal/gc/esc.go +++ b/src/cmd/compile/internal/gc/esc.go @@ -689,18 +689,16 @@ func (e *EscState) mayAffectMemory(n *Node) bool { switch n.Op { case ONAME, OCLOSUREVAR, OLITERAL: return false - case ODOT, ODOTPTR: - return e.mayAffectMemory(n.Left) - case OIND, OCONVNOP: - return e.mayAffectMemory(n.Left) - case OCONV: - return e.mayAffectMemory(n.Left) - case OINDEX: - return e.mayAffectMemory(n.Left) || e.mayAffectMemory(n.Right) - case OADD, OSUB, OOR, OXOR, OMUL, OLSH, ORSH, OAND, OANDNOT, ODIV, OMOD: + + // Left+Right group. + case OINDEX, OADD, OSUB, OOR, OXOR, OMUL, OLSH, ORSH, OAND, OANDNOT, ODIV, OMOD: return e.mayAffectMemory(n.Left) || e.mayAffectMemory(n.Right) - case ONOT, OCOM, OPLUS, OMINUS, OALIGNOF, OOFFSETOF, OSIZEOF: + + // Left group. + case ODOT, ODOTPTR, OIND, OCONVNOP, OCONV, OLEN, OCAP, + ONOT, OCOM, OPLUS, OMINUS, OALIGNOF, OOFFSETOF, OSIZEOF: return e.mayAffectMemory(n.Left) + default: return true } |
