Debian Codegraph @

test/fixedbugs/issue44739.go

raw
1 // compile
2
3 // Copyright 2021 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 // issue 44739: cmd/compile: incorrect offset in MOVD
8 // load/store on ppc64/ppc64le causes assembler error.
9
10 // Test other 8 byte loads and stores where the
11 // compile time offset is not aligned to 8, as
12 // well as cases where the offset is not known
13 // until link time (e.g. gostrings).
14
15 package main
16
17 import (
18 "fmt"
19 )
20
21 type T struct {
22 x [4]byte
23 y [8]byte
24 }
25
26 var st T
27
28 const (
29 gostring1 = "abc"
30 gostring2 = "defghijk"
31 gostring3 = "lmnopqrs"
32 )
33
34 func f(a T, _ byte, b T) bool {
35 // initialization of a,b
36 // tests unaligned store
37 return a.y == b.y
38 }
39
40 func g(a T) {
41 // test load of unaligned
42 // 8 byte gostring, store
43 // to unaligned static
44 copy(a.y[:], gostring2)
45 }
46
47 func main() {
48 var t1, t2 T
49
50 // test copy to automatic storage,
51 // load of unaligned gostring.
52 copy(st.y[:], gostring2)
53 copy(t1.y[:], st.y[:])
54 copy(t2.y[:], gostring3)
55 // test initialization of params
56 if !f(t1, 'a', t2) {
57 // gostring1 added so it has a use
58 fmt.Printf("FAIL: %s\n", gostring1)
59 }
60 }
61