2019-03-05 10:21:08 -07:00
|
|
|
// +build !nacl,!386,!wasm,!arm,!gcflags_noopt
|
2018-11-09 16:28:44 -07:00
|
|
|
// 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.
|
2018-11-09 06:49:38 -07:00
|
|
|
|
|
|
|
// 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.
|
2018-11-09 16:28:44 -07:00
|
|
|
|
|
|
|
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" "&sync\.m\.state escapes to heap"
|
|
|
|
}
|
2018-11-09 06:49:38 -07:00
|
|
|
|
|
|
|
func small6() { // ERROR "can inline small6"
|
|
|
|
// the Lock fast path should be inlined
|
|
|
|
mutex.Lock() // ERROR "inlining call to sync\.\(\*Mutex\)\.Lock" "&sync\.m\.state escapes to heap"
|
|
|
|
}
|
2018-11-12 23:34:22 -07:00
|
|
|
|
|
|
|
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" "&sync\.o\.done escapes to heap"
|
|
|
|
}
|