mirror of
https://github.com/golang/go
synced 2024-11-23 19:40:08 -07:00
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>
This commit is contained in:
parent
930ce09ca3
commit
2d82465d18
@ -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:
|
||||
|
||||
// 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 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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user