}
// NewFunc returns a new, empty function object.
-// Caller must set f.Config and f.Cache before using f.
-func NewFunc(fe Frontend) *Func {
- return &Func{fe: fe, NamedValues: make(map[LocalSlot][]*Value), CanonicalLocalSlots: make(map[LocalSlot]*LocalSlot), CanonicalLocalSplits: make(map[LocalSlotSplitKey]*LocalSlot)}
+// Caller must reset cache before calling NewFunc.
+func (c *Config) NewFunc(fe Frontend, cache *Cache) *Func {
+ return &Func{
+ fe: fe,
+ Config: c,
+ Cache: cache,
+
+ NamedValues: make(map[LocalSlot][]*Value),
+ CanonicalLocalSlots: make(map[LocalSlot]*LocalSlot),
+ CanonicalLocalSplits: make(map[LocalSlotSplitKey]*LocalSlot),
+ }
}
// NumBlocks returns an integer larger than the id of any Block in the Func.
// supplied to one of the Bloc functions. Each of the bloc names and
// valu names should be unique across the Fun.
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.
- f.Cache = new(Cache)
+ f := c.config.NewFunc(c.Frontend(), new(Cache))
f.pass = &emptyPass
f.cachedLineStarts = newXposmap(map[int]lineRange{0: {0, 100}, 1: {0, 100}, 2: {0, 100}, 3: {0, 100}, 4: {0, 100}})
}
s.curfn = fn
- s.f = ssa.NewFunc(&fe)
+ cache := &ssaCaches[worker]
+ cache.Reset()
+
+ s.f = ssaConfig.NewFunc(&fe, cache)
s.config = ssaConfig
s.f.Type = fn.Type()
- s.f.Config = ssaConfig
- s.f.Cache = &ssaCaches[worker]
- s.f.Cache.Reset()
s.f.Name = name
s.f.PrintOrHtmlSSA = printssa
if fn.Pragma&ir.Nosplit != 0 {