cmd/compile: stronger constant propagation around closures #73601
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FeatureRequest
Issues asking for a new feature that does not need a proposal.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
I notice that the use of a local variable to hold a function (e.g. for brevity) doesn't prevent the compiler from treating the variable as an alias for the function, and dispatching calls statically. However, if the variable is referenced from an inner closure, it is treated as a true variable, resulting in a dynamic call:
The closure may be latent, in the case of a range-over-func:
This is another facet of #73524 (comment), where closures defeat constant propagation of outer single-assignment variables.
The text was updated successfully, but these errors were encountered: