]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/gc: treat cap/len as safe in mayAffectMemory
authorIskander Sharipov <iskander.sharipov@intel.com>
Wed, 5 Sep 2018 15:49:52 +0000 (18:49 +0300)
committerIskander Sharipov <iskander.sharipov@intel.com>
Mon, 17 Sep 2018 11:06:01 +0000 (11:06 +0000)
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>
src/cmd/compile/internal/gc/esc.go

index 9db6c8e0b4b96399ad33a54e8e4c605744c99834..254427be4fd92007c98e9f222f93aae086b12d53 100644 (file)
@@ -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
        }