cmd/compile: handle OCLOSURE/OCALLPART in mustHeapAlloc check

Currently, generated struct wrapper for closure is not handled in
mustHeapAlloc. That causes compiler crashes when the wrapper struct
is too large for stack, and must be heap allocated instead.

Fixes #39292

Change-Id: I14c1e591681d9d92317bb2396d6cf5207aa93e08
Reviewed-on: https://go-review.googlesource.com/c/go/+/244917
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Cuong Manh Le 2020-07-27 12:08:56 +07:00
parent 0031fa80a3
commit 82c45eb681
3 changed files with 37 additions and 1 deletions

View file

@ -187,6 +187,13 @@ func mustHeapAlloc(n *Node) bool {
return true
}
if n.Op == OCLOSURE && closureType(n).Size() >= maxImplicitStackVarSize {
return true
}
if n.Op == OCALLPART && partialCallType(n).Size() >= maxImplicitStackVarSize {
return true
}
if n.Op == OMAKESLICE && !isSmallMakeSlice(n) {
return true
}