mirror of
https://github.com/golang/go
synced 2024-11-22 14:15:05 -07:00
cmd/compile: output cost while inlining function with Debug['m'] > 1
The existing implementation outputs inline cost iff function cannot be inlined with Debug['m'] > 1, the cost info is also useful if the function is inlineable. Fixes #36780 Change-Id: Ic96f6baf96aee25fb4b33d31d4d644dc2310e536 Reviewed-on: https://go-review.googlesource.com/c/go/+/216778 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
parent
26aadfa044
commit
ee46f135a9
@ -225,7 +225,7 @@ func caninl(fn *Node) {
|
||||
fn.Type.FuncType().Nname = asTypesNode(n)
|
||||
|
||||
if Debug['m'] > 1 {
|
||||
fmt.Printf("%v: can inline %#v as: %#v { %#v }\n", fn.Line(), n, fn.Type, asNodes(n.Func.Inl.Body))
|
||||
fmt.Printf("%v: can inline %#v with cost %d as: %#v { %#v }\n", fn.Line(), n, inlineMaxBudget-visitor.budget, fn.Type, asNodes(n.Func.Inl.Body))
|
||||
} else if Debug['m'] != 0 {
|
||||
fmt.Printf("%v: can inline %v\n", fn.Line(), n)
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ func Foo(x int) int { // ERROR "cannot inline Foo: marked go:norace with -race c
|
||||
return x * (x + 1) * (x + 2)
|
||||
}
|
||||
|
||||
func Bar(x int) int { // ERROR "can inline Bar as: func\(int\) int { return x \* \(x \+ 1\) \* \(x \+ 2\) }$"
|
||||
func Bar(x int) int { // ERROR "can inline Bar with cost .* as: func\(int\) int { return x \* \(x \+ 1\) \* \(x \+ 2\) }$"
|
||||
return x * (x + 1) * (x + 2)
|
||||
}
|
||||
|
||||
|
@ -7,11 +7,11 @@
|
||||
package main
|
||||
|
||||
//go:norace
|
||||
func Foo(x int) int { // ERROR "can inline Foo as: func\(int\) int { return x \* \(x \+ 1\) \* \(x \+ 2\) }$"
|
||||
func Foo(x int) int { // ERROR "can inline Foo with cost .* as: func\(int\) int { return x \* \(x \+ 1\) \* \(x \+ 2\) }$"
|
||||
return x * (x + 1) * (x + 2)
|
||||
}
|
||||
|
||||
func Bar(x int) int { // ERROR "can inline Bar as: func\(int\) int { return x \* \(x \+ 1\) \* \(x \+ 2\) }$"
|
||||
func Bar(x int) int { // ERROR "can inline Bar with cost .* as: func\(int\) int { return x \* \(x \+ 1\) \* \(x \+ 2\) }$"
|
||||
return x * (x + 1) * (x + 2)
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,12 @@
|
||||
|
||||
package foo
|
||||
|
||||
func small(a []int) int { // ERROR "can inline small as:.*" "a does not escape"
|
||||
func small(a []int) int { // ERROR "can inline small with cost .* as:.*" "a does not escape"
|
||||
// Cost 16 body (need cost < 20).
|
||||
// See cmd/compile/internal/gc/inl.go:inlineBigFunction*
|
||||
return a[0] + a[1] + a[2] + a[3]
|
||||
}
|
||||
func medium(a []int) int { // ERROR "can inline medium as:.*" "a does not escape"
|
||||
func medium(a []int) int { // ERROR "can inline medium with cost .* as:.*" "a does not escape"
|
||||
// Cost 32 body (need cost > 20 and cost < 80).
|
||||
// See cmd/compile/internal/gc/inl.go:inlineBigFunction*
|
||||
return a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7]
|
||||
|
Loading…
Reference in New Issue
Block a user