aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/func_test.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2017-03-18 22:00:28 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2017-03-19 05:37:39 +0000
commita68e5d94fad421e64d471dae1c5ee0b95b933242 (patch)
treed1718f76809e68d4021b5dfb9f6e0922521ffe78 /src/cmd/compile/internal/ssa/func_test.go
parent62947bedd28a884b46f5df71070a9e86dad17081 (diff)
downloadgo-a68e5d94fad421e64d471dae1c5ee0b95b933242.tar.gz
go-a68e5d94fad421e64d471dae1c5ee0b95b933242.zip
cmd/compile: clean up SSA test API
I noted in CL 38327 that the SSA test API felt a bit clunky after the ssa.Func/ssa.Cache/ssa.Config refactoring, and promised to clean it up once the dust settled. The dust has settled. Along the way, this CL fixes a potential latent bug, in which the amd64 test context was used for all dummy Syslook calls. The lone SSA test using the s390x context did not depend on the Syslook context being correct, so the bug did not arise in practice. Change-Id: If964251d1807976073ad7f47da0b1f1f77c58413 Reviewed-on: https://go-review.googlesource.com/38346 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/func_test.go')
-rw-r--r--src/cmd/compile/internal/ssa/func_test.go40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/cmd/compile/internal/ssa/func_test.go b/src/cmd/compile/internal/ssa/func_test.go
index eaeb8268c1..3c81f0876e 100644
--- a/src/cmd/compile/internal/ssa/func_test.go
+++ b/src/cmd/compile/internal/ssa/func_test.go
@@ -143,9 +143,9 @@ var emptyPass pass = pass{
// returns a fun containing the composed Func. entry must be a name
// supplied to one of the Bloc functions. Each of the bloc names and
// valu names should be unique across the Fun.
-func Fun(c *Config, fe Frontend, entry string, blocs ...bloc) fun {
- f := NewFunc(fe)
- f.Config = c
+func (c *Conf) Fun(entry string, blocs ...bloc) fun {
+ f := NewFunc(c.Frontend())
+ f.Config = c.config
// TODO: Either mark some SSA tests as t.Parallel,
// or set up a shared Cache and Reset it between tests.
// But not both.
@@ -274,7 +274,7 @@ type valu struct {
func TestArgs(t *testing.T) {
c := testConfig(t)
- fun := Fun(c, DummyFrontend{t}, "entry",
+ fun := c.Fun("entry",
Bloc("entry",
Valu("a", OpConst64, TypeInt64, 14, nil),
Valu("b", OpConst64, TypeInt64, 26, nil),
@@ -293,10 +293,11 @@ func TestArgs(t *testing.T) {
}
func TestEquiv(t *testing.T) {
+ cfg := testConfig(t)
equivalentCases := []struct{ f, g fun }{
// simple case
{
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("a", OpConst64, TypeInt64, 14, nil),
Valu("b", OpConst64, TypeInt64, 26, nil),
@@ -305,7 +306,7 @@ func TestEquiv(t *testing.T) {
Goto("exit")),
Bloc("exit",
Exit("mem"))),
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("a", OpConst64, TypeInt64, 14, nil),
Valu("b", OpConst64, TypeInt64, 26, nil),
@@ -317,7 +318,7 @@ func TestEquiv(t *testing.T) {
},
// block order changed
{
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("a", OpConst64, TypeInt64, 14, nil),
Valu("b", OpConst64, TypeInt64, 26, nil),
@@ -326,7 +327,7 @@ func TestEquiv(t *testing.T) {
Goto("exit")),
Bloc("exit",
Exit("mem"))),
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("exit",
Exit("mem")),
Bloc("entry",
@@ -348,26 +349,26 @@ func TestEquiv(t *testing.T) {
differentCases := []struct{ f, g fun }{
// different shape
{
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Goto("exit")),
Bloc("exit",
Exit("mem"))),
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Exit("mem"))),
},
// value order changed
{
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Valu("b", OpConst64, TypeInt64, 26, nil),
Valu("a", OpConst64, TypeInt64, 14, nil),
Exit("mem"))),
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Valu("a", OpConst64, TypeInt64, 14, nil),
@@ -376,12 +377,12 @@ func TestEquiv(t *testing.T) {
},
// value auxint different
{
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Valu("a", OpConst64, TypeInt64, 14, nil),
Exit("mem"))),
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Valu("a", OpConst64, TypeInt64, 26, nil),
@@ -389,12 +390,12 @@ func TestEquiv(t *testing.T) {
},
// value aux different
{
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Valu("a", OpConst64, TypeInt64, 0, 14),
Exit("mem"))),
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Valu("a", OpConst64, TypeInt64, 0, 26),
@@ -402,14 +403,14 @@ func TestEquiv(t *testing.T) {
},
// value args different
{
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Valu("a", OpConst64, TypeInt64, 14, nil),
Valu("b", OpConst64, TypeInt64, 26, nil),
Valu("sum", OpAdd64, TypeInt64, 0, nil, "a", "b"),
Exit("mem"))),
- Fun(testConfig(t), DummyFrontend{t}, "entry",
+ cfg.Fun("entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Valu("a", OpConst64, TypeInt64, 0, nil),
@@ -430,7 +431,8 @@ func TestEquiv(t *testing.T) {
// TestConstCache ensures that the cache will not return
// reused free'd values with a non-matching AuxInt
func TestConstCache(t *testing.T) {
- f := Fun(testConfig(t), DummyFrontend{t}, "entry",
+ c := testConfig(t)
+ f := c.Fun("entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Exit("mem")))