| |
| |
| |
|
|
| package ssa |
|
|
| import ( |
| "cmd/compile/internal/abi" |
| "cmd/compile/internal/base" |
| "cmd/compile/internal/ir" |
| "cmd/compile/internal/typecheck" |
| "cmd/compile/internal/types" |
| "cmd/internal/obj" |
| "cmd/internal/src" |
| "fmt" |
| "math" |
| "strings" |
| ) |
|
|
| |
| |
| |
| type Func struct { |
| Config *Config |
| Cache *Cache |
| fe Frontend |
| pass *pass |
| Name string |
| Type *types.Type |
| Blocks []*Block |
| Entry *Block |
|
|
| bid idAlloc |
| vid idAlloc |
|
|
| HTMLWriter *HTMLWriter |
| PrintOrHtmlSSA bool |
| ruleMatches map[string]int |
| ABI0 *abi.ABIConfig |
| ABI1 *abi.ABIConfig |
| ABISelf *abi.ABIConfig |
| ABIDefault *abi.ABIConfig |
|
|
| maxCPUFeatures CPUfeatures |
|
|
| scheduled bool |
| laidout bool |
| NoSplit bool |
| dumpFileSeq uint8 |
| IsPgoHot bool |
| DeferReturn *Block |
|
|
| |
| RegAlloc []Location |
|
|
| |
| tempRegs map[ID]*Register |
|
|
| |
| NamedValues map[LocalSlot][]*Value |
| |
| |
| Names []*LocalSlot |
| |
| |
| CanonicalLocalSlots map[LocalSlot]*LocalSlot |
| CanonicalLocalSplits map[LocalSlotSplitKey]*LocalSlot |
|
|
| |
| RegArgs []Spill |
| |
| OwnAux *AuxCall |
| |
| |
| CloSlot *ir.Name |
|
|
| freeValues *Value |
| freeBlocks *Block |
|
|
| cachedPostorder []*Block |
| cachedIdom []*Block |
| cachedSdom SparseTree |
| cachedLoopnest *loopnest |
| cachedLineStarts *xposmap |
|
|
| auxmap auxmap |
| constants map[int64][]*Value |
| } |
|
|
| type LocalSlotSplitKey struct { |
| parent *LocalSlot |
| Off int64 |
| Type *types.Type |
| } |
|
|
| |
| |
| 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), |
| OwnAux: &AuxCall{}, |
| } |
| } |
|
|
| |
| func (f *Func) NumBlocks() int { |
| return f.bid.num() |
| } |
|
|
| |
| func (f *Func) NumValues() int { |
| return f.vid.num() |
| } |
|
|
| |
| |
| |
| |
| func (f *Func) NameABI() string { |
| return FuncNameABI(f.Name, f.ABISelf.Which()) |
| } |
|
|
| |
| |
| |
| func FuncNameABI(n string, a obj.ABI) string { |
| return fmt.Sprintf("%s,%d", n, a) |
| } |
|
|
| |
| func (f *Func) newSparseSet(n int) *sparseSet { |
| return f.Cache.allocSparseSet(n) |
| } |
|
|
| |
| |
| func (f *Func) retSparseSet(ss *sparseSet) { |
| f.Cache.freeSparseSet(ss) |
| } |
|
|
| |
| func (f *Func) newSparseMap(n int) *sparseMap { |
| return f.Cache.allocSparseMap(n) |
| } |
|
|
| |
| |
| func (f *Func) retSparseMap(ss *sparseMap) { |
| f.Cache.freeSparseMap(ss) |
| } |
|
|
| |
| func (f *Func) newSparseMapPos(n int) *sparseMapPos { |
| return f.Cache.allocSparseMapPos(n) |
| } |
|
|
| |
| |
| func (f *Func) retSparseMapPos(ss *sparseMapPos) { |
| f.Cache.freeSparseMapPos(ss) |
| } |
|
|
| |
| func (f *Func) newPoset() *poset { |
| if len(f.Cache.scrPoset) > 0 { |
| po := f.Cache.scrPoset[len(f.Cache.scrPoset)-1] |
| f.Cache.scrPoset = f.Cache.scrPoset[:len(f.Cache.scrPoset)-1] |
| return po |
| } |
| return newPoset() |
| } |
|
|
| |
| func (f *Func) retPoset(po *poset) { |
| f.Cache.scrPoset = append(f.Cache.scrPoset, po) |
| } |
|
|
| func (f *Func) localSlotAddr(slot LocalSlot) *LocalSlot { |
| a, ok := f.CanonicalLocalSlots[slot] |
| if !ok { |
| a = new(LocalSlot) |
| *a = slot |
| f.CanonicalLocalSlots[slot] = a |
| } |
| return a |
| } |
|
|
| func (f *Func) SplitString(name *LocalSlot) (*LocalSlot, *LocalSlot) { |
| ptrType := types.NewPtr(types.Types[types.TUINT8]) |
| lenType := types.Types[types.TINT] |
| |
| p := f.SplitSlot(name, ".ptr", 0, ptrType) |
| l := f.SplitSlot(name, ".len", ptrType.Size(), lenType) |
| return p, l |
| } |
|
|
| func (f *Func) SplitInterface(name *LocalSlot) (*LocalSlot, *LocalSlot) { |
| n := name.N |
| u := types.Types[types.TUINTPTR] |
| t := types.NewPtr(types.Types[types.TUINT8]) |
| |
| sfx := ".itab" |
| if n.Type().IsEmptyInterface() { |
| sfx = ".type" |
| } |
| c := f.SplitSlot(name, sfx, 0, u) |
| d := f.SplitSlot(name, ".data", u.Size(), t) |
| return c, d |
| } |
|
|
| func (f *Func) SplitSlice(name *LocalSlot) (*LocalSlot, *LocalSlot, *LocalSlot) { |
| ptrType := types.NewPtr(name.Type.Elem()) |
| lenType := types.Types[types.TINT] |
| p := f.SplitSlot(name, ".ptr", 0, ptrType) |
| l := f.SplitSlot(name, ".len", ptrType.Size(), lenType) |
| c := f.SplitSlot(name, ".cap", ptrType.Size()+lenType.Size(), lenType) |
| return p, l, c |
| } |
|
|
| func (f *Func) SplitComplex(name *LocalSlot) (*LocalSlot, *LocalSlot) { |
| s := name.Type.Size() / 2 |
| var t *types.Type |
| if s == 8 { |
| t = types.Types[types.TFLOAT64] |
| } else { |
| t = types.Types[types.TFLOAT32] |
| } |
| r := f.SplitSlot(name, ".real", 0, t) |
| i := f.SplitSlot(name, ".imag", t.Size(), t) |
| return r, i |
| } |
|
|
| func (f *Func) SplitInt64(name *LocalSlot) (*LocalSlot, *LocalSlot) { |
| var t *types.Type |
| if name.Type.IsSigned() { |
| t = types.Types[types.TINT32] |
| } else { |
| t = types.Types[types.TUINT32] |
| } |
| if f.Config.BigEndian { |
| return f.SplitSlot(name, ".hi", 0, t), f.SplitSlot(name, ".lo", t.Size(), types.Types[types.TUINT32]) |
| } |
| return f.SplitSlot(name, ".hi", t.Size(), t), f.SplitSlot(name, ".lo", 0, types.Types[types.TUINT32]) |
| } |
|
|
| func (f *Func) SplitStruct(name *LocalSlot, i int) *LocalSlot { |
| st := name.Type |
| return f.SplitSlot(name, st.FieldName(i), st.FieldOff(i), st.FieldType(i)) |
| } |
| func (f *Func) SplitArray(name *LocalSlot) *LocalSlot { |
| n := name.N |
| at := name.Type |
| if at.NumElem() != 1 { |
| base.FatalfAt(n.Pos(), "bad array size") |
| } |
| et := at.Elem() |
| return f.SplitSlot(name, "[0]", 0, et) |
| } |
|
|
| func (f *Func) SplitSlot(name *LocalSlot, sfx string, offset int64, t *types.Type) *LocalSlot { |
| lssk := LocalSlotSplitKey{name, offset, t} |
| if als, ok := f.CanonicalLocalSplits[lssk]; ok { |
| return als |
| } |
| |
| |
| |
| ls := f.fe.SplitSlot(name, sfx, offset, t) |
| f.CanonicalLocalSplits[lssk] = &ls |
| return &ls |
| } |
|
|
| |
| func (f *Func) newValue(op Op, t *types.Type, b *Block, pos src.XPos) *Value { |
| var v *Value |
| if f.freeValues != nil { |
| v = f.freeValues |
| f.freeValues = v.argstorage[0] |
| v.argstorage[0] = nil |
| } else { |
| ID := f.vid.get() |
| if int(ID) < len(f.Cache.values) { |
| v = &f.Cache.values[ID] |
| v.ID = ID |
| } else { |
| v = &Value{ID: ID} |
| } |
| } |
| v.Op = op |
| v.Type = t |
| v.Block = b |
| if notStmtBoundary(op) { |
| pos = pos.WithNotStmt() |
| } |
| v.Pos = pos |
| b.Values = append(b.Values, v) |
| return v |
| } |
|
|
| |
| |
| |
| |
| func (f *Func) newValueNoBlock(op Op, t *types.Type, pos src.XPos) *Value { |
| var v *Value |
| if f.freeValues != nil { |
| v = f.freeValues |
| f.freeValues = v.argstorage[0] |
| v.argstorage[0] = nil |
| } else { |
| ID := f.vid.get() |
| if int(ID) < len(f.Cache.values) { |
| v = &f.Cache.values[ID] |
| v.ID = ID |
| } else { |
| v = &Value{ID: ID} |
| } |
| } |
| v.Op = op |
| v.Type = t |
| v.Block = nil |
| if notStmtBoundary(op) { |
| pos = pos.WithNotStmt() |
| } |
| v.Pos = pos |
| return v |
| } |
|
|
| |
| |
| |
| |
| |
| |
| func (f *Func) LogStat(key string, args ...any) { |
| value := "" |
| for _, a := range args { |
| value += fmt.Sprintf("\t%v", a) |
| } |
| n := "missing_pass" |
| if f.pass != nil { |
| n = strings.ReplaceAll(f.pass.name, " ", "_") |
| } |
| f.Warnl(f.Entry.Pos, "\t%s\t%s%s\t%s", n, key, value, f.Name) |
| } |
|
|
| |
| |
| |
| func (f *Func) unCacheLine(v *Value, aux int64) bool { |
| vv := f.constants[aux] |
| for i, cv := range vv { |
| if v == cv { |
| vv[i] = vv[len(vv)-1] |
| vv[len(vv)-1] = nil |
| f.constants[aux] = vv[0 : len(vv)-1] |
| v.InCache = false |
| return true |
| } |
| } |
| return false |
| } |
|
|
| |
| func (f *Func) unCache(v *Value) { |
| if v.InCache { |
| aux := v.AuxInt |
| if f.unCacheLine(v, aux) { |
| return |
| } |
| if aux == 0 { |
| switch v.Op { |
| case OpConstNil: |
| aux = constNilMagic |
| case OpConstSlice: |
| aux = constSliceMagic |
| case OpConstString: |
| aux = constEmptyStringMagic |
| case OpConstInterface: |
| aux = constInterfaceMagic |
| } |
| if aux != 0 && f.unCacheLine(v, aux) { |
| return |
| } |
| } |
| f.Fatalf("unCached value %s not found in cache, auxInt=0x%x, adjusted aux=0x%x", v.LongString(), v.AuxInt, aux) |
| } |
| } |
|
|
| |
| func (f *Func) freeValue(v *Value) { |
| if v.Block == nil { |
| f.Fatalf("trying to free an already freed value") |
| } |
| if v.Uses != 0 { |
| f.Fatalf("value %s still has %d uses", v, v.Uses) |
| } |
| if len(v.Args) != 0 { |
| f.Fatalf("value %s still has %d args", v, len(v.Args)) |
| } |
| |
| id := v.ID |
| if v.InCache { |
| f.unCache(v) |
| } |
| *v = Value{} |
| v.ID = id |
| v.argstorage[0] = f.freeValues |
| f.freeValues = v |
| } |
|
|
| |
| func (f *Func) NewBlock(kind BlockKind) *Block { |
| var b *Block |
| if f.freeBlocks != nil { |
| b = f.freeBlocks |
| f.freeBlocks = b.succstorage[0].b |
| b.succstorage[0].b = nil |
| } else { |
| ID := f.bid.get() |
| if int(ID) < len(f.Cache.blocks) { |
| b = &f.Cache.blocks[ID] |
| b.ID = ID |
| } else { |
| b = &Block{ID: ID} |
| } |
| } |
| b.Kind = kind |
| b.Func = f |
| b.Preds = b.predstorage[:0] |
| b.Succs = b.succstorage[:0] |
| b.Values = b.valstorage[:0] |
| f.Blocks = append(f.Blocks, b) |
| f.invalidateCFG() |
| return b |
| } |
|
|
| func (f *Func) freeBlock(b *Block) { |
| if b.Func == nil { |
| f.Fatalf("trying to free an already freed block") |
| } |
| |
| id := b.ID |
| *b = Block{} |
| b.ID = id |
| b.succstorage[0].b = f.freeBlocks |
| f.freeBlocks = b |
| } |
|
|
| |
| func (b *Block) NewValue0(pos src.XPos, op Op, t *types.Type) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = 0 |
| v.Args = v.argstorage[:0] |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue0I(pos src.XPos, op Op, t *types.Type, auxint int64) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = auxint |
| v.Args = v.argstorage[:0] |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue0A(pos src.XPos, op Op, t *types.Type, aux Aux) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = 0 |
| v.Aux = aux |
| v.Args = v.argstorage[:0] |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue0IA(pos src.XPos, op Op, t *types.Type, auxint int64, aux Aux) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = auxint |
| v.Aux = aux |
| v.Args = v.argstorage[:0] |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue1(pos src.XPos, op Op, t *types.Type, arg *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = 0 |
| v.Args = v.argstorage[:1] |
| v.argstorage[0] = arg |
| arg.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue1I(pos src.XPos, op Op, t *types.Type, auxint int64, arg *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = auxint |
| v.Args = v.argstorage[:1] |
| v.argstorage[0] = arg |
| arg.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue1A(pos src.XPos, op Op, t *types.Type, aux Aux, arg *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = 0 |
| v.Aux = aux |
| v.Args = v.argstorage[:1] |
| v.argstorage[0] = arg |
| arg.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue1IA(pos src.XPos, op Op, t *types.Type, auxint int64, aux Aux, arg *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = auxint |
| v.Aux = aux |
| v.Args = v.argstorage[:1] |
| v.argstorage[0] = arg |
| arg.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue2(pos src.XPos, op Op, t *types.Type, arg0, arg1 *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = 0 |
| v.Args = v.argstorage[:2] |
| v.argstorage[0] = arg0 |
| v.argstorage[1] = arg1 |
| arg0.Uses++ |
| arg1.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue2A(pos src.XPos, op Op, t *types.Type, aux Aux, arg0, arg1 *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = 0 |
| v.Aux = aux |
| v.Args = v.argstorage[:2] |
| v.argstorage[0] = arg0 |
| v.argstorage[1] = arg1 |
| arg0.Uses++ |
| arg1.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue2I(pos src.XPos, op Op, t *types.Type, auxint int64, arg0, arg1 *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = auxint |
| v.Args = v.argstorage[:2] |
| v.argstorage[0] = arg0 |
| v.argstorage[1] = arg1 |
| arg0.Uses++ |
| arg1.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue2IA(pos src.XPos, op Op, t *types.Type, auxint int64, aux Aux, arg0, arg1 *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = auxint |
| v.Aux = aux |
| v.Args = v.argstorage[:2] |
| v.argstorage[0] = arg0 |
| v.argstorage[1] = arg1 |
| arg0.Uses++ |
| arg1.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue3(pos src.XPos, op Op, t *types.Type, arg0, arg1, arg2 *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = 0 |
| v.Args = v.argstorage[:3] |
| v.argstorage[0] = arg0 |
| v.argstorage[1] = arg1 |
| v.argstorage[2] = arg2 |
| arg0.Uses++ |
| arg1.Uses++ |
| arg2.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue3I(pos src.XPos, op Op, t *types.Type, auxint int64, arg0, arg1, arg2 *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = auxint |
| v.Args = v.argstorage[:3] |
| v.argstorage[0] = arg0 |
| v.argstorage[1] = arg1 |
| v.argstorage[2] = arg2 |
| arg0.Uses++ |
| arg1.Uses++ |
| arg2.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue3A(pos src.XPos, op Op, t *types.Type, aux Aux, arg0, arg1, arg2 *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = 0 |
| v.Aux = aux |
| v.Args = v.argstorage[:3] |
| v.argstorage[0] = arg0 |
| v.argstorage[1] = arg1 |
| v.argstorage[2] = arg2 |
| arg0.Uses++ |
| arg1.Uses++ |
| arg2.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue4(pos src.XPos, op Op, t *types.Type, arg0, arg1, arg2, arg3 *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = 0 |
| v.Args = []*Value{arg0, arg1, arg2, arg3} |
| arg0.Uses++ |
| arg1.Uses++ |
| arg2.Uses++ |
| arg3.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue4A(pos src.XPos, op Op, t *types.Type, aux Aux, arg0, arg1, arg2, arg3 *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = 0 |
| v.Aux = aux |
| v.Args = []*Value{arg0, arg1, arg2, arg3} |
| arg0.Uses++ |
| arg1.Uses++ |
| arg2.Uses++ |
| arg3.Uses++ |
| return v |
| } |
|
|
| |
| func (b *Block) NewValue4I(pos src.XPos, op Op, t *types.Type, auxint int64, arg0, arg1, arg2, arg3 *Value) *Value { |
| v := b.Func.newValue(op, t, b, pos) |
| v.AuxInt = auxint |
| v.Args = []*Value{arg0, arg1, arg2, arg3} |
| arg0.Uses++ |
| arg1.Uses++ |
| arg2.Uses++ |
| arg3.Uses++ |
| return v |
| } |
|
|
| |
| func (f *Func) constVal(op Op, t *types.Type, c int64, setAuxInt bool) *Value { |
| if f.constants == nil { |
| f.constants = make(map[int64][]*Value) |
| } |
| vv := f.constants[c] |
| for _, v := range vv { |
| if v.Op == op && v.Type.Compare(t) == types.CMPeq { |
| if setAuxInt && v.AuxInt != c { |
| panic(fmt.Sprintf("cached const %s should have AuxInt of %d", v.LongString(), c)) |
| } |
| return v |
| } |
| } |
| var v *Value |
| if setAuxInt { |
| v = f.Entry.NewValue0I(src.NoXPos, op, t, c) |
| } else { |
| v = f.Entry.NewValue0(src.NoXPos, op, t) |
| } |
| f.constants[c] = append(vv, v) |
| v.InCache = true |
| return v |
| } |
|
|
| |
| |
| |
| |
| const ( |
| constSliceMagic = 1122334455 |
| constInterfaceMagic = 2233445566 |
| constNilMagic = 3344556677 |
| constEmptyStringMagic = 4455667788 |
| ) |
|
|
| |
| func (f *Func) ConstBool(t *types.Type, c bool) *Value { |
| i := int64(0) |
| if c { |
| i = 1 |
| } |
| return f.constVal(OpConstBool, t, i, true) |
| } |
| func (f *Func) ConstInt8(t *types.Type, c int8) *Value { |
| return f.constVal(OpConst8, t, int64(c), true) |
| } |
| func (f *Func) ConstInt16(t *types.Type, c int16) *Value { |
| return f.constVal(OpConst16, t, int64(c), true) |
| } |
| func (f *Func) ConstInt32(t *types.Type, c int32) *Value { |
| return f.constVal(OpConst32, t, int64(c), true) |
| } |
| func (f *Func) ConstInt64(t *types.Type, c int64) *Value { |
| return f.constVal(OpConst64, t, c, true) |
| } |
| func (f *Func) ConstFloat32(t *types.Type, c float64) *Value { |
| return f.constVal(OpConst32F, t, int64(math.Float64bits(float64(float32(c)))), true) |
| } |
| func (f *Func) ConstFloat64(t *types.Type, c float64) *Value { |
| return f.constVal(OpConst64F, t, int64(math.Float64bits(c)), true) |
| } |
|
|
| func (f *Func) ConstSlice(t *types.Type) *Value { |
| return f.constVal(OpConstSlice, t, constSliceMagic, false) |
| } |
| func (f *Func) ConstInterface(t *types.Type) *Value { |
| return f.constVal(OpConstInterface, t, constInterfaceMagic, false) |
| } |
| func (f *Func) ConstNil(t *types.Type) *Value { |
| return f.constVal(OpConstNil, t, constNilMagic, false) |
| } |
| func (f *Func) ConstEmptyString(t *types.Type) *Value { |
| v := f.constVal(OpConstString, t, constEmptyStringMagic, false) |
| v.Aux = StringToAux("") |
| return v |
| } |
| func (f *Func) ConstOffPtrSP(t *types.Type, c int64, sp *Value) *Value { |
| v := f.constVal(OpOffPtr, t, c, true) |
| if len(v.Args) == 0 { |
| v.AddArg(sp) |
| } |
| return v |
| } |
|
|
| func (f *Func) Frontend() Frontend { return f.fe } |
| func (f *Func) Warnl(pos src.XPos, msg string, args ...any) { f.fe.Warnl(pos, msg, args...) } |
| func (f *Func) Logf(msg string, args ...any) { f.fe.Logf(msg, args...) } |
| func (f *Func) Log() bool { return f.fe.Log() } |
|
|
| func (f *Func) Fatalf(msg string, args ...any) { |
| stats := "crashed" |
| if f.Log() { |
| f.Logf(" pass %s end %s\n", f.pass.name, stats) |
| printFunc(f) |
| } |
| if f.HTMLWriter != nil { |
| f.HTMLWriter.WritePhase(f.pass.name, fmt.Sprintf("%s <span class=\"stats\">%s</span>", f.pass.name, stats)) |
| f.HTMLWriter.flushPhases() |
| } |
| f.fe.Fatalf(f.Entry.Pos, msg, args...) |
| } |
|
|
| |
| func (f *Func) postorder() []*Block { |
| if f.cachedPostorder == nil { |
| f.cachedPostorder = postorder(f) |
| } |
| return f.cachedPostorder |
| } |
|
|
| func (f *Func) Postorder() []*Block { |
| return f.postorder() |
| } |
|
|
| |
| |
| func (f *Func) Idom() []*Block { |
| if f.cachedIdom == nil { |
| f.cachedIdom = dominators(f) |
| } |
| return f.cachedIdom |
| } |
|
|
| |
| |
| func (f *Func) Sdom() SparseTree { |
| if f.cachedSdom == nil { |
| f.cachedSdom = newSparseTree(f, f.Idom()) |
| } |
| return f.cachedSdom |
| } |
|
|
| |
| func (f *Func) loopnest() *loopnest { |
| if f.cachedLoopnest == nil { |
| f.cachedLoopnest = loopnestfor(f) |
| } |
| return f.cachedLoopnest |
| } |
|
|
| |
| func (f *Func) invalidateCFG() { |
| f.cachedPostorder = nil |
| f.cachedIdom = nil |
| f.cachedSdom = nil |
| f.cachedLoopnest = nil |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| func (f *Func) DebugHashMatch() bool { |
| if !base.HasDebugHash() { |
| return true |
| } |
| sym := f.fe.Func().Sym() |
| return base.DebugHashMatchPkgFunc(sym.Pkg.Path, sym.Name) |
| } |
|
|
| func (f *Func) spSb() (sp, sb *Value) { |
| initpos := src.NoXPos |
| for _, v := range f.Entry.Values { |
| if v.Op == OpSB { |
| sb = v |
| } |
| if v.Op == OpSP { |
| sp = v |
| } |
| if sb != nil && sp != nil { |
| return |
| } |
| } |
| if sb == nil { |
| sb = f.Entry.NewValue0(initpos.WithNotStmt(), OpSB, f.Config.Types.Uintptr) |
| } |
| if sp == nil { |
| sp = f.Entry.NewValue0(initpos.WithNotStmt(), OpSP, f.Config.Types.Uintptr) |
| } |
| return |
| } |
|
|
| |
| |
| func (f *Func) useFMA(v *Value) bool { |
| if base.FmaHash == nil { |
| return true |
| } |
| return base.FmaHash.MatchPos(v.Pos, nil) |
| } |
|
|
| |
| func (f *Func) NewLocal(pos src.XPos, typ *types.Type) *ir.Name { |
| nn := typecheck.TempAt(pos, f.fe.Func(), typ) |
| nn.SetNonMergeable(true) |
| return nn |
| } |
|
|
| |
| |
| |
| |
| |
| func IsMergeCandidate(n *ir.Name) bool { |
| if base.Debug.MergeLocals == 0 || |
| base.Flag.N != 0 || |
| n.Class != ir.PAUTO || |
| n.Type().Size() <= int64(3*types.PtrSize) || |
| n.Addrtaken() || |
| n.NonMergeable() || |
| n.OpenDeferSlot() { |
| return false |
| } |
| return true |
| } |
|
|