aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile
diff options
context:
space:
mode:
authorkhr@golang.org <khr@golang.org>2026-02-20 12:04:35 -0800
committerKeith Randall <khr@golang.org>2026-02-25 16:52:27 -0800
commit0886e65b119e5be88846b1580451dc2b0d6f6fd0 (patch)
treef5ff2ed9124119288daa640bc88e7c3a84e2ded1 /src/cmd/compile
parentb48b2002febf107a04350c43d99e86cba60eba43 (diff)
downloadgo-0886e65b119e5be88846b1580451dc2b0d6f6fd0.tar.xz
cmd/compile: treat all zero-sized values as SSA-able
Might as well, we don't need any registers for such values. Fixes #77635 Change-Id: Iedc1bc3f13662b043b183228bcc1dc4e6c91da81 Reviewed-on: https://go-review.googlesource.com/c/go/+/747780 Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile')
-rw-r--r--src/cmd/compile/internal/ssa/value.go3
-rw-r--r--src/cmd/compile/internal/ssagen/ssa.go20
2 files changed, 21 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/ssa/value.go b/src/cmd/compile/internal/ssa/value.go
index dba73de771..95710d9024 100644
--- a/src/cmd/compile/internal/ssa/value.go
+++ b/src/cmd/compile/internal/ssa/value.go
@@ -616,6 +616,9 @@ func CanSSA(t *types.Type) bool {
if t.IsSIMD() {
return true
}
+ if t.Size() == 0 {
+ return true
+ }
sizeLimit := int64(MaxStruct * types.PtrSize)
if t.Size() > sizeLimit {
// 4*Widthptr is an arbitrary constant. We want it
diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go
index db87d72a4a..5c4826f6d2 100644
--- a/src/cmd/compile/internal/ssagen/ssa.go
+++ b/src/cmd/compile/internal/ssagen/ssa.go
@@ -4529,7 +4529,15 @@ func (s *state) assignWhichMayOverlap(left ir.Node, right *ssa.Value, deref bool
return
}
if n != 1 {
- s.Fatalf("assigning to non-1-length array")
+ // This can happen in weird, always-panics cases, like:
+ // var x [0][2]int
+ // x[i][j] = 5
+ // We know it always panics because the LHS is ssa-able,
+ // and arrays of length > 1 can't be ssa-able unless
+ // they are somewhere inside an outer [0].
+ // We can ignore the actual assignment, it is dynamically
+ // unreachable. See issue 77635.
+ return
}
if t.Size() == 0 {
return
@@ -5223,7 +5231,15 @@ func (s *state) addr(n ir.Node) *ssa.Value {
}
if s.canSSA(n) {
- s.Fatalf("addr of canSSA expression: %+v", n)
+ // This happens in weird, always-panics cases, like:
+ // var x [0][2]int
+ // x[i][j] = 5
+ // The outer assignment, ...[j] = 5, is a fine
+ // assignment to do, but requires computing the address
+ // &x[i], which will always panic when evaluated.
+ // We just return something reasonable in this case.
+ // It will be dynamically unreachable. See issue 77635.
+ return s.newValue1A(ssa.OpAddr, n.Type().PtrTo(), ir.Syms.Zerobase, s.sb)
}
t := types.NewPtr(n.Type())