cmd/compile: method calls for indirect imports not inlined #71598
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
Go version
go version devel go1.24-6d39245514 Thu Oct 31 01:28:37 2024 +0000 linux/arm64
Output of
go env
in your module/workspace:What did you do?
Hello! I found error in inlining. Basically, if module A imports module B. Module B imports module C. Module A can call functions from module C but can't inline them! However, if you directly import module C into A, then inlining succeeds.
Here is a example:
project/
--- go.mod
--- transform.go
--- Descriptor/
--- go.mod
--- descriptor.go
--- DescriptorWrapper/
--- go.mod
--- wrapper.go
descriptor.go
wrapper.go
transform.go
Here we can see that call to NumberKind() wasn't inlined:
However, if we add direct import of "Descriptor":
transform.go
Here call to NumberKind() is inlined!
In this example, in first case (when inlining do not happen) 'bodyReaderFor' from 'unifiedHaveInlineBody' return false and inlining fails (in second case it returns true):
cmd/compile/internal/noder/reader.go
What did you see happen?
Function that can be inlined wasn't inlined.
What did you expect to see?
Inlining of function that can be inlined
The text was updated successfully, but these errors were encountered: