1 // +build !nacl,!386,!wasm,!arm,!riscv64,!gcflags_noopt
4 // Copyright 2019 The Go Authors. All rights reserved.
5 // Use of this source code is governed by a BSD-style
6 // license that can be found in the LICENSE file.
8 // Test, using compiler diagnostic flags, that inlining of functions
9 // imported from the sync package is working.
10 // Compiles but does not run.
12 // FIXME: This test is disabled on architectures where atomic operations
13 // are function calls rather than intrinsics, since this prevents inlining
14 // of the sync fast paths. This test should be re-enabled once the problem
17 // TODO(jsing): Re-enable on riscv64 when it has atomic intrinsics - see
18 // golang.org/issue/36765
28 func small5() { // ERROR "can inline small5"
29 // the Unlock fast path should be inlined
30 mutex.Unlock() // ERROR "inlining call to sync\.\(\*Mutex\)\.Unlock"
33 func small6() { // ERROR "can inline small6"
34 // the Lock fast path should be inlined
35 mutex.Lock() // ERROR "inlining call to sync\.\(\*Mutex\)\.Lock"
40 func small7() { // ERROR "can inline small7"
41 // the Do fast path should be inlined
42 once.Do(small5) // ERROR "inlining call to sync\.\(\*Once\)\.Do"
45 var rwmutex *sync.RWMutex
47 func small8() { // ERROR "can inline small8"
48 // the RUnlock fast path should be inlined
49 rwmutex.RUnlock() // ERROR "inlining call to sync\.\(\*RWMutex\)\.RUnlock"
52 func small9() { // ERROR "can inline small9"
53 // the RLock fast path should be inlined
54 rwmutex.RLock() // ERROR "inlining call to sync\.\(\*RWMutex\)\.RLock"