Skip to content

Commit c2d373d

Browse files
committed
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 #53454 Change-Id: I09fd08e11a63c6ba3ef781d3f5ede237e9b0132e Reviewed-on: https://go-review.googlesource.com/c/go/+/413294 Reviewed-by: Keith Randall <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: David Chase <[email protected]> Run-TryBot: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 19ed442 commit c2d373d

5 files changed

Lines changed: 107 additions & 0 deletions

File tree

src/cmd/compile/internal/amd64/ssa.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ func storeByType(t *types.Type) obj.As {
7878
return x86.AMOVL
7979
case 8:
8080
return x86.AMOVQ
81+
case 16:
82+
return x86.AMOVUPS
8183
}
8284
}
8385
panic(fmt.Sprintf("bad store type %v", t))

src/cmd/compile/internal/dwarfgen/dwarf.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ func Info(fnsym *obj.LSym, infosym *obj.LSym, curfn interface{}) ([]dwarf.Scope,
9191
continue
9292
}
9393
apdecls = append(apdecls, n)
94+
if n.Type().Kind() == types.TSSA {
95+
// Can happen for TypeInt128 types. This only happens for
96+
// spill locations, so not a huge deal.
97+
continue
98+
}
9499
fnsym.Func().RecordAutoType(reflectdata.TypeLinksym(n.Type()))
95100
}
96101
}

src/cmd/compile/internal/types/size.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,12 @@ func PtrDataSize(t *Type) int64 {
590590
}
591591
return 0
592592

593+
case TSSA:
594+
if t != TypeInt128 {
595+
base.Fatalf("PtrDataSize: unexpected ssa type %v", t)
596+
}
597+
return 0
598+
593599
default:
594600
base.Fatalf("PtrDataSize: unexpected type, %v", t)
595601
return 0

src/cmd/compile/internal/types/type.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,11 @@ var (
17051705
TypeResultMem = newResults([]*Type{TypeMem})
17061706
)
17071707

1708+
func init() {
1709+
TypeInt128.width = 16
1710+
TypeInt128.align = 8
1711+
}
1712+
17081713
// NewNamed returns a new named type for the given type name. obj should be an
17091714
// ir.Name. The new type is incomplete (marked as TFORW kind), and the underlying
17101715
// type should be set later via SetUnderlying(). References to the type are

test/fixedbugs/issue53454.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// compile
2+
3+
// Copyright 2022 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package main
8+
9+
type T1 struct {
10+
A T5
11+
B T2
12+
C T7
13+
D T4
14+
}
15+
16+
type T2 struct {
17+
T3
18+
A float64
19+
E float64
20+
C float64
21+
}
22+
23+
type T3 struct {
24+
F float64
25+
G float64
26+
H float64
27+
I float64
28+
J float64
29+
K float64
30+
L float64
31+
}
32+
33+
type T4 struct {
34+
M float64
35+
N float64
36+
O float64
37+
P float64
38+
}
39+
40+
type T5 struct {
41+
Q float64
42+
R float64
43+
S float64
44+
T float64
45+
U float64
46+
V float64
47+
}
48+
49+
type T6 struct {
50+
T9
51+
C T10
52+
}
53+
54+
type T7 struct {
55+
T10
56+
T11
57+
}
58+
59+
type T8 struct {
60+
T9
61+
C T7
62+
}
63+
64+
type T9 struct {
65+
A T5
66+
B T3
67+
D T4
68+
}
69+
70+
type T10 struct {
71+
W float64
72+
}
73+
74+
type T11 struct {
75+
X float64
76+
Y float64
77+
}
78+
79+
func MainTest(x T1, y T8, z T6) float64 {
80+
return Test(x.B, x.A, x.D, x.C, y.B, y.A, y.D, y.C, z.B, z.A, z.D,
81+
T7{
82+
T10: T10{
83+
W: z.C.W,
84+
},
85+
T11: T11{},
86+
},
87+
)
88+
}
89+
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

0 commit comments

Comments
 (0)