mirror of
https://github.com/golang/go
synced 2024-11-25 10:27:57 -07:00
ccf9acefa8
In the ppc64 ISA DS form loads and stores are restricted to offset fields that are a multiple of 4. This is currently handled with checks in the rules that generate MOVDload, MOVWload, MOVDstore and MOVDstorezero to prevent invalid instructions from getting to the assembler. An unhandled case was discovered which led to the search for a better solution to this problem. Now, instead of checking the offset in the rules, this will be detected when processing these Ops in ssaGenValues in ppc64/ssa.go. If the offset is not valid, the address of the symbol to be loaded or stored will be computed using the base register + offset, and that value used in the new base register. With the full address in the base register, the offset field can be zero in the instruction. Updates #44739 Change-Id: I4f3c0c469ae70a63e3add295c9b55ea0e30ef9b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/299789 Trust: Lynn Boger <laboger@linux.vnet.ibm.com> Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
62 lines
1.1 KiB
Go
62 lines
1.1 KiB
Go
// compile
|
|
|
|
// Copyright 2021 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 44739: cmd/compile: incorrect offset in MOVD
|
|
// load/store on ppc64/ppc64le causes assembler error.
|
|
|
|
// Test other 8 byte loads and stores where the
|
|
// compile time offset is not aligned to 8, as
|
|
// well as cases where the offset is not known
|
|
// until link time (e.g. gostrings).
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type T struct {
|
|
x [4]byte
|
|
y [8]byte
|
|
}
|
|
|
|
var st T
|
|
|
|
const (
|
|
gostring1 = "abc"
|
|
gostring2 = "defghijk"
|
|
gostring3 = "lmnopqrs"
|
|
)
|
|
|
|
func f(a T, _ byte, b T) bool {
|
|
// initialization of a,b
|
|
// tests unaligned store
|
|
return a.y == b.y
|
|
}
|
|
|
|
func g(a T) {
|
|
// test load of unaligned
|
|
// 8 byte gostring, store
|
|
// to unaligned static
|
|
copy(a.y[:], gostring2)
|
|
}
|
|
|
|
func main() {
|
|
var t1, t2 T
|
|
|
|
// test copy to automatic storage,
|
|
// load of unaligned gostring.
|
|
copy(st.y[:], gostring2)
|
|
copy(t1.y[:], st.y[:])
|
|
copy(t2.y[:], gostring3)
|
|
// test initialization of params
|
|
if !f(t1, 'a', t2) {
|
|
// gostring1 added so it has a use
|
|
fmt.Printf("FAIL: %s\n", gostring1)
|
|
}
|
|
}
|
|
|