Skip to content

Commit

Permalink
cmd/compile: set hiter type for map iterator in order pass
Browse files Browse the repository at this point in the history
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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
  • Loading branch information
martisch committed Sep 5, 2017
1 parent bb31217 commit 9c3f268
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/cmd/compile/internal/gc/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/compile/internal/gc/range.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c3f268

Please sign in to comment.