Debian Codegraph @

test/fixedbugs/issue36723.go

raw
1 // compile -d=ssa/check/on
2
3 // Copyright 2020 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 36723: fail to compile on PPC64 when SSA check is on.
8
9 package p
10
11 import "unsafe"
12
13 type T struct {
14 a, b, c, d uint8
15 x [10]int32
16 }
17
18 func F(p *T, i uintptr) int32 {
19 // load p.x[i] using unsafe, derived from runtime.pcdatastart
20 _ = *p
21 return *(*int32)(add(unsafe.Pointer(&p.d), unsafe.Sizeof(p.d)+i*unsafe.Sizeof(p.x[0])))
22 }
23
24 func add(p unsafe.Pointer, x uintptr) unsafe.Pointer {
25 return unsafe.Pointer(uintptr(p) + x)
26 }