]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: clean up SSA test API
authorJosh Bleecher Snyder <josharian@gmail.com>
Sun, 19 Mar 2017 05:00:28 +0000 (22:00 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Sun, 19 Mar 2017 05:37:39 +0000 (05:37 +0000)
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>
17 files changed:
src/cmd/compile/internal/ssa/copyelim_test.go
src/cmd/compile/internal/ssa/cse_test.go
src/cmd/compile/internal/ssa/deadcode_test.go
src/cmd/compile/internal/ssa/deadstore_test.go
src/cmd/compile/internal/ssa/dom_test.go
src/cmd/compile/internal/ssa/export_test.go
src/cmd/compile/internal/ssa/func_test.go
src/cmd/compile/internal/ssa/fuse_test.go
src/cmd/compile/internal/ssa/lca_test.go
src/cmd/compile/internal/ssa/loop_test.go
src/cmd/compile/internal/ssa/nilcheck_test.go
src/cmd/compile/internal/ssa/passbm_test.go
src/cmd/compile/internal/ssa/regalloc_test.go
src/cmd/compile/internal/ssa/schedule_test.go
src/cmd/compile/internal/ssa/shift_test.go
src/cmd/compile/internal/ssa/shortcircuit_test.go
src/cmd/compile/internal/ssa/writebarrier_test.go

index 3250445fecae55c96d7377621dea679baa4d8d7c..5de147297a67b2aa009774dccc3e675463559fd6 100644 (file)
@@ -34,7 +34,7 @@ func benchmarkCopyElim(b *testing.B, n int) {
        }
 
        for i := 0; i < b.N; i++ {
-               fun := Fun(c, DummyFrontend{b}, "entry", Bloc("entry", values...))
+               fun := c.Fun("entry", Bloc("entry", values...))
                Copyelim(fun.f)
        }
 }
index 16d301506af1ec072b45ad587d4d42e8bf57dd4d..dcb081332e99175f2c4c9478d5a2a3ff85098d01 100644 (file)
@@ -19,7 +19,7 @@ func TestCSEAuxPartitionBug(t *testing.T) {
 
        // construct lots of values with args that have aux values and place
        // them in an order that triggers the bug
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, TypeMem, 0, nil),
                        Valu("sp", OpSP, TypeBytePtr, 0, nil),
@@ -87,7 +87,7 @@ func TestCSEAuxPartitionBug(t *testing.T) {
 func TestZCSE(t *testing.T) {
        c := testConfig(t)
 
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, TypeMem, 0, nil),
                        Valu("sp", OpSP, TypeBytePtr, 0, nil),
index 156a1d746e4a05dff5822168a0a64bff2f229e99..0f93bbf3fa4d9180850eca249635bd1ebab123eb 100644 (file)
@@ -12,7 +12,7 @@ import (
 
 func TestDeadLoop(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Goto("exit")),
@@ -42,7 +42,7 @@ func TestDeadLoop(t *testing.T) {
 
 func TestDeadValue(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("deadval", OpConst64, TypeInt64, 37, nil),
@@ -65,7 +65,7 @@ func TestDeadValue(t *testing.T) {
 
 func TestNeverTaken(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("cond", OpConstBool, TypeBool, 0, nil),
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
@@ -100,7 +100,7 @@ func TestNeverTaken(t *testing.T) {
 
 func TestNestedDeadBlocks(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("cond", OpConstBool, TypeBool, 0, nil),
@@ -152,7 +152,7 @@ func BenchmarkDeadCode(b *testing.B) {
                        }
                        b.ResetTimer()
                        for i := 0; i < b.N; i++ {
-                               fun := Fun(c, DummyFrontend{b}, "entry", blocks...)
+                               fun := c.Fun("entry", blocks...)
                                Deadcode(fun.f)
                        }
                })
index 82cda3327e470c4e001372fd26c1da12fc7e092f..3e38fe8efa35255cf3a33fcc23d93a50d5a5a4e9 100644 (file)
@@ -10,7 +10,7 @@ func TestDeadStore(t *testing.T) {
        c := testConfig(t)
        elemType := &TypeImpl{Size_: 1, Name: "testtype"}
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr", Elem_: elemType} // dummy for testing
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -45,7 +45,7 @@ func TestDeadStorePhi(t *testing.T) {
        // make sure we don't get into an infinite loop with phi values.
        c := testConfig(t)
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -72,7 +72,7 @@ func TestDeadStoreTypes(t *testing.T) {
        c := testConfig(t)
        t1 := &TypeImpl{Size_: 8, Ptr: true, Name: "t1"}
        t2 := &TypeImpl{Size_: 4, Ptr: true, Name: "t2"}
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -102,7 +102,7 @@ func TestDeadStoreUnsafe(t *testing.T) {
        // can get to a point where the size is changed but type unchanged.
        c := testConfig(t)
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
index 91758f24db9bd8dabbb20d3cef8461ea1b6ff54b..40f2b35b39e8c9de785f6d8b23ea73578881cf58 100644 (file)
@@ -161,7 +161,7 @@ var domBenchRes []*Block
 
 func benchmarkDominators(b *testing.B, size int, bg blockGen) {
        c := testConfig(b)
-       fun := Fun(c, DummyFrontend{b}, "entry", bg(size)...)
+       fun := c.Fun("entry", bg(size)...)
 
        CheckFunc(fun.f)
        b.SetBytes(int64(size))
@@ -221,7 +221,7 @@ func verifyDominators(t *testing.T, fut fun, domFn domFunc, doms map[string]stri
 
 func TestDominatorsSingleBlock(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Exit("mem")))
@@ -236,7 +236,7 @@ func TestDominatorsSingleBlock(t *testing.T) {
 
 func TestDominatorsSimple(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Goto("a")),
@@ -264,7 +264,7 @@ func TestDominatorsSimple(t *testing.T) {
 
 func TestDominatorsMultPredFwd(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("p", OpConstBool, TypeBool, 1, nil),
@@ -292,7 +292,7 @@ func TestDominatorsMultPredFwd(t *testing.T) {
 
 func TestDominatorsDeadCode(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("p", OpConstBool, TypeBool, 0, nil),
@@ -315,7 +315,7 @@ func TestDominatorsDeadCode(t *testing.T) {
 
 func TestDominatorsMultPredRev(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Goto("first")),
                Bloc("first",
@@ -346,7 +346,7 @@ func TestDominatorsMultPredRev(t *testing.T) {
 
 func TestDominatorsMultPred(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("p", OpConstBool, TypeBool, 1, nil),
@@ -375,7 +375,7 @@ func TestDominatorsMultPred(t *testing.T) {
 func TestInfiniteLoop(t *testing.T) {
        c := testConfig(t)
        // note lack of an exit block
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("p", OpConstBool, TypeBool, 1, nil),
@@ -411,7 +411,8 @@ func TestDomTricky(t *testing.T) {
                b := 1 & i >> 1
                c := 1 & i >> 2
 
-               fun := Fun(testConfig(t), DummyFrontend{t}, "1",
+               cfg := testConfig(t)
+               fun := cfg.Fun("1",
                        Bloc("1",
                                Valu("mem", OpInitMem, TypeMem, 0, nil),
                                Valu("p", OpConstBool, TypeBool, 1, nil),
@@ -455,7 +456,7 @@ func generateDominatorMap(fut fun) map[string]string {
 
 func TestDominatorsPostTricky(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "b1",
+       fun := c.Fun("b1",
                Bloc("b1",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("p", OpConstBool, TypeBool, 1, nil),
index 33e0ffb4162ebe51f03d3a29085ec19d24ae5cd6..fd8d3617f29d2533914e1c2ae8d5e52e91ebcbbd 100644 (file)
@@ -16,20 +16,48 @@ var CheckFunc = checkFunc
 var Opt = opt
 var Deadcode = deadcode
 var Copyelim = copyelim
-var TestCtxt = obj.Linknew(&x86.Linkamd64)
 
-func testConfig(t testing.TB) *Config {
-       return NewConfig("amd64", dummyTypes, TestCtxt, true)
+var testCtxts = map[string]*obj.Link{
+       "amd64": obj.Linknew(&x86.Linkamd64),
+       "s390x": obj.Linknew(&s390x.Links390x),
 }
 
-func testConfigS390X(t testing.TB) *Config {
-       return NewConfig("s390x", dummyTypes, obj.Linknew(&s390x.Links390x), true)
+func testConfig(tb testing.TB) *Conf      { return testConfigArch(tb, "amd64") }
+func testConfigS390X(tb testing.TB) *Conf { return testConfigArch(tb, "s390x") }
+
+func testConfigArch(tb testing.TB, arch string) *Conf {
+       ctxt, ok := testCtxts[arch]
+       if !ok {
+               tb.Fatalf("unknown arch %s", arch)
+       }
+       if ctxt.Arch.IntSize != 8 {
+               tb.Fatal("dummyTypes is 64-bit only")
+       }
+       c := &Conf{
+               config: NewConfig(arch, dummyTypes, ctxt, true),
+               tb:     tb,
+       }
+       return c
+}
+
+type Conf struct {
+       config *Config
+       tb     testing.TB
+       fe     Frontend
+}
+
+func (c *Conf) Frontend() Frontend {
+       if c.fe == nil {
+               c.fe = DummyFrontend{t: c.tb, ctxt: c.config.ctxt}
+       }
+       return c.fe
 }
 
 // DummyFrontend is a test-only frontend.
 // It assumes 64 bit integers and pointers.
 type DummyFrontend struct {
-       t testing.TB
+       t    testing.TB
+       ctxt *obj.Link
 }
 
 type DummyAuto struct {
@@ -85,8 +113,8 @@ func (DummyFrontend) Line(_ src.XPos) string {
 }
 func (DummyFrontend) AllocFrame(f *Func) {
 }
-func (DummyFrontend) Syslook(s string) *obj.LSym {
-       return obj.Linklookup(TestCtxt, s, 0)
+func (DummyFrontend) Syslook(s string) *obj.LSym {
+       return obj.Linklookup(d.ctxt, s, 0)
 }
 func (DummyFrontend) UseWriteBarrier() bool {
        return true // only writebarrier_test cares
index eaeb8268c187369f52efa31a03f8b2f77398f56d..3c81f0876e121cc15bb2000fbfa93be0910a23b3 100644 (file)
@@ -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")))
index ec340ee7c5818ac022e27a665192ab75c2fae48a..3a0aecc21c0f3be0ed5e6aedbd37a0369f47ebb3 100644 (file)
@@ -9,7 +9,7 @@ import (
 func TestFuseEliminatesOneBranch(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -37,7 +37,7 @@ func TestFuseEliminatesOneBranch(t *testing.T) {
 func TestFuseEliminatesBothBranches(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -70,7 +70,7 @@ func TestFuseEliminatesBothBranches(t *testing.T) {
 func TestFuseHandlesPhis(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -103,7 +103,7 @@ func TestFuseHandlesPhis(t *testing.T) {
 
 func TestFuseEliminatesEmptyBlocks(t *testing.T) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -160,7 +160,7 @@ func BenchmarkFuse(b *testing.B) {
 
                        b.ResetTimer()
                        for i := 0; i < b.N; i++ {
-                               fun := Fun(c, DummyFrontend{b}, "entry", blocks...)
+                               fun := c.Fun("entry", blocks...)
                                fuse(fun.f)
                        }
                })
index 74128ae6e149264c9b7f2edd9571936c9269dfc5..8221dc466d9a2a1492cedd6b6c2179efa693ae19 100644 (file)
@@ -23,7 +23,7 @@ func lcaEqual(f *Func, lca1, lca2 lca) bool {
 
 func testLCAgen(t *testing.T, bg blockGen, size int) {
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry", bg(size)...)
+       fun := c.Fun("entry", bg(size)...)
        CheckFunc(fun.f)
        if size == 4 {
                t.Logf(fun.f.String())
index db1069e823696ee69dafee8f4b334f083dde0cb4..b0f20be3eaedd1e1521f67c3c3054aa5b9909662 100644 (file)
@@ -44,13 +44,12 @@ func TestLoopConditionS390X(t *testing.T) {
        //   done:
        //
        c := testConfigS390X(t)
-       fe := DummyFrontend{t}
-       fun := Fun(c, fe, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("SP", OpSP, TypeUInt64, 0, nil),
                        Valu("ret", OpAddr, TypeInt64Ptr, 0, nil, "SP"),
-                       Valu("N", OpArg, TypeInt64, 0, fe.Auto(TypeInt64)),
+                       Valu("N", OpArg, TypeInt64, 0, c.Frontend().Auto(TypeInt64)),
                        Valu("starti", OpConst64, TypeInt64, 0, nil),
                        Valu("startsum", OpConst64, TypeInt64, 0, nil),
                        Goto("b1")),
index 0c9daf000895652ef8a3f0aa23cfe2a491a2b606..06edb033e329943525858d52c953c3d8c2e8f21c 100644 (file)
@@ -41,7 +41,7 @@ func benchmarkNilCheckDeep(b *testing.B, depth int) {
        )
 
        c := testConfig(b)
-       fun := Fun(c, DummyFrontend{b}, "entry", blocs...)
+       fun := c.Fun("entry", blocs...)
 
        CheckFunc(fun.f)
        b.SetBytes(int64(depth)) // helps for eyeballing linearity
@@ -65,7 +65,7 @@ func isNilCheck(b *Block) bool {
 func TestNilcheckSimple(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -102,7 +102,7 @@ func TestNilcheckSimple(t *testing.T) {
 func TestNilcheckDomOrder(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -138,7 +138,7 @@ func TestNilcheckDomOrder(t *testing.T) {
 func TestNilcheckAddr(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -171,7 +171,7 @@ func TestNilcheckAddr(t *testing.T) {
 func TestNilcheckAddPtr(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -206,7 +206,7 @@ func TestNilcheckAddPtr(t *testing.T) {
 func TestNilcheckPhi(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -250,7 +250,7 @@ func TestNilcheckPhi(t *testing.T) {
 func TestNilcheckKeepRemove(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -298,7 +298,7 @@ func TestNilcheckKeepRemove(t *testing.T) {
 func TestNilcheckInFalseBranch(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -349,7 +349,7 @@ func TestNilcheckInFalseBranch(t *testing.T) {
 func TestNilcheckUser(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -388,7 +388,7 @@ func TestNilcheckUser(t *testing.T) {
 func TestNilcheckBug(t *testing.T) {
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
index f628a028063336fd16c7de370861aad8864017d3..c316e9b67de611ae43f5c6ec2c148e86d5d39666 100644 (file)
@@ -34,7 +34,7 @@ func BenchmarkMultiPassBlock(b *testing.B) { benchFnBlock(b, multi, genFunction)
 func benchFnPass(b *testing.B, fn passFunc, size int, bg blockGen) {
        b.ReportAllocs()
        c := testConfig(b)
-       fun := Fun(c, DummyFrontend{b}, "entry", bg(size)...)
+       fun := c.Fun("entry", bg(size)...)
        CheckFunc(fun.f)
        b.ResetTimer()
        for i := 0; i < b.N; i++ {
@@ -49,7 +49,7 @@ func benchFnPass(b *testing.B, fn passFunc, size int, bg blockGen) {
 func benchFnBlock(b *testing.B, fn passFunc, bg blockGen) {
        b.ReportAllocs()
        c := testConfig(b)
-       fun := Fun(c, DummyFrontend{b}, "entry", bg(b.N)...)
+       fun := c.Fun("entry", bg(b.N)...)
        CheckFunc(fun.f)
        b.ResetTimer()
        for i := 0; i < passCount; i++ {
index 55ed6d769e2900282eb811ea6e76ff587d909e4e..e52c6c1b27c5ccd5083a3f9c57db3bf39f28e2e6 100644 (file)
@@ -8,7 +8,7 @@ import "testing"
 
 func TestLiveControlOps(t *testing.T) {
        c := testConfig(t)
-       f := Fun(c, DummyFrontend{t}, "entry",
+       f := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("x", OpAMD64MOVLconst, TypeInt8, 1, nil),
index fc4409ad25c5a3fd39c20e7a7cb3ad3a8fa9e07b..eceaafc0887aeb5dfa4d5e19e4599b27610b275a 100644 (file)
@@ -9,7 +9,7 @@ import "testing"
 func TestSchedule(t *testing.T) {
        c := testConfig(t)
        cases := []fun{
-               Fun(c, DummyFrontend{t}, "entry",
+               c.Fun("entry",
                        Bloc("entry",
                                Valu("mem0", OpInitMem, TypeMem, 0, nil),
                                Valu("ptr", OpConst64, TypeInt64, 0xABCD, nil),
@@ -60,7 +60,7 @@ func TestStoreOrder(t *testing.T) {
        // In the function below, v2 depends on v3 and v4, v4 depends on v3, and v3 depends on store v5.
        // storeOrder did not handle this case correctly.
        c := testConfig(t)
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem0", OpInitMem, TypeMem, 0, nil),
                        Valu("a", OpAdd64, TypeInt64, 0, nil, "b", "c"),                  // v2
index 2102612cdb3b03327d83ec59f7fe2f0a8f53b60b..1c39f50389efc7fbcbdf1636fe6cd278590fb607 100644 (file)
@@ -10,29 +10,28 @@ import (
 
 func TestShiftConstAMD64(t *testing.T) {
        c := testConfig(t)
-       fe := DummyFrontend{t}
-       fun := makeConstShiftFunc(c, fe, 18, OpLsh64x64, TypeUInt64)
+       fun := makeConstShiftFunc(c, 18, OpLsh64x64, TypeUInt64)
        checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SHLQconst: 1, OpAMD64CMPQconst: 0, OpAMD64ANDQconst: 0})
 
-       fun = makeConstShiftFunc(c, fe, 66, OpLsh64x64, TypeUInt64)
+       fun = makeConstShiftFunc(c, 66, OpLsh64x64, TypeUInt64)
        checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SHLQconst: 0, OpAMD64CMPQconst: 0, OpAMD64ANDQconst: 0})
 
-       fun = makeConstShiftFunc(c, fe, 18, OpRsh64Ux64, TypeUInt64)
+       fun = makeConstShiftFunc(c, 18, OpRsh64Ux64, TypeUInt64)
        checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SHRQconst: 1, OpAMD64CMPQconst: 0, OpAMD64ANDQconst: 0})
 
-       fun = makeConstShiftFunc(c, fe, 66, OpRsh64Ux64, TypeUInt64)
+       fun = makeConstShiftFunc(c, 66, OpRsh64Ux64, TypeUInt64)
        checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SHRQconst: 0, OpAMD64CMPQconst: 0, OpAMD64ANDQconst: 0})
 
-       fun = makeConstShiftFunc(c, fe, 18, OpRsh64x64, TypeInt64)
+       fun = makeConstShiftFunc(c, 18, OpRsh64x64, TypeInt64)
        checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SARQconst: 1, OpAMD64CMPQconst: 0})
 
-       fun = makeConstShiftFunc(c, fe, 66, OpRsh64x64, TypeInt64)
+       fun = makeConstShiftFunc(c, 66, OpRsh64x64, TypeInt64)
        checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SARQconst: 1, OpAMD64CMPQconst: 0})
 }
 
-func makeConstShiftFunc(c *Config, fe Frontend, amount int64, op Op, typ Type) fun {
+func makeConstShiftFunc(c *Conf, amount int64, op Op, typ Type) fun {
        ptyp := &TypeImpl{Size_: 8, Ptr: true, Name: "ptr"}
-       fun := Fun(c, fe, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("SP", OpSP, TypeUInt64, 0, nil),
@@ -77,9 +76,8 @@ func TestShiftToExtensionAMD64(t *testing.T) {
                {8, OpLsh16x64, OpRsh16x64, TypeInt16},
        }
        c := testConfig(t)
-       fe := DummyFrontend{t}
        for _, tc := range tests {
-               fun := makeShiftExtensionFunc(c, fe, tc.amount, tc.left, tc.right, tc.typ)
+               fun := makeShiftExtensionFunc(c, tc.amount, tc.left, tc.right, tc.typ)
                checkOpcodeCounts(t, fun.f, ops)
        }
 }
@@ -89,9 +87,9 @@ func TestShiftToExtensionAMD64(t *testing.T) {
 //   (rshift (lshift (Const64 [amount])) (Const64 [amount]))
 //
 // This may be equivalent to a sign or zero extension.
-func makeShiftExtensionFunc(c *Config, fe Frontend, amount int64, lshift, rshift Op, typ Type) fun {
+func makeShiftExtensionFunc(c *Conf, amount int64, lshift, rshift Op, typ Type) fun {
        ptyp := &TypeImpl{Size_: 8, Ptr: true, Name: "ptr"}
-       fun := Fun(c, fe, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("SP", OpSP, TypeUInt64, 0, nil),
index 93033df469d1100cfb7eec87cf002a3e1eeab9d0..e70159d746af722292b0e8c869c8295cb8a076e2 100644 (file)
@@ -9,7 +9,7 @@ import "testing"
 func TestShortCircuit(t *testing.T) {
        c := testConfig(t)
 
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, TypeMem, 0, nil),
                        Valu("arg1", OpArg, TypeInt64, 0, nil),
index 41d6de9c13821f0866de25b0d7efe428a1157901..e26346de3cd1f1d006aaac6bfe040e7a198266b5 100644 (file)
@@ -10,7 +10,7 @@ func TestWriteBarrierStoreOrder(t *testing.T) {
        // Make sure writebarrier phase works even StoreWB ops are not in dependency order
        c := testConfig(t)
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),
@@ -34,7 +34,7 @@ func TestWriteBarrierPhi(t *testing.T) {
        // See issue #19067.
        c := testConfig(t)
        ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
-       fun := Fun(c, DummyFrontend{t}, "entry",
+       fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, TypeMem, 0, nil),
                        Valu("sb", OpSB, TypeInvalid, 0, nil),