From 9c3f2685589e05c21563c583b683d00703eb0090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=B6hrmann?= Date: Sat, 2 Sep 2017 14:31:13 +0200 Subject: [PATCH] cmd/compile: set hiter type for map iterator in order pass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/cmd/compile/internal/gc/order.go | 5 +++-- src/cmd/compile/internal/gc/range.go | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmd/compile/internal/gc/order.go b/src/cmd/compile/internal/gc/order.go index 3265805000..27c3272cab 100644 --- a/src/cmd/compile/internal/gc/order.go +++ b/src/cmd/compile/internal/gc/order.go @@ -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)) diff --git a/src/cmd/compile/internal/gc/range.go b/src/cmd/compile/internal/gc/range.go index 032601ca3d..c9f2f01282 100644 --- a/src/cmd/compile/internal/gc/range.go +++ b/src/cmd/compile/internal/gc/range.go @@ -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