1// compile 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 19137: folding address into load/store causes 8// odd offset on ARM64. 9 10package p 11 12type T struct { 13 p *int 14 a [2]byte 15 b [6]byte // not 4-byte aligned 16} 17 18func f(b [6]byte) T { 19 var x [1000]int // a large stack frame 20 _ = x 21 return T{b: b} 22} 23 24// Arg symbol's base address may be not at an aligned offset to 25// SP. Folding arg's address into load/store may cause odd offset. 26func move(a, b [20]byte) [20]byte { 27 var x [1000]int // a large stack frame 28 _ = x 29 return b // b is not 8-byte aligned to SP 30} 31func zero() ([20]byte, [20]byte) { 32 var x [1000]int // a large stack frame 33 _ = x 34 return [20]byte{}, [20]byte{} // the second return value is not 8-byte aligned to SP 35} 36 37// Issue 21992: unaligned offset between 256 and 504 and handled 38// incorrectly. 39type T2 struct { 40 a [257]byte 41 // fields below are not 8-, 4-, 2-byte aligned 42 b [8]byte 43 c [4]byte 44 d [2]byte 45} 46 47func f2(x *T2) { 48 x.b = [8]byte{} 49 x.c = [4]byte{} 50 x.d = [2]byte{} 51} 52