You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes
What did you do?
I write the following code:
package main
import"encoding/binary"funcmain() {
}
funcA(b []byte) uint64 {
returnbinary.LittleEndian.Uint64(b)
}
// Copy-paste of binary.LittleEndian.Uint64funcUint64(b []byte) uint64 {
_=b[7] // bounds check hint to compiler; see golang.org/issue/14808returnuint64(b[0]) |uint64(b[1])<<8|uint64(b[2])<<16|uint64(b[3])<<24|uint64(b[4])<<32|uint64(b[5])<<40|uint64(b[6])<<48|uint64(b[7])<<56
}
funcB(b []byte) uint64 {
returnUint64(b)
}
Then I run the command go build -gcflags -m=2 . and I see:
can inline A with cost 5 as: func([]byte) uint64 { return binary.littleEndian.Uint64(binary.LittleEndian, b) }
inlining call to binary.littleEndian.Uint64
can inline B with cost 63 as: func([]byte) uint64 { return Uint64(b) }
inlining call to Uint64
So A calls Uint64 from another module and B calls Uint64 from the same module, and A and B have different costs.
What did you expect to see?
I expected to see the same cost no matter where the called function is located.
The text was updated successfully, but these errors were encountered:
subtle-byte
changed the title
cmd/compile: zero inline-cost of function from another module
cmd/compile: low inline cost of function from another module
Aug 12, 2022
subtle-byte
changed the title
cmd/compile: low inline cost of function from another module
cmd/compile: low function inline cost
Aug 12, 2022
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
I write the following code:
Then I run the command
go build -gcflags -m=2 .
and I see:So
A
callsUint64
from another module andB
callsUint64
from the same module, andA
andB
have different costs.What did you expect to see?
I expected to see the same cost no matter where the called function is located.
The text was updated successfully, but these errors were encountered: