cmd/compile: inline devirtualized functions if they are inlineable #60032
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
What version of Go are you using (go version)?
go version devel go1.21-3e35df5edb Fri May 5 23:33:02 2023 +0000 windows/amd64
What did you do?
I wrote a function that takes an interface and calls a method on it. I knew that it would be devirtualized and call
MyStruct.Do
directly, however I also expected the call toMyStruct.Do
to also be inlined if it's inlineable after the fact. But due to inlining happening before devirtualization, that doesn't happen.So, I'm proposing that after we devirtualize interface method calls that we also see at that point in time if the devirtualized method can be inlined.
What did you expect to see?
When running
go build && go tool objdump test.exe > test.sout
on the code above, I expected something more like this, where the there would be noCALL
toMyStruct.Do
What did you see instead?
When running
go build && go tool objdump test.exe > test.sout
, I instead see the following.Proposed solution
I can formerly put the following into a PR/CL but the gist of what I propose is:
Func.Inl
set.I'm not sure if this particular solution is viable however as I haven't benchmarked anything as of yet but this at least proves it can be done.
The following changes to
src\cmd\compile\internal\devirtualize\devirtualize.go
are how I got the assembly output for the "What did you expect to see" section above.The text was updated successfully, but these errors were encountered: