cmd/compile: remove NodeList != NodeList comparisons
Opt for replacements that avoid any assumptions
about the representations in use.
Passes toolstash -cmp.
Change-Id: Ia858a33abcae344e03fc1862fc9b0e192fde80c1
Reviewed-on: https://go-review.googlesource.com/20279
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go
index a34f4b2..c4b6bda 100644
--- a/src/cmd/compile/internal/gc/walk.go
+++ b/src/cmd/compile/internal/gc/walk.go
@@ -2336,7 +2336,7 @@
var early *NodeList
var mapinit *NodeList
- for list := all; list != nil; list = list.Next {
+ for list, i := all, 0; list != nil; list, i = list.Next, i+1 {
l = list.N.Left
// Save subexpressions needed on left side.
@@ -2348,7 +2348,7 @@
}
if l.Op == OINDEX && Isfixedarray(l.Left.Type) {
- reorder3save(&l.Right, all, list, &early)
+ reorder3save(&l.Right, all, i, &early)
l = l.Left
continue
}
@@ -2364,18 +2364,18 @@
break
case OINDEX, OINDEXMAP:
- reorder3save(&l.Left, all, list, &early)
- reorder3save(&l.Right, all, list, &early)
+ reorder3save(&l.Left, all, i, &early)
+ reorder3save(&l.Right, all, i, &early)
if l.Op == OINDEXMAP {
list.N = convas(list.N, &mapinit)
}
case OIND, ODOTPTR:
- reorder3save(&l.Left, all, list, &early)
+ reorder3save(&l.Left, all, i, &early)
}
// Save expression on right side.
- reorder3save(&list.N.Right, all, list, &early)
+ reorder3save(&list.N.Right, all, i, &early)
}
early = concat(mapinit, early)
@@ -2383,12 +2383,12 @@
}
// if the evaluation of *np would be affected by the
-// assignments in all up to but not including stop,
+// assignments in all up to but not including the ith assignment,
// copy into a temporary during *early and
// replace *np with that temp.
-func reorder3save(np **Node, all *NodeList, stop *NodeList, early **NodeList) {
+func reorder3save(np **Node, all *NodeList, i int, early **NodeList) {
n := *np
- if !aliased(n, all, stop) {
+ if !aliased(n, all, i) {
return
}
@@ -2423,8 +2423,8 @@
}
// Is it possible that the computation of n might be
-// affected by writes in as up to but not including stop?
-func aliased(n *Node, all *NodeList, stop *NodeList) bool {
+// affected by writes in as up to but not including the ith element?
+func aliased(n *Node, all *NodeList, i int) bool {
if n == nil {
return false
}
@@ -2438,7 +2438,7 @@
varwrite := 0
var a *Node
- for l := all; l != stop; l = l.Next {
+ for l := all; i > 0; l, i = l.Next, i-1 {
a = outervalue(l.N.Left)
if a.Op != ONAME {
memwrite = 1