diff options
| author | hengwu0 <41297446+hengwu0@users.noreply.github.com> | 2019-03-05 01:24:35 +0000 |
|---|---|---|
| committer | Cherry Zhang <cherryyz@google.com> | 2019-03-05 03:53:51 +0000 |
| commit | 95d4e6158b4199e1eee957e2c8c934d2cb86c35e (patch) | |
| tree | e30fa2885784df417d618601ea47aa19ad123670 /src/cmd/internal | |
| parent | ab0c9510a988027f305d213213ed2eaaabbffe77 (diff) | |
| download | go-95d4e6158b4199e1eee957e2c8c934d2cb86c35e.tar.xz | |
cmd/compile: fix mips64 instruction UNPREDICTABLE bug
Replace addu with a sll instruction with a definite behavior (sll will discard the upper 32 bits of the 64 bits, then do sign extensions, with certain behavior). It won't have any UNPREDICTABLE expectation.
Fixes #30459
Change-Id: Id79085c28c5cc4f86939b4ef08ef4bff46077c45
GitHub-Last-Rev: 03569796a9a64ed6c7d56a5bca966fc62c89b4ff
GitHub-Pull-Request: golang/go#30461
Reviewed-on: https://go-review.googlesource.com/c/go/+/164758
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/internal')
| -rw-r--r-- | src/cmd/internal/obj/mips/asm0.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cmd/internal/obj/mips/asm0.go b/src/cmd/internal/obj/mips/asm0.go index 458e071e47..c117269c35 100644 --- a/src/cmd/internal/obj/mips/asm0.go +++ b/src/cmd/internal/obj/mips/asm0.go @@ -1120,9 +1120,11 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) { case 1: /* mov r1,r2 ==> OR r1,r0,r2 */ a := AOR if p.As == AMOVW && c.ctxt.Arch.Family == sys.MIPS64 { - a = AADDU // sign-extended to high 32 bits + // on MIPS64, most of the 32-bit instructions have unpredictable behavior, + // but SLL is special that the result is always sign-extended to 64-bit. + a = ASLL } - o1 = OP_RRR(c.oprrr(a), uint32(REGZERO), uint32(p.From.Reg), uint32(p.To.Reg)) + o1 = OP_RRR(c.oprrr(a), uint32(p.From.Reg), uint32(REGZERO), uint32(p.To.Reg)) case 2: /* add/sub r1,[r2],r3 */ r := int(p.Reg) |
