cmd/compile: inlined closure remnants (unnecessarily) set Addrtaken in local variables #65158
Labels
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.22-66d34c7d08
Output of
go env
in your module/workspace:does not depend on platform, only on `GOEXPERIMENT=rangefunc`
What did you do?
Go play link: https://go.dev/play/p/9faujPo3akR?v=gotip
I actually compiled this code
GOSSAFUNC=main GOEXPERIMENT=rangefunc go run main.go
and then examined ssa.html in a browser.What did you see happen?
The two interesting places are the genssa column of ssa.html (the rightmost) and the AST column (2nd from left).
in genssa there are references to
main.#exit1
andmain.i
as a stack variableThe cause for this can be seen in the AST column, where both
i
and#exit1
are marked as Addrtaken, because once-upon-a-time they were locals modified in a closure, but that closure has been inlined and is called nowhere. I understand it cannot quite be completely dead code eliminated because of mentions of the name in debugging information.I poked around the compiler a bit, and believe that the deed is done (
Addrtaken
set) inflowClosure
inescape.go
What did you expect to see?
#exit1
andi
not markedAddrtaken
, allocated to registers, and (in the case of#exit1
) completely removed from the code because it is statically evident that it is not needed.The text was updated successfully, but these errors were encountered: