[dev.regabi] cmd/compile: use ir.Find for "search" traversals

This CL converts all the generic searching traversal to use ir.Find
instead of relying on direct access to Left, Right, and so on.

Passes buildall w/ toolstash -cmp.

Change-Id: I4d951aef630c00bf333f24be79565cc564694d04
Reviewed-on: https://go-review.googlesource.com/c/go/+/275372
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Russ Cox 2020-12-02 20:18:47 -05:00
parent 0d1b44c645
commit b9df26d7a8
7 changed files with 247 additions and 341 deletions

View file

@ -60,7 +60,8 @@ func (s *InitSchedule) tryStaticInit(n ir.Node) bool {
if n.Op() != ir.OAS {
return false
}
if ir.IsBlank(n.Left()) && candiscard(n.Right()) {
if ir.IsBlank(n.Left()) && !hasSideEffects(n.Right()) {
// Discard.
return true
}
lno := setlineno(n)
@ -548,7 +549,8 @@ func fixedlit(ctxt initContext, kind initKind, n ir.Node, var_ ir.Node, init *ir
for _, r := range n.List().Slice() {
a, value := splitnode(r)
if a == ir.BlankNode && candiscard(value) {
if a == ir.BlankNode && !hasSideEffects(value) {
// Discard.
continue
}