3 //go:build !nacl && !386 && !wasm && !arm && !gcflags_noopt
5 // Copyright 2019 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.
9 // Test, using compiler diagnostic flags, that inlining of functions
10 // imported from the sync package is working.
11 // Compiles but does not run.
13 // FIXME: This test is disabled on architectures where atomic operations
14 // are function calls rather than intrinsics, since this prevents inlining
15 // of the sync fast paths. This test should be re-enabled once the problem
26 func small5() { // ERROR "can inline small5"
27 // the Unlock fast path should be inlined
28 mutex.Unlock() // ERROR "inlining call to sync\.\(\*Mutex\)\.Unlock"
31 func small6() { // ERROR "can inline small6"
32 // the Lock fast path should be inlined
33 mutex.Lock() // ERROR "inlining call to sync\.\(\*Mutex\)\.Lock"
38 func small7() { // ERROR "can inline small7"
39 // the Do fast path should be inlined
40 once.Do(small5) // ERROR "inlining call to sync\.\(\*Once\)\.Do" "inlining call to atomic\.\(\*Uint32\)\.Load"
43 var rwmutex *sync.RWMutex
45 func small8() { // ERROR "can inline small8"
46 // the RUnlock fast path should be inlined
47 rwmutex.RUnlock() // ERROR "inlining call to sync\.\(\*RWMutex\)\.RUnlock" "inlining call to atomic\.\(\*Int32\)\.Add"
50 func small9() { // ERROR "can inline small9"
51 // the RLock fast path should be inlined
52 rwmutex.RLock() // ERROR "inlining call to sync\.\(\*RWMutex\)\.RLock" "inlining call to atomic\.\(\*Int32\)\.Add"