Commit ac8127d7 authored by Keith Randall's avatar Keith Randall

cmd/compile: fix register size for ODOTPTR result

The result of ODOTPTR, as well as a bunch of other ops,
should be the type of the result, not always a pointer type.

This fixes an amd64p32 bug where we were incorrectly truncating
a 64-bit slice index to 32 bits, and then barfing on a weird
load-64-bits-but-then-truncate-to-32-bits op that doesn't exist.

Fixes #15252

Change-Id: Ie62f4315fffd79f233e5449324ccc0879f5ac343
Reviewed-on: https://go-review.googlesource.com/22094
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 7c7081f5
......@@ -946,7 +946,7 @@ func Cgenr(n *Node, a *Node, res *Node) {
OCALLINTER:
var n1 Node
Igen(n, &n1, res)
Regalloc(a, Types[Tptr], &n1)
Regalloc(a, n.Type, &n1)
Thearch.Gmove(&n1, a)
Regfree(&n1)
......
// run
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This test makes sure that we use all 64 bits of an
// index, even on 32 bit machines. It also tests that nacl
// can compile 64 bit indexes loaded from ODOTPTR properly.
package main
type T struct {
i int64
}
func f(t *T) byte {
b := [2]byte{3, 4}
return b[t.i]
}
func main() {
t := &T{0x100000001}
defer func() {
r := recover()
if r == nil {
panic("panic wasn't recoverable")
}
}()
f(t)
panic("index didn't panic")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment