3 // Copyright 2018 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Test that we restrict inlining into very large functions.
12 func small(a []int) int { // ERROR "can inline small with cost .* as:.*" "a does not escape"
13 // Cost 16 body (need cost < 20).
14 // See cmd/compile/internal/gc/inl.go:inlineBigFunction*
15 return a[0] + a[1] + a[2] + a[3]
17 func medium(a []int) int { // ERROR "can inline medium with cost .* as:.*" "a does not escape"
18 // Cost 32 body (need cost > 20 and cost < 80).
19 // See cmd/compile/internal/gc/inl.go:inlineBigFunction*
20 return a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7]
23 func f(a []int) int { // ERROR "cannot inline f:.*" "a does not escape" "function f considered 'big'"
24 // Add lots of nodes to f's body. We need >5000.
25 // See cmd/compile/internal/gc/inl.go:inlineBigFunction*
1026 x := small(a) // ERROR "inlining call to small"
1027 y := medium(a) // The crux of this test: medium is not inlined.