]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile/internal/inline: tweak "returns inlinable func" heuristic
authorThan McIntosh <thanm@google.com>
Fri, 15 Sep 2023 18:46:03 +0000 (14:46 -0400)
committerThan McIntosh <thanm@google.com>
Tue, 7 Nov 2023 21:12:14 +0000 (21:12 +0000)
commitf56c29331951c9d1a48f5b7627f4bb98e7eeb80f
tree55f755d68b18e09f7a5e6592c3eba1d7f91310de
parentff19f8e7636f0b5797f3b65cee69f41fb650b965
cmd/compile/internal/inline: tweak "returns inlinable func" heuristic

The code that analyzes function return values checks for cases where a
function F always returns the same inlinable function, e.g.

  func returnsFunc() func(*int, int) { return setit }
  func setit(p *int, v int) { *p = v }

The check for inlinability was being done by looking at "fn.Inl !=
nil", which is probably not what we want, since it includes functions
whose cost value is between 80 and 160 and may only be inlined if lots
of other heuristics kick in.

This patch changes the "always returns same inlinable func" heuristic
to ensure that the func in question has a size of 80 or less, so as to
restrict this case to functions that have a high likelihood of being
inlined.

Change-Id: I06003bca1c56c401df8fd51c922a59c61aa86bea
Reviewed-on: https://go-review.googlesource.com/c/go/+/529116
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/inline/inlheur/analyze.go
src/cmd/compile/internal/inline/inlheur/analyze_func_returns.go