1// run -race 2 3//go:build cgo && linux && amd64 4 5// Copyright 2021 The Go Authors. All rights reserved. 6// Use of this source code is governed by a BSD-style 7// license that can be found in the LICENSE file. 8 9// Test that CL 281293 doesn't interfere with race detector 10// instrumentation. 11 12package main 13 14import "fmt" 15 16const N = 2e6 17 18type Big = [N]int 19 20var sink interface{} 21 22func main() { 23 g(0, f(0)) 24 25 x1 := f(1) 26 sink = &x1 27 g(1, x1) 28 g(7, f(7)) 29 g(1, x1) 30 31 x3 := f(3) 32 sink = &x3 33 g(1, x1) 34 g(3, x3) 35 36 h(f(0), x1, f(2), x3, f(4)) 37} 38 39//go:noinline 40func f(k int) (x Big) { 41 for i := range x { 42 x[i] = k*N + i 43 } 44 return 45} 46 47//go:noinline 48func g(k int, x Big) { 49 for i := range x { 50 if x[i] != k*N+i { 51 panic(fmt.Sprintf("x%d[%d] = %d", k, i, x[i])) 52 } 53 } 54} 55 56//go:noinline 57func h(x0, x1, x2, x3, x4 Big) { 58 g(0, x0) 59 g(1, x1) 60 g(2, x2) 61 g(3, x3) 62 g(4, x4) 63} 64