aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2023-01-03 12:11:44 -0800
committerMatthew Dempsky <mdempsky@google.com>2023-01-26 23:27:24 +0000
commit6f6276ce366f0f9cd9748d9c910310e0bc7dc8e5 (patch)
tree934d69c784677969b42a59d08e1f3f914fd9b9a5 /src
parenta0bebffa339efc92af3a51781d910ef79b830482 (diff)
downloadgo-6f6276ce366f0f9cd9748d9c910310e0bc7dc8e5.tar.xz
cmd/compile/internal/inline: adjust isBigFunc to recognize unified IR codegen
Unified IR generates uniform IR for "a, b = f()" to be able to insert implicit conversion expressions, but the result is somewhat more verbose and trips up the inliner's naive cost metrics. The hairyVisitor.doNode method was already adjusted to account for this, but isBigFunc needs the same adjustment. Fixes #57563. Change-Id: Ia8d86a6e314ec60190c78f40ace4fb30dadc4413 Reviewed-on: https://go-review.googlesource.com/c/go/+/460395 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/inline/inl.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go
index 11a64fde0c..99cbda8e9c 100644
--- a/src/cmd/compile/internal/inline/inl.go
+++ b/src/cmd/compile/internal/inline/inl.go
@@ -643,6 +643,8 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
// minimize impact to the existing inlining heuristics (in
// particular, to avoid breaking the existing inlinability regress
// tests), we need to compensate for this here.
+ //
+ // See also identical logic in isBigFunc.
if init := n.Rhs[0].Init(); len(init) == 1 {
if _, ok := init[0].(*ir.AssignListStmt); ok {
// 4 for each value, because each temporary variable now
@@ -684,6 +686,16 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
func isBigFunc(fn *ir.Func) bool {
budget := inlineBigFunctionNodes
return ir.Any(fn, func(n ir.Node) bool {
+ // See logic in hairyVisitor.doNode, explaining unified IR's
+ // handling of "a, b = f()" assignments.
+ if n, ok := n.(*ir.AssignListStmt); ok && n.Op() == ir.OAS2 {
+ if init := n.Rhs[0].Init(); len(init) == 1 {
+ if _, ok := init[0].(*ir.AssignListStmt); ok {
+ budget += 4*len(n.Lhs) + 1
+ }
+ }
+ }
+
budget--
return budget <= 0
})