github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/compile/inline/inlheur/testdata/dumpscores.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package dumpscores 6 7 var G int 8 9 func inlinable(x int, f func(int) int) int { 10 if x != 0 { 11 return 1 12 } 13 G += noninl(x) 14 return f(x) 15 } 16 17 func inlinable2(x int) int { 18 return noninl(-x) 19 } 20 21 //go:noinline 22 func noninl(x int) int { 23 return x + 1 24 } 25 26 func tooLargeToInline(x int) int { 27 if x > 101 { 28 // Drive up the cost of inlining this func over the 29 // regular threshold. 30 return big(big(big(big(big(G + x))))) 31 } 32 if x < 100 { 33 // make sure this callsite is scored properly 34 G += inlinable(101, inlinable2) 35 if G == 101 { 36 return 0 37 } 38 panic(inlinable2(3)) 39 } 40 return G 41 } 42 43 func big(q int) int { 44 return noninl(q) + noninl(-q) 45 }