x/tools/internal/refactor/inline: a read from a non-address-taken variable should commute with global effects #68948
Labels
Analysis
Issues related to static analysis (vet, x/tools/go/analysis)
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Refactoring
Issues related to refactoring tools
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
@lfolger reported a suboptimal inliner result of this form:
In this case, the inliner's effects analysis assumed conservatively that the read from global var g would not commute with the call to complicated(). However, the variable g is not address-taken and is assigned only in its declaration.
The inliner's effects analysis should enumerate all non-address-taken variables (non-exported variables that appear in an lvalue position only in their own declaration) and allow reads of them to commute with global effects such as complicated(), resulting in this more optimal inlining:
f2(g, complicated())
.The text was updated successfully, but these errors were encountered: