summaryrefslogtreecommitdiffstats
path: root/test/inline_sync.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 13:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 13:18:25 +0000
commit109be507377fe7f6e8819ac94041d3fdcdf6fd2f (patch)
tree2806a689f8fab4a2ec9fc949830ef270a91d667d /test/inline_sync.go
parentInitial commit. (diff)
downloadgolang-1.19-109be507377fe7f6e8819ac94041d3fdcdf6fd2f.tar.xz
golang-1.19-109be507377fe7f6e8819ac94041d3fdcdf6fd2f.zip
Adding upstream version 1.19.8.upstream/1.19.8upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/inline_sync.go')
-rw-r--r--test/inline_sync.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/inline_sync.go b/test/inline_sync.go
new file mode 100644
index 0000000..30b436a
--- /dev/null
+++ b/test/inline_sync.go
@@ -0,0 +1,53 @@
+// +build !nacl,!386,!wasm,!arm,!gcflags_noopt
+// errorcheck -0 -m
+
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test, using compiler diagnostic flags, that inlining of functions
+// imported from the sync package is working.
+// Compiles but does not run.
+
+// FIXME: This test is disabled on architectures where atomic operations
+// are function calls rather than intrinsics, since this prevents inlining
+// of the sync fast paths. This test should be re-enabled once the problem
+// is solved.
+
+package foo
+
+import (
+ "sync"
+)
+
+var mutex *sync.Mutex
+
+func small5() { // ERROR "can inline small5"
+ // the Unlock fast path should be inlined
+ mutex.Unlock() // ERROR "inlining call to sync\.\(\*Mutex\)\.Unlock"
+}
+
+func small6() { // ERROR "can inline small6"
+ // the Lock fast path should be inlined
+ mutex.Lock() // ERROR "inlining call to sync\.\(\*Mutex\)\.Lock"
+}
+
+var once *sync.Once
+
+func small7() { // ERROR "can inline small7"
+ // the Do fast path should be inlined
+ once.Do(small5) // ERROR "inlining call to sync\.\(\*Once\)\.Do"
+}
+
+var rwmutex *sync.RWMutex
+
+func small8() { // ERROR "can inline small8"
+ // the RUnlock fast path should be inlined
+ rwmutex.RUnlock() // ERROR "inlining call to sync\.\(\*RWMutex\)\.RUnlock"
+}
+
+func small9() { // ERROR "can inline small9"
+ // the RLock fast path should be inlined
+ rwmutex.RLock() // ERROR "inlining call to sync\.\(\*RWMutex\)\.RLock"
+}
+