aboutsummaryrefslogtreecommitdiff
path: root/test/fixedbugs/issue44739.go
blob: 3441a903437e03a6f3cb0854009d55cb91c033a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// 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)
	}
}