-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Description
Go version
go version go1.24.1 linux/amd64
Output of go env in your module/workspace:
-What did you do?
package pkg
func Foo(arg int) {
var x [4]int
var fp func(*[4]int)
if arg == 1 {
fp = bar1
} else {
fp = bar2
}
fp(&x)
}
//go:noinline
func bar1(_ *[4]int) {}
//go:noinline
func bar2(_ *[4]int) {}
What did you see happen?
x gets allocated on the heap because the compiler cannot tell that the call to fp doesn't cause the argument to escape.
What did you expect to see?
All possible values of fp are statically known and known not to cause the argument to escape. I would expect the escape information for bar1 and bar2 to be merged and maintained with fp.
This comes up when providing multiple assembly implementations of a function for the same overall CPU architecture, for example both SSE and AVX ones. The implementation has to be chosen dynamically and I would like to pull that out of any loops, hence the function pointer.
adonovan, mateusz834, thediveo, tmthrgd and Ahmedkhairy0106
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
Status
Todo