]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: set hiter type for map iterator in order pass
authorMartin Möhrmann <moehrmann@google.com>
Sat, 2 Sep 2017 12:31:13 +0000 (14:31 +0200)
committerMartin Möhrmann <moehrmann@google.com>
Tue, 5 Sep 2017 21:00:59 +0000 (21:00 +0000)
Previously the type was first set to uint8 and then corrected
later in walkrange.

Change-Id: I9e4b597710e8a5fad39dde035df85676bc8d2874
Reviewed-on: https://go-review.googlesource.com/61032
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/order.go
src/cmd/compile/internal/gc/range.go

index 3265805000769f2b3255240341df719c86f795af..27c3272cab371280fdd88124ce8d02a2c2323201 100644 (file)
@@ -762,8 +762,9 @@ func orderstmt(n *Node, order *Order) {
                        r := n.Right
                        n.Right = ordercopyexpr(r, r.Type, order, 0)
 
-                       // n->alloc is the temp for the iterator.
-                       prealloc[n] = ordertemp(types.Types[TUINT8], order, true)
+                       // prealloc[n] is the temp for the iterator.
+                       // hiter contains pointers and needs to be zeroed.
+                       prealloc[n] = ordertemp(hiter(n.Type), order, true)
                }
                for i := range n.List.Slice() {
                        n.List.SetIndex(i, orderexprinplace(n.List.Index(i), order))
index 032601ca3dfd212da80ae6336eb789e2f50dd8ac..c9f2f012826e8b8e6cd8d698231f2a0404df641a 100644 (file)
@@ -249,9 +249,8 @@ func walkrange(n *Node) *Node {
                // we only use a once, so no copy needed.
                ha := a
 
-               th := hiter(t)
                hit := prealloc[n]
-               hit.Type = th
+               th := hit.Type
                n.Left = nil
                keysym := th.Field(0).Sym // depends on layout of iterator struct.  See reflect.go:hiter
                valsym := th.Field(1).Sym // ditto