cmd/compile: move basic blocks, which return non-nil errors, to the end of assembly output #65068
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
Basic blocks, which return non-nil errors, are usually executed rarely. So it would great from performance perspective to move them to the end of assembly output. This should provide the following benefits:
The following heuristics can be used for determining whether the basic block returns non-nil error:
error
. The function may return multiple results. If at least a single returned result iserror
, then it is good idea to look closer to basic blocks of this function.return
, which returns non-nilerror
. If some globally definederror
is returned, then assume it is non-nil. If some function is called at the place oferror
return result, then assume it returns non-nil error in the following cases:fmt.Errorf()
orerrors.New()
.error
argument. This should cover common idiom:if err != nil { return someErrorWrapper(args, err) }
.I verified these heuristics are missing in Go1.21.
The text was updated successfully, but these errors were encountered: