mirror of
https://github.com/golang/go
synced 2024-11-05 18:36:08 +00:00
cmd/7g: fix ACMP entry in progtable
On arm64, CMP $foo, R is encoded as from=$foo, reg=R, not as from=$foo,
to=R. The progtable entry for ACMP incorrectly described the latter
form. Because of this, the registerizer was not accounting the registers
used in CMP instructions and was incorrectly re-assigning those registers.
This was an old problem, but it only became apparent after b115c35
(cmd/internal/gc: move cgen, regalloc, et al to portable code). Previous
to this commit, the compiler used a slightly larger register set for the
temps than it used for register variables. Since it had plenty registers
dedicated to temps, the registers used in CMP instruction never clashed
with registers assigned to register variables.
Fixes #10253
Change-Id: Iedf4bd882bd59440dff310ac0f81e0f53d80d7ed
Reviewed-on: https://go-review.googlesource.com/8387
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
This commit is contained in:
parent
bb298754ab
commit
33448d963c
2 changed files with 27 additions and 1 deletions
|
@ -57,7 +57,7 @@ var progtable = [arm64.ALAST]obj.ProgInfo{
|
|||
arm64.ALSL: {gc.SizeQ | gc.LeftRead | gc.RegRead | gc.RightWrite, 0, 0, 0},
|
||||
arm64.ALSR: {gc.SizeQ | gc.LeftRead | gc.RegRead | gc.RightWrite, 0, 0, 0},
|
||||
arm64.AASR: {gc.SizeQ | gc.LeftRead | gc.RegRead | gc.RightWrite, 0, 0, 0},
|
||||
arm64.ACMP: {gc.SizeQ | gc.LeftRead | gc.RightRead, 0, 0, 0},
|
||||
arm64.ACMP: {gc.SizeQ | gc.LeftRead | gc.RegRead, 0, 0, 0},
|
||||
|
||||
// Floating point.
|
||||
arm64.AFADDD: {gc.SizeD | gc.LeftRead | gc.RegRead | gc.RightWrite, 0, 0, 0},
|
||||
|
|
26
test/fixedbugs/issue10253.go
Normal file
26
test/fixedbugs/issue10253.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
// run
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// issue 10253: cmd/7g: bad codegen, probably regopt related
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
if !eq() {
|
||||
panic("wrong value")
|
||||
}
|
||||
}
|
||||
|
||||
var text = "abc"
|
||||
var s = &str{text}
|
||||
|
||||
func eq() bool {
|
||||
return text[0] == s.text[0]
|
||||
}
|
||||
|
||||
type str struct {
|
||||
text string
|
||||
}
|
Loading…
Reference in a new issue