Debian Codegraph @

test/fixedbugs/issue21048.go

raw
1 // run
2
3 // Copyright 2017 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 21048: s390x merged address generation into stores
8 // to unaligned global variables. This resulted in an illegal
9 // instruction.
10
11 package main
12
13 type T struct {
14 _ [1]byte
15 a [2]byte // offset: 1
16 _ [3]byte
17 b [2]uint16 // offset: 6
18 _ [2]byte
19 c [2]uint32 // offset: 12
20 _ [2]byte
21 d [2]int16 // offset: 22
22 _ [2]byte
23 e [2]int32 // offset: 28
24 }
25
26 var Source, Sink T
27
28 func newT() T {
29 return T{
30 a: [2]byte{1, 2},
31 b: [2]uint16{1, 2},
32 c: [2]uint32{1, 2},
33 d: [2]int16{1, 2},
34 e: [2]int32{1, 2},
35 }
36 }
37
38 //go:noinline
39 func moves() {
40 Sink.a = Source.a
41 Sink.b = Source.b
42 Sink.c = Source.c
43 Sink.d = Source.d
44 Sink.e = Source.e
45 }
46
47 //go:noinline
48 func loads() *T {
49 t := newT()
50 t.a = Source.a
51 t.b = Source.b
52 t.c = Source.c
53 t.d = Source.d
54 t.e = Source.e
55 return &t
56 }
57
58 //go:noinline
59 func stores() {
60 t := newT()
61 Sink.a = t.a
62 Sink.b = t.b
63 Sink.c = t.c
64 Sink.d = t.d
65 Sink.e = t.e
66 }
67
68 func main() {
69 moves()
70 loads()
71 stores()
72 }