github.com/flyinox/gosm@v0.0.0-20171117061539-16768cb62077/test/fixedbugs/issue19137.go (about)

     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  
    10  package p
    11  
    12  type T struct {
    13  	p *int
    14  	a [2]byte
    15  	b [6]byte // not 4-byte aligned
    16  }
    17  
    18  func 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.
    26  func 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  }
    31  func 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  }