Skip to content

Commit b61b1d2

Browse files
committed
test/codegen: port structs test to codegen
And delete them from asm_test. Change-Id: Ia286239a3d8f3915f2ca25dbcb39f3354a4f8aea Reviewed-on: https://go-review.googlesource.com/101138 Run-TryBot: Alberto Donizetti <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent cc155eb commit b61b1d2

File tree

2 files changed

+46
-37
lines changed

2 files changed

+46
-37
lines changed

src/cmd/compile/internal/gc/asm_test.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -279,43 +279,6 @@ var linuxAMD64Tests = []*asmTest{
279279
`,
280280
pos: []string{"\tSHLQ\t\\$5,", "\tLEAQ\t\\(.*\\)\\(.*\\*2\\),"},
281281
},
282-
// Structure zeroing. See issue #18370.
283-
{
284-
fn: `
285-
type T1 struct {
286-
a, b, c int
287-
}
288-
func $(t *T1) {
289-
*t = T1{}
290-
}
291-
`,
292-
pos: []string{"\tXORPS\tX., X", "\tMOVUPS\tX., \\(.*\\)", "\tMOVQ\t\\$0, 16\\(.*\\)"},
293-
},
294-
// SSA-able composite literal initialization. Issue 18872.
295-
{
296-
fn: `
297-
type T18872 struct {
298-
a, b, c, d int
299-
}
300-
301-
func f18872(p *T18872) {
302-
*p = T18872{1, 2, 3, 4}
303-
}
304-
`,
305-
pos: []string{"\tMOVQ\t[$]1", "\tMOVQ\t[$]2", "\tMOVQ\t[$]3", "\tMOVQ\t[$]4"},
306-
},
307-
// Also test struct containing pointers (this was special because of write barriers).
308-
{
309-
fn: `
310-
type T2 struct {
311-
a, b, c *int
312-
}
313-
func f19(t *T2) {
314-
*t = T2{}
315-
}
316-
`,
317-
pos: []string{"\tXORPS\tX., X", "\tMOVUPS\tX., \\(.*\\)", "\tMOVQ\t\\$0, 16\\(.*\\)", "\tCALL\truntime\\.gcWriteBarrier\\(SB\\)"},
318-
},
319282
{
320283
fn: `
321284
func f33(m map[int]int) int {

test/codegen/structs.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// asmcheck
2+
3+
// Copyright 2018 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 codegen
8+
9+
// This file contains code generation tests related to the handling of
10+
// struct types.
11+
12+
// ------------- //
13+
// Zeroing //
14+
// ------------- //
15+
16+
type Z1 struct {
17+
a, b, c int
18+
}
19+
20+
func Zero1(t *Z1) { // Issue #18370
21+
// amd64:`XORPS\tX., X`,`MOVUPS\tX., \(.*\)`,`MOVQ\t\$0, 16\(.*\)`
22+
*t = Z1{}
23+
}
24+
25+
type Z2 struct {
26+
a, b, c *int
27+
}
28+
29+
func Zero2(t *Z2) {
30+
// amd64:`XORPS\tX., X`,`MOVUPS\tX., \(.*\)`,`MOVQ\t\$0, 16\(.*\)`
31+
// amd64:`.*runtime[.]gcWriteBarrier\(SB\)`
32+
*t = Z2{}
33+
}
34+
35+
// ------------------ //
36+
// Initializing //
37+
// ------------------ //
38+
39+
type I1 struct {
40+
a, b, c, d int
41+
}
42+
43+
func Init1(p *I1) { // Issue #18872
44+
// amd64:`MOVQ\t[$]1`,`MOVQ\t[$]2`,`MOVQ\t[$]3`,`MOVQ\t[$]4`
45+
*p = I1{1, 2, 3, 4}
46+
}

0 commit comments

Comments
 (0)