aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/inline
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-01-22 14:32:06 -0800
committerDan Scales <danscales@google.com>2021-01-23 00:30:58 +0000
commit51e1819a8d2ecb6ed292ca363cbb8edfea4aea65 (patch)
tree3880b4fdd77a5c68f953cd560de4d820c98933e1 /src/cmd/compile/internal/inline
parent7e0a81d2806b073c6455f73b10fbf2c811703f46 (diff)
downloadgo-51e1819a8d2ecb6ed292ca363cbb8edfea4aea65.tar.gz
go-51e1819a8d2ecb6ed292ca363cbb8edfea4aea65.zip
[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>
Diffstat (limited to 'src/cmd/compile/internal/inline')
-rw-r--r--src/cmd/compile/internal/inline/inl.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go
index 83f6740a48..9f9bb87dd5 100644
--- a/src/cmd/compile/internal/inline/inl.go
+++ b/src/cmd/compile/internal/inline/inl.go
@@ -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,