1
0
mirror of https://github.com/golang/go synced 2024-11-11 20:01:37 -07:00

[dev.regabi] cmd/compile: scan body of closure in tooHairy to check for disallowed nodes

Several of the bugs in #43818 are because we were not scanning the body
of an possibly inlined closure in tooHairy(). I think this scanning got
lost in the rebase past some of the ir changes. This fixes the issue
related to the SELRECV2 and the bug reported from cuonglm. There is at
least one other bug related to escape analysis which I'll fix in another
change.

Change-Id: I8f38cd12a287881155403bbabbc540ed5fc2248e
Reviewed-on: https://go-review.googlesource.com/c/go/+/285676
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Dan Scales 2021-01-22 14:32:06 -08:00
parent 7e0a81d280
commit 51e1819a8d

View File

@ -354,10 +354,16 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
return true
case ir.OCLOSURE:
// TODO(danscales) - fix some bugs when budget is lowered below 30
// TODO(danscales) - fix some bugs when budget is lowered below 15
// Maybe make budget proportional to number of closure variables, e.g.:
//v.budget -= int32(len(n.(*ir.ClosureExpr).Func.ClosureVars) * 3)
v.budget -= 30
v.budget -= 15
// Scan body of closure (which DoChildren doesn't automatically
// do) to check for disallowed ops in the body and include the
// body in the budget.
if doList(n.(*ir.ClosureExpr).Func.Body, v.do) {
return true
}
case ir.ORANGE,
ir.OSELECT,