Skip to content

Commit eb437ba

Browse files
TapirLiurandall77
authored andcommitted
cmd/compile: make stack value size threshold comparisons consistent
Consistency is beautiful. Change-Id: Ib110dcff0ce2fa87b5576c79cd79c83aab385a7c GitHub-Last-Rev: b8758f8 GitHub-Pull-Request: #47011 Reviewed-on: https://go-review.googlesource.com/c/go/+/332230 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
1 parent 9d65578 commit eb437ba

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/cmd/compile/internal/escape/escape.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,14 +2013,14 @@ func HeapAllocReason(n ir.Node) string {
20132013
return "too large for stack"
20142014
}
20152015

2016-
if (n.Op() == ir.ONEW || n.Op() == ir.OPTRLIT) && n.Type().Elem().Width >= ir.MaxImplicitStackVarSize {
2016+
if (n.Op() == ir.ONEW || n.Op() == ir.OPTRLIT) && n.Type().Elem().Width > ir.MaxImplicitStackVarSize {
20172017
return "too large for stack"
20182018
}
20192019

2020-
if n.Op() == ir.OCLOSURE && typecheck.ClosureType(n.(*ir.ClosureExpr)).Size() >= ir.MaxImplicitStackVarSize {
2020+
if n.Op() == ir.OCLOSURE && typecheck.ClosureType(n.(*ir.ClosureExpr)).Size() > ir.MaxImplicitStackVarSize {
20212021
return "too large for stack"
20222022
}
2023-
if n.Op() == ir.OCALLPART && typecheck.PartialCallType(n.(*ir.SelectorExpr)).Size() >= ir.MaxImplicitStackVarSize {
2023+
if n.Op() == ir.OCALLPART && typecheck.PartialCallType(n.(*ir.SelectorExpr)).Size() > ir.MaxImplicitStackVarSize {
20242024
return "too large for stack"
20252025
}
20262026

@@ -2033,7 +2033,7 @@ func HeapAllocReason(n ir.Node) string {
20332033
if !ir.IsSmallIntConst(r) {
20342034
return "non-constant size"
20352035
}
2036-
if t := n.Type(); t.Elem().Width != 0 && ir.Int64Val(r) >= ir.MaxImplicitStackVarSize/t.Elem().Width {
2036+
if t := n.Type(); t.Elem().Width != 0 && ir.Int64Val(r) > ir.MaxImplicitStackVarSize/t.Elem().Width {
20372037
return "too large for stack"
20382038
}
20392039
}

src/cmd/compile/internal/walk/builtin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ func walkNew(n *ir.UnaryExpr, init *ir.Nodes) ir.Node {
489489
base.Errorf("%v can't be allocated in Go; it is incomplete (or unallocatable)", n.Type().Elem())
490490
}
491491
if n.Esc() == ir.EscNone {
492-
if t.Size() >= ir.MaxImplicitStackVarSize {
492+
if t.Size() > ir.MaxImplicitStackVarSize {
493493
base.Fatalf("large ONEW with EscNone: %v", n)
494494
}
495495
return stackTempAddr(init, t)

0 commit comments

Comments
 (0)