aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2022-06-20 17:06:09 -0700
committerHeschi Kreinick <heschi@google.com>2022-07-06 19:33:22 +0000
commiteeef5ebd84d0d16d49e48640001b8367607350ba (patch)
treee276eb1239988893041f5046a58eb03f4b691ac3
parent460a93b54af4a0305f6007e44e41e6160a6469d8 (diff)
downloadgo-eeef5ebd84d0d16d49e48640001b8367607350ba.tar.gz
go-eeef5ebd84d0d16d49e48640001b8367607350ba.zip
[release-branch.go1.18] cmd/compile: allow 128-bit values to be spilled
We sometimes use 16-byte load+store to move values around in memory. In rare circumstances, the loaded value must be spilled because the store can't happen yet. In that case, we need to be able to spill the 16-byte value. Fixes #53471 Change-Id: I09fd08e11a63c6ba3ef781d3f5ede237e9b0132e Reviewed-on: https://go-review.googlesource.com/c/go/+/413294 Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> (cherry picked from commit c2d373d5d1802d7479f3c81dcf01d41bef3646dd) Reviewed-on: https://go-review.googlesource.com/c/go/+/413455 Reviewed-by: Alex Rakoczy <jenny@golang.org>
-rw-r--r--src/cmd/compile/internal/amd64/ssa.go2
-rw-r--r--src/cmd/compile/internal/dwarfgen/dwarf.go5
-rw-r--r--src/cmd/compile/internal/types/size.go6
-rw-r--r--src/cmd/compile/internal/types/type.go5
-rw-r--r--test/fixedbugs/issue53454.go89
5 files changed, 107 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/amd64/ssa.go b/src/cmd/compile/internal/amd64/ssa.go
index b0e5c34030..b5db283e87 100644
--- a/src/cmd/compile/internal/amd64/ssa.go
+++ b/src/cmd/compile/internal/amd64/ssa.go
@@ -78,6 +78,8 @@ func storeByType(t *types.Type) obj.As {
return x86.AMOVL
case 8:
return x86.AMOVQ
+ case 16:
+ return x86.AMOVUPS
}
}
panic(fmt.Sprintf("bad store type %v", t))
diff --git a/src/cmd/compile/internal/dwarfgen/dwarf.go b/src/cmd/compile/internal/dwarfgen/dwarf.go
index e249a52e57..8ae03d70e6 100644
--- a/src/cmd/compile/internal/dwarfgen/dwarf.go
+++ b/src/cmd/compile/internal/dwarfgen/dwarf.go
@@ -91,6 +91,11 @@ func Info(fnsym *obj.LSym, infosym *obj.LSym, curfn interface{}) ([]dwarf.Scope,
continue
}
apdecls = append(apdecls, n)
+ if n.Type().Kind() == types.TSSA {
+ // Can happen for TypeInt128 types. This only happens for
+ // spill locations, so not a huge deal.
+ continue
+ }
fnsym.Func().RecordAutoType(reflectdata.TypeLinksym(n.Type()))
}
}
diff --git a/src/cmd/compile/internal/types/size.go b/src/cmd/compile/internal/types/size.go
index fb6accdc64..0c3fa922f8 100644
--- a/src/cmd/compile/internal/types/size.go
+++ b/src/cmd/compile/internal/types/size.go
@@ -696,6 +696,12 @@ func PtrDataSize(t *Type) int64 {
}
return 0
+ case TSSA:
+ if t != TypeInt128 {
+ base.Fatalf("PtrDataSize: unexpected ssa type %v", t)
+ }
+ return 0
+
default:
base.Fatalf("PtrDataSize: unexpected type, %v", t)
return 0
diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go
index bfcb8d215e..1021bd94a0 100644
--- a/src/cmd/compile/internal/types/type.go
+++ b/src/cmd/compile/internal/types/type.go
@@ -1721,6 +1721,11 @@ var (
TypeResultMem = newResults([]*Type{TypeMem})
)
+func init() {
+ TypeInt128.width = 16
+ TypeInt128.align = 8
+}
+
// NewNamed returns a new named type for the given type name. obj should be an
// ir.Name. The new type is incomplete (marked as TFORW kind), and the underlying
// type should be set later via SetUnderlying(). References to the type are
diff --git a/test/fixedbugs/issue53454.go b/test/fixedbugs/issue53454.go
new file mode 100644
index 0000000000..8b16d81839
--- /dev/null
+++ b/test/fixedbugs/issue53454.go
@@ -0,0 +1,89 @@
+// compile
+
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+type T1 struct {
+ A T5
+ B T2
+ C T7
+ D T4
+}
+
+type T2 struct {
+ T3
+ A float64
+ E float64
+ C float64
+}
+
+type T3 struct {
+ F float64
+ G float64
+ H float64
+ I float64
+ J float64
+ K float64
+ L float64
+}
+
+type T4 struct {
+ M float64
+ N float64
+ O float64
+ P float64
+}
+
+type T5 struct {
+ Q float64
+ R float64
+ S float64
+ T float64
+ U float64
+ V float64
+}
+
+type T6 struct {
+ T9
+ C T10
+}
+
+type T7 struct {
+ T10
+ T11
+}
+
+type T8 struct {
+ T9
+ C T7
+}
+
+type T9 struct {
+ A T5
+ B T3
+ D T4
+}
+
+type T10 struct {
+ W float64
+}
+
+type T11 struct {
+ X float64
+ Y float64
+}
+
+func MainTest(x T1, y T8, z T6) float64 {
+ return Test(x.B, x.A, x.D, x.C, y.B, y.A, y.D, y.C, z.B, z.A, z.D,
+ T7{
+ T10: T10{
+ W: z.C.W,
+ },
+ T11: T11{},
+ },
+ )
+}
+func Test(a T2, b T5, c T4, d T7, e T3, f T5, g T4, h T7, i T3, j T5, k T4, l T7) float64