]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: reorder operations in SCCs to enable more inlining
authorThan McIntosh <thanm@google.com>
Thu, 9 Mar 2023 14:59:26 +0000 (09:59 -0500)
committerThan McIntosh <thanm@google.com>
Thu, 9 Mar 2023 22:13:26 +0000 (22:13 +0000)
commitf5c7416511de979433a500735c1617cf03dc46c2
tree5723402513474397c8a27257a54bab9c9f1ac4a1
parentc9389a5849d65b74287cd2746a94748d6d64cb44
cmd/compile: reorder operations in SCCs to enable more inlining

This patch changes the relative order of "CanInline" and "InlineCalls"
operations within the inliner for clumps of functions corresponding to
strongly connected components in the call graph. This helps increase
the amount of inlining within SCCs, particularly in Go's runtime
package, which has a couple of very large SCCs.

For a given SCC of the form { fn1, fn2, ... fnk }, the inliner would
(prior to this point) walk through the list of functions and for each
function first compute inlinability ("CanInline") and then perform
inlining ("InlineCalls"). This meant that if there was an inlinable
call from fn3 to fn4 (for example), this call would never be inlined,
since at the point fn3 was visited, we would not have computed
inlinability for fn4.

We now do inlinability analysis for all functions in an SCC first,
then do actual inlining for everything. This results in 47 additional
inlines in the Go runtime package (a fairly modest increase
percentage-wise of 0.6%).

Updates #58905.

Change-Id: I48dbb1ca16f0b12f256d9eeba8cf7f3e6dd853cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/474955
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/compile/internal/base/debug.go
src/cmd/compile/internal/inline/inl.go
test/inline.go