Commit graph

46130 commits

Author SHA1 Message Date
Russ Cox ead4957892 [dev.regabi] cmd/compile: move helpers into package base [generated]
[git-generate]
cd src/cmd/compile/internal/gc
rf '
	# Move EnableTrace constant into base, with the other flags.
	mv enableTrace EnableTrace
	mv EnableTrace base.go

	# Move compilation checks to base.
	mv instrumenting Instrumenting
	mv ispkgin Compiling
	mv omit_pkgs NoInstrumentPkgs
	mv norace_inst_pkgs NoRacePkgs
	mv Instrumenting Compiling NoInstrumentPkgs NoRacePkgs base.go

	# Move AutogeneratedPos to package base, next to Pos.
	mv autogeneratedPos AutogeneratedPos
	mv AutogeneratedPos print.go

	mv timings Timer

	mv base.go print.go timings.go cmd/compile/internal/base
'
cd ../base
rf '
	mv Instrumenting Flag.Cfg.Instrumenting
'

Change-Id: I534437fa75857d31531fc499d833c9930c0a06d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/279420
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:37:55 +00:00
Russ Cox 440308ffd7 [dev.regabi] cmd/compile: simplify Nodes usage [generated]
Now that Nodes is a slice, most of the methods can be removed
in favor of direct slice operations, reducing the new API that must
be understood to:

	Copy
	Take
	Append
	Prepend
	Format

Passes buildall w/ toolstash -cmp.

[git-generate]
cd src/cmd/compile/internal/ir
rf '
ex . ../gc {
	var ns Nodes
	var pns *Nodes
	var n, n2, n3 Node
	var i int
	var slice []Node

	ns.Len() -> len(ns)
	ns.Slice() -> ns
	ns.First() -> ns[0]
	ns.Second() -> ns[1]
	ns.Index(i) -> ns[i]
	ns.Addr(i) -> &ns[i]
	ns.SetIndex(i, n) -> ns[i] = n
	ns.SetFirst(n) -> ns[0] = n
	ns.SetSecond(n) -> ns[1] = n
	ns.Set1(n) -> ns = []Node{n}
	ns.Set2(n, n2) -> ns = []Node{n, n2}
	ns.Set3(n, n2, n3) -> ns = []Node{n, n2, n3}
	ns.Set1(n) -> ns = []Node{n}
	ns.Set2(n, n2) -> ns = []Node{n, n2}
	ns.Set3(n, n2, n3) -> ns = []Node{n, n2, n3}
	AsNodes(slice) -> Nodes(slice)
	ns.AppendNodes(pns) -> ns.Append(pns.Take()...)
	ns.MoveNodes(pns) -> ns = pns.Take()
}

rm \
	Nodes.Len Nodes.Slice \
	Nodes.First Nodes.Second Nodes.Index Nodes.Addr \
	Nodes.SetIndex Nodes.SetFirst Nodes.SetSecond \
	Nodes.Set1 Nodes.Set2 Nodes.Set3 \
	AsNodes \
	Nodes.AppendNodes Nodes.MoveNodes
'

Change-Id: Iee86434ced52e67861c3fa71bdd6d994a8cba735
Reviewed-on: https://go-review.googlesource.com/c/go/+/277936
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:37:48 +00:00
Russ Cox f9d373720e [dev.regabi] cmd/compile: remove Left, Right etc methods [generated]
Now that the generic graph structure methods - Left, Right, and so on -
have been removed from the Node interface, each implementation's uses
can be replaced with direct field access, using more specific names,
and the methods themselves can be deleted.

Passes buildall w/ toolstash -cmp.

[git-generate]

cd src/cmd/compile/internal/ir
rf '
	mv Func.iota Func.Iota_
	mv Name.fn Name.Func_
'

cd ../gc
rf '
ex . ../ir {
        import "cmd/compile/internal/ir"
        import "cmd/compile/internal/types"

        var ns ir.Nodes
        var b bool
        var i64 int64
        var n ir.Node
        var op ir.Op
        var sym *types.Sym
        var class ir.Class

        var decl *ir.Decl
        decl.Left()         -> decl.X
        decl.SetLeft(n)     -> decl.X = n

        var asl *ir.AssignListStmt
        asl.List()          -> asl.Lhs
        asl.PtrList()       -> &asl.Lhs
        asl.SetList(ns)     -> asl.Lhs = ns
        asl.Rlist()         -> asl.Rhs
        asl.PtrRlist()      -> &asl.Rhs
        asl.SetRlist(ns)    -> asl.Rhs = ns
        asl.Colas()         -> asl.Def
        asl.SetColas(b)     -> asl.Def = b

        var as *ir.AssignStmt
        as.Left()           -> as.X
        as.SetLeft(n)       -> as.X = n
        as.Right()          -> as.Y
        as.SetRight(n)      -> as.Y = n
        as.Colas()          -> as.Def
        as.SetColas(b)      -> as.Def = b

        var ao *ir.AssignOpStmt
        ao.Left()           -> ao.X
        ao.SetLeft(n)       -> ao.X = n
        ao.Right()          -> ao.Y
        ao.SetRight(n)      -> ao.Y = n
        ao.SubOp()          -> ao.AsOp
        ao.SetSubOp(op)     -> ao.AsOp = op
        ao.Implicit()       -> ao.IncDec
        ao.SetImplicit(b)   -> ao.IncDec = b

        var bl *ir.BlockStmt
        bl.List()           -> bl.List_
        bl.PtrList()        -> &bl.List_
        bl.SetList(ns)      -> bl.List_ = ns

        var br *ir.BranchStmt
        br.Sym()            -> br.Label
        br.SetSym(sym)      -> br.Label = sym

        var cas *ir.CaseStmt
        cas.List()          -> cas.List_
        cas.PtrList()       -> &cas.List_
        cas.SetList(ns)     -> cas.List_ = ns
        cas.Body()          -> cas.Body_
        cas.PtrBody()       -> &cas.Body_
        cas.SetBody(ns)     -> cas.Body_ = ns
        cas.Rlist()         -> cas.Vars
        cas.PtrRlist()      -> &cas.Vars
        cas.SetRlist(ns)    -> cas.Vars = ns
        cas.Left()          -> cas.Comm
        cas.SetLeft(n)      -> cas.Comm = n

        var fr *ir.ForStmt
        fr.Sym()            -> fr.Label
        fr.SetSym(sym)      -> fr.Label = sym
        fr.Left()           -> fr.Cond
        fr.SetLeft(n)       -> fr.Cond = n
        fr.Right()          -> fr.Post
        fr.SetRight(n)      -> fr.Post = n
        fr.Body()           -> fr.Body_
        fr.PtrBody()        -> &fr.Body_
        fr.SetBody(ns)      -> fr.Body_ = ns
        fr.List()           -> fr.Late
        fr.PtrList()        -> &fr.Late
        fr.SetList(ns)      -> fr.Late = ns
        fr.HasBreak()       -> fr.HasBreak_
        fr.SetHasBreak(b)   -> fr.HasBreak_ = b

        var gs *ir.GoDeferStmt
        gs.Left()           -> gs.Call
        gs.SetLeft(n)       -> gs.Call = n

        var ifs *ir.IfStmt
        ifs.Left()          -> ifs.Cond
        ifs.SetLeft(n)      -> ifs.Cond = n
        ifs.Body()          -> ifs.Body_
        ifs.PtrBody()       -> &ifs.Body_
        ifs.SetBody(ns)     -> ifs.Body_ = ns
        ifs.Rlist()         -> ifs.Else
        ifs.PtrRlist()      -> &ifs.Else
        ifs.SetRlist(ns)    -> ifs.Else = ns
        ifs.Likely()        -> ifs.Likely_
        ifs.SetLikely(b)    -> ifs.Likely_ = b

        var im *ir.InlineMarkStmt
        im.Offset()         -> im.Index
        im.SetOffset(i64)   -> im.Index = i64

        var lab *ir.LabelStmt
        lab.Sym()           -> lab.Label
        lab.SetSym(sym)     -> lab.Label = sym

        var rng *ir.RangeStmt
        rng.Sym()           -> rng.Label
        rng.SetSym(sym)     -> rng.Label = sym
        rng.Right()         -> rng.X
        rng.SetRight(n)     -> rng.X = n
        rng.Body()          -> rng.Body_
        rng.PtrBody()       -> &rng.Body_
        rng.SetBody(ns)     -> rng.Body_ = ns
        rng.List()          -> rng.Vars
        rng.PtrList()       -> &rng.Vars
        rng.SetList(ns)     -> rng.Vars = ns
        rng.HasBreak()      -> rng.HasBreak_
        rng.SetHasBreak(b)  -> rng.HasBreak_ = b
        rng.Colas()         -> rng.Def
        rng.SetColas(b)     -> rng.Def = b

        var ret *ir.ReturnStmt
        ret.List()          -> ret.Results
        ret.PtrList()       -> &ret.Results
        ret.SetList(ns)     -> ret.Results = ns

        var sel *ir.SelectStmt
        sel.List()          -> sel.Cases
        sel.PtrList()       -> &sel.Cases
        sel.SetList(ns)     -> sel.Cases = ns
        sel.Sym()           -> sel.Label
        sel.SetSym(sym)     -> sel.Label = sym
        sel.HasBreak()      -> sel.HasBreak_
        sel.SetHasBreak(b)  -> sel.HasBreak_ = b
        sel.Body()          -> sel.Compiled
        sel.PtrBody()       -> &sel.Compiled
        sel.SetBody(ns)     -> sel.Compiled = ns

        var send *ir.SendStmt
        send.Left()         -> send.Chan
        send.SetLeft(n)     -> send.Chan = n
        send.Right()        -> send.Value
        send.SetRight(n)    -> send.Value = n

        var sw *ir.SwitchStmt
        sw.Left()           -> sw.Tag
        sw.SetLeft(n)       -> sw.Tag = n
        sw.List()           -> sw.Cases
        sw.PtrList()        -> &sw.Cases
        sw.SetList(ns)      -> sw.Cases = ns
        sw.Body()           -> sw.Compiled
        sw.PtrBody()        -> &sw.Compiled
        sw.SetBody(ns)      -> sw.Compiled = ns
        sw.Sym()            -> sw.Label
        sw.SetSym(sym)      -> sw.Label = sym
        sw.HasBreak()       -> sw.HasBreak_
        sw.SetHasBreak(b)   -> sw.HasBreak_ = b

        var tg *ir.TypeSwitchGuard
        tg.Left()           -> tg.Tag
        tg.SetLeft(nil)     -> tg.Tag = nil
        tg.SetLeft(n)       -> tg.Tag = n.(*ir.Ident)
        tg.Right()          -> tg.X
        tg.SetRight(n)      -> tg.X = n

        var adds *ir.AddStringExpr
        adds.List()         -> adds.List_
        adds.PtrList()      -> &adds.List_
        adds.SetList(ns)    -> adds.List_ = ns

        var addr *ir.AddrExpr
        addr.Left()         -> addr.X
        addr.SetLeft(n)     -> addr.X = n
        addr.Right()        -> addr.Alloc
        addr.SetRight(n)    -> addr.Alloc = n

        var bin *ir.BinaryExpr
        bin.Left()          -> bin.X
        bin.SetLeft(n)      -> bin.X = n
        bin.Right()         -> bin.Y
        bin.SetRight(n)     -> bin.Y = n

        var log *ir.LogicalExpr
        log.Left()          -> log.X
        log.SetLeft(n)      -> log.X = n
        log.Right()         -> log.Y
        log.SetRight(n)     -> log.Y = n

        var call *ir.CallExpr
        call.Left()         -> call.X
        call.SetLeft(n)     -> call.X = n
        call.List()         -> call.Args
        call.PtrList()      -> &call.Args
        call.SetList(ns)    -> call.Args = ns
        call.Rlist()        -> call.Rargs
        call.PtrRlist()     -> &call.Rargs
        call.SetRlist(ns)   -> call.Rargs = ns
        call.IsDDD()        -> call.DDD
        call.SetIsDDD(b)    -> call.DDD = b
        call.NoInline()     -> call.NoInline_
        call.SetNoInline(b) -> call.NoInline_ = b
        call.Body()         -> call.Body_
        call.PtrBody()      -> &call.Body_
        call.SetBody(ns)    -> call.Body_ = ns

        var cp *ir.CallPartExpr
        cp.Func()           -> cp.Func_
        cp.Left()           -> cp.X
        cp.SetLeft(n)       -> cp.X = n
        cp.Sym()            -> cp.Method.Sym

        var clo *ir.ClosureExpr
        clo.Func()          -> clo.Func_

        var cr *ir.ClosureReadExpr
        cr.Offset()         -> cr.Offset_

        var cl *ir.CompLitExpr
        cl.Right()          -> cl.Ntype
        cl.SetRight(nil)    -> cl.Ntype = nil
        cl.SetRight(n)      -> cl.Ntype = ir.Node(n).(ir.Ntype)
        cl.List()           -> cl.List_
        cl.PtrList()        -> &cl.List_
        cl.SetList(ns)      -> cl.List_ = ns

        var conv *ir.ConvExpr
        conv.Left()         -> conv.X
        conv.SetLeft(n)     -> conv.X = n

        var ix *ir.IndexExpr
        ix.Left()           -> ix.X
        ix.SetLeft(n)       -> ix.X = n
        ix.Right()          -> ix.Index
        ix.SetRight(n)      -> ix.Index = n
        ix.IndexMapLValue() -> ix.Assigned
        ix.SetIndexMapLValue(b) -> ix.Assigned = b

        var kv *ir.KeyExpr
        kv.Left()           -> kv.Key
        kv.SetLeft(n)       -> kv.Key = n
        kv.Right()          -> kv.Value
        kv.SetRight(n)      -> kv.Value = n

        var sk *ir.StructKeyExpr
        sk.Sym()            -> sk.Field
        sk.SetSym(sym)      -> sk.Field = sym
        sk.Left()           -> sk.Value
        sk.SetLeft(n)       -> sk.Value = n
        sk.Offset()         -> sk.Offset_
        sk.SetOffset(i64)   -> sk.Offset_ = i64

        var ic *ir.InlinedCallExpr
        ic.Body()           -> ic.Body_
        ic.PtrBody()        -> &ic.Body_
        ic.SetBody(ns)      -> ic.Body_ = ns
        ic.Rlist()          -> ic.ReturnVars
        ic.PtrRlist()       -> &ic.ReturnVars
        ic.SetRlist(ns)     -> ic.ReturnVars = ns

        var mak *ir.MakeExpr
        mak.Left()          -> mak.Len
        mak.SetLeft(n)      -> mak.Len = n
        mak.Right()         -> mak.Cap
        mak.SetRight(n)     -> mak.Cap = n

        var par *ir.ParenExpr
        par.Left()          -> par.X
        par.SetLeft(n)      -> par.X = n

        var res *ir.ResultExpr
        res.Offset()        -> res.Offset_
        res.SetOffset(i64)  -> res.Offset_ = i64

        var dot *ir.SelectorExpr
        dot.Left()          -> dot.X
        dot.SetLeft(n)      -> dot.X = n
        dot.Sym()           -> dot.Sel
        dot.SetSym(sym)     -> dot.Sel = sym
        dot.Offset()        -> dot.Offset_
        dot.SetOffset(i64)  -> dot.Offset_ = i64

        var sl *ir.SliceExpr
        sl.Left()           -> sl.X
        sl.SetLeft(n)       -> sl.X = n
        sl.List()           -> sl.List_
        sl.PtrList()        -> &sl.List_
        sl.SetList(ns)      -> sl.List_ = ns

        var sh *ir.SliceHeaderExpr
        sh.Left()           -> sh.Ptr
        sh.SetLeft(n)       -> sh.Ptr = n
        sh.List()           -> sh.LenCap_
        sh.PtrList()        -> &sh.LenCap_
        sh.SetList(ns)      -> sh.LenCap_ = ns

        var st *ir.StarExpr
        st.Left()           -> st.X
        st.SetLeft(n)       -> st.X = n

        var ta *ir.TypeAssertExpr
        ta.Left()           -> ta.X
        ta.SetLeft(n)       -> ta.X = n
        ta.Right()          -> ta.Ntype
        ta.SetRight(n)    -> ta.Ntype = n
        ta.List()           -> ta.Itab
        ta.PtrList()        -> &ta.Itab
        ta.SetList(ns)      -> ta.Itab = ns

        var u *ir.UnaryExpr
        u.Left()            -> u.X
        u.SetLeft(n)        -> u.X = n

        var fn *ir.Func
        fn.Body()           -> fn.Body_
        fn.PtrBody()        -> &fn.Body_
        fn.SetBody(ns)      -> fn.Body_ = ns
        fn.Iota()           -> fn.Iota_
        fn.SetIota(i64)     -> fn.Iota_ = i64
        fn.Func()           -> fn

        var nam *ir.Name
        nam.SubOp()         -> nam.BuiltinOp
        nam.SetSubOp(op)    -> nam.BuiltinOp = op
        nam.Class()         -> nam.Class_
        nam.SetClass(class) -> nam.Class_ = class
        nam.Func()          -> nam.Func_
        nam.Offset()        -> nam.Offset_
        nam.SetOffset(i64)  -> nam.Offset_ = i64
}

ex . ../ir {
        import "cmd/compile/internal/ir"

        var n ir.Nodes

        (&n).Append         -> n.Append
        (&n).AppendNodes    -> n.AppendNodes
        (&n).MoveNodes      -> n.MoveNodes
        (&n).Prepend        -> n.Prepend
        (&n).Set            -> n.Set
        (&n).Set1           -> n.Set1
        (&n).Set2           -> n.Set2
        (&n).Set3           -> n.Set3

        var ntype ir.Ntype
        ir.Node(ntype).(ir.Ntype) -> ntype
}
'

cd ../ir
rf '
rm \
        Decl.Left Decl.SetLeft \
        AssignListStmt.List AssignListStmt.PtrList AssignListStmt.SetList \
        AssignListStmt.Rlist AssignListStmt.PtrRlist AssignListStmt.SetRlist \
        AssignListStmt.Colas AssignListStmt.SetColas \
        AssignStmt.Left AssignStmt.SetLeft \
        AssignStmt.Right AssignStmt.SetRight \
        AssignStmt.Colas AssignStmt.SetColas \
        AssignOpStmt.Left AssignOpStmt.SetLeft \
        AssignOpStmt.Right AssignOpStmt.SetRight \
        AssignOpStmt.SubOp AssignOpStmt.SetSubOp \
        AssignOpStmt.Implicit AssignOpStmt.SetImplicit \
        BlockStmt.List BlockStmt.PtrList BlockStmt.SetList \
        BranchStmt.SetSym \
        CaseStmt.List CaseStmt.PtrList CaseStmt.SetList \
        CaseStmt.Body CaseStmt.PtrBody CaseStmt.SetBody \
        CaseStmt.Rlist CaseStmt.PtrRlist CaseStmt.SetRlist \
        CaseStmt.Left CaseStmt.SetLeft \
        ForStmt.Left ForStmt.SetLeft \
        ForStmt.Right ForStmt.SetRight \
        ForStmt.Body ForStmt.PtrBody ForStmt.SetBody \
        ForStmt.List ForStmt.PtrList ForStmt.SetList \
        ForStmt.HasBreak ForStmt.SetHasBreak \
        ForStmt.Sym ForStmt.SetSym \
        GoDeferStmt.Left GoDeferStmt.SetLeft \
        IfStmt.Left IfStmt.SetLeft \
        IfStmt.Body IfStmt.PtrBody IfStmt.SetBody \
        IfStmt.Rlist IfStmt.PtrRlist IfStmt.SetRlist \
        IfStmt.Likely IfStmt.SetLikely \
        LabelStmt.SetSym \
        RangeStmt.Right RangeStmt.SetRight \
        RangeStmt.Body RangeStmt.PtrBody RangeStmt.SetBody \
        RangeStmt.List RangeStmt.PtrList RangeStmt.SetList \
        RangeStmt.HasBreak RangeStmt.SetHasBreak \
        RangeStmt.Colas RangeStmt.SetColas \
        RangeStmt.Sym RangeStmt.SetSym \
        ReturnStmt.List ReturnStmt.PtrList ReturnStmt.SetList \
        SelectStmt.List SelectStmt.PtrList SelectStmt.SetList \
        SelectStmt.HasBreak SelectStmt.SetHasBreak \
        SelectStmt.Body SelectStmt.PtrBody SelectStmt.SetBody \
        SelectStmt.Sym SelectStmt.SetSym \
        SendStmt.Left SendStmt.SetLeft \
        SendStmt.Right SendStmt.SetRight \
        SwitchStmt.Left SwitchStmt.SetLeft \
        SwitchStmt.List SwitchStmt.PtrList SwitchStmt.SetList \
        SwitchStmt.Body SwitchStmt.PtrBody SwitchStmt.SetBody \
        SwitchStmt.HasBreak SwitchStmt.SetHasBreak \
        SwitchStmt.Sym SwitchStmt.SetSym \
        TypeSwitchGuard.Left TypeSwitchGuard.SetLeft \
        TypeSwitchGuard.Right TypeSwitchGuard.SetRight \
        AddStringExpr.List AddStringExpr.PtrList AddStringExpr.SetList \
        AddrExpr.Left AddrExpr.SetLeft \
        AddrExpr.Right AddrExpr.SetRight \
        BinaryExpr.Left BinaryExpr.SetLeft \
        BinaryExpr.Right BinaryExpr.SetRight \
        LogicalExpr.Left LogicalExpr.SetLeft \
        LogicalExpr.Right LogicalExpr.SetRight \
        CallExpr.Left CallExpr.SetLeft \
        CallExpr.List CallExpr.PtrList CallExpr.SetList \
        CallExpr.Rlist CallExpr.PtrRlist CallExpr.SetRlist \
        CallExpr.NoInline CallExpr.SetNoInline \
        CallExpr.Body CallExpr.PtrBody CallExpr.SetBody \
        CallExpr.IsDDD CallExpr.SetIsDDD \
        CallPartExpr.Left CallPartExpr.SetLeft \
        ClosureReadExpr.Offset \
        ClosureReadExpr.Type \ # provided by miniExpr already
        CompLitExpr.Right CompLitExpr.SetRight \
        CompLitExpr.List CompLitExpr.PtrList CompLitExpr.SetList \
        ConvExpr.Left ConvExpr.SetLeft \
        IndexExpr.Left IndexExpr.SetLeft \
        IndexExpr.Right IndexExpr.SetRight \
        IndexExpr.IndexMapLValue IndexExpr.SetIndexMapLValue \
        KeyExpr.Left KeyExpr.SetLeft \
        KeyExpr.Right KeyExpr.SetRight \
        StructKeyExpr.Left StructKeyExpr.SetLeft \
        StructKeyExpr.Offset StructKeyExpr.SetOffset \
        StructKeyExpr.SetSym \
        InlinedCallExpr.Body InlinedCallExpr.PtrBody InlinedCallExpr.SetBody \
        InlinedCallExpr.Rlist InlinedCallExpr.PtrRlist InlinedCallExpr.SetRlist \
        MakeExpr.Left MakeExpr.SetLeft \
        MakeExpr.Right MakeExpr.SetRight \
        MethodExpr.Left MethodExpr.SetLeft \
        MethodExpr.Right MethodExpr.SetRight \
        MethodExpr.Offset MethodExpr.SetOffset \
        MethodExpr.Class MethodExpr.SetClass \
        ParenExpr.Left ParenExpr.SetLeft \
        ResultExpr.Offset ResultExpr.SetOffset \
        ReturnStmt.IsDDD \
        SelectorExpr.Left SelectorExpr.SetLeft \
        SelectorExpr.Offset SelectorExpr.SetOffset \
        SelectorExpr.SetSym \
        SliceExpr.Left SliceExpr.SetLeft \
        SliceExpr.List SliceExpr.PtrList SliceExpr.SetList \
        SliceHeaderExpr.Left SliceHeaderExpr.SetLeft \
        SliceHeaderExpr.List SliceHeaderExpr.PtrList SliceHeaderExpr.SetList \
        StarExpr.Left StarExpr.SetLeft \
        TypeAssertExpr.Left TypeAssertExpr.SetLeft \
        TypeAssertExpr.Right TypeAssertExpr.SetRight \
        TypeAssertExpr.List TypeAssertExpr.PtrList TypeAssertExpr.SetList \
        UnaryExpr.Left UnaryExpr.SetLeft \
        Func.Body Func.PtrBody Func.SetBody \
        Func.Iota Func.SetIota \
        CallPartExpr.Func ClosureExpr.Func Func.Func Name.Func \

mv BlockStmt.List_ BlockStmt.List
mv CaseStmt.List_ CaseStmt.List
mv CaseStmt.Body_ CaseStmt.Body
mv ForStmt.Body_ ForStmt.Body
mv ForStmt.HasBreak_ ForStmt.HasBreak
mv Func.Iota_ Func.Iota
mv IfStmt.Body_ IfStmt.Body
mv IfStmt.Likely_ IfStmt.Likely
mv RangeStmt.Body_ RangeStmt.Body
mv RangeStmt.HasBreak_ RangeStmt.HasBreak
mv SelectStmt.HasBreak_ SelectStmt.HasBreak
mv SwitchStmt.HasBreak_ SwitchStmt.HasBreak
mv AddStringExpr.List_ AddStringExpr.List
mv CallExpr.NoInline_ CallExpr.NoInline
mv CallExpr.Body_ CallExpr.Body # TODO what is this?
mv CallExpr.DDD CallExpr.IsDDD
mv ClosureReadExpr.Offset_ ClosureReadExpr.Offset
mv CompLitExpr.List_ CompLitExpr.List
mv StructKeyExpr.Offset_ StructKeyExpr.Offset
mv InlinedCallExpr.Body_ InlinedCallExpr.Body
mv ResultExpr.Offset_ ResultExpr.Offset
mv SelectorExpr.Offset_ SelectorExpr.Offset
mv SliceExpr.List_ SliceExpr.List
mv SliceHeaderExpr.LenCap_ SliceHeaderExpr.LenCap
mv Func.Body_ Func.Body
mv CallPartExpr.Func_ CallPartExpr.Func
mv ClosureExpr.Func_ ClosureExpr.Func
mv Name.Func_ Name.Func
'

Change-Id: Ia2ee59649674f83eb123e63fda7a7781cf91cc56
Reviewed-on: https://go-review.googlesource.com/c/go/+/277935
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:37:41 +00:00
Russ Cox 14d667341f [dev.regabi] cmd/compile: remove Node.Left etc [generated]
This automated CL adds type assertions on the true branches of
n.Op() equality tests, to redeclare n with a more specific type, when
it is safe to do so. (That is, when n is not reassigned with a more
general type, when n is not reassigned and then used outside the
scope, and so on.) All the "unsafe" times that the automated tool
would avoid have been removed or rewritten in earlier CLs, so that
after this CL and the next one, which removes the use of ir.Nod,
every use of the Left, Right, and so on methods is done using concrete
types, never the Node interface.

Having done that, the CL locks in the progress by deleting many of
the access methods, including Left, SetLeft and so on, from the
Node interface.

There are still uses of Name, Func, Sym, some of the tracking
bits, and a few other miscellaneous fields, but all the main access
methods are gone from the Node interface. The others will be cleaned
up in smaller CLs.

Passes buildall w/ toolstash -cmp.

[git-generate]
cd src/cmd/compile/internal/gc
rf 'typeassert {
        import "cmd/compile/internal/ir"
        var n ir.Node

        n.Op() == ir.OADD -> n.(*ir.BinaryExpr)
        n.Op() == ir.OADDR -> n.(*ir.AddrExpr)
        n.Op() == ir.OADDSTR -> n.(*ir.AddStringExpr)
        n.Op() == ir.OALIGNOF -> n.(*ir.UnaryExpr)
        n.Op() == ir.OAND -> n.(*ir.BinaryExpr)
        n.Op() == ir.OANDAND -> n.(*ir.LogicalExpr)
        n.Op() == ir.OANDNOT -> n.(*ir.BinaryExpr)
        n.Op() == ir.OAPPEND -> n.(*ir.CallExpr)
        n.Op() == ir.OARRAYLIT -> n.(*ir.CompLitExpr)
        n.Op() == ir.OAS -> n.(*ir.AssignStmt)
        n.Op() == ir.OAS2 -> n.(*ir.AssignListStmt)
        n.Op() == ir.OAS2DOTTYPE -> n.(*ir.AssignListStmt)
        n.Op() == ir.OAS2FUNC -> n.(*ir.AssignListStmt)
        n.Op() == ir.OAS2MAPR -> n.(*ir.AssignListStmt)
        n.Op() == ir.OAS2RECV -> n.(*ir.AssignListStmt)
        n.Op() == ir.OASOP -> n.(*ir.AssignOpStmt)
        n.Op() == ir.OBITNOT -> n.(*ir.UnaryExpr)
        n.Op() == ir.OBLOCK -> n.(*ir.BlockStmt)
        n.Op() == ir.OBREAK -> n.(*ir.BranchStmt)
        n.Op() == ir.OBYTES2STR -> n.(*ir.ConvExpr)
        n.Op() == ir.OBYTES2STRTMP -> n.(*ir.ConvExpr)
        n.Op() == ir.OCALL -> n.(*ir.CallExpr)
        n.Op() == ir.OCALLFUNC -> n.(*ir.CallExpr)
        n.Op() == ir.OCALLINTER -> n.(*ir.CallExpr)
        n.Op() == ir.OCALLMETH -> n.(*ir.CallExpr)
        n.Op() == ir.OCALLPART -> n.(*ir.CallPartExpr)
        n.Op() == ir.OCAP -> n.(*ir.UnaryExpr)
        n.Op() == ir.OCASE -> n.(*ir.CaseStmt)
        n.Op() == ir.OCFUNC -> n.(*ir.UnaryExpr)
        n.Op() == ir.OCHECKNIL -> n.(*ir.UnaryExpr)
        n.Op() == ir.OCLOSE -> n.(*ir.UnaryExpr)
        n.Op() == ir.OCOMPLEX -> n.(*ir.BinaryExpr)
        n.Op() == ir.OCOMPLIT -> n.(*ir.CompLitExpr)
        n.Op() == ir.OCONTINUE -> n.(*ir.BranchStmt)
        n.Op() == ir.OCONV -> n.(*ir.ConvExpr)
        n.Op() == ir.OCONVIFACE -> n.(*ir.ConvExpr)
        n.Op() == ir.OCONVNOP -> n.(*ir.ConvExpr)
        n.Op() == ir.OCOPY -> n.(*ir.BinaryExpr)
        n.Op() == ir.ODCL -> n.(*ir.Decl)
        n.Op() == ir.ODCLCONST -> n.(*ir.Decl)
        n.Op() == ir.ODCLFUNC -> n.(*ir.Func)
        n.Op() == ir.ODCLTYPE -> n.(*ir.Decl)
        n.Op() == ir.ODEFER -> n.(*ir.GoDeferStmt)
        n.Op() == ir.ODELETE -> n.(*ir.CallExpr)
        n.Op() == ir.ODEREF -> n.(*ir.StarExpr)
        n.Op() == ir.ODIV -> n.(*ir.BinaryExpr)
        n.Op() == ir.ODOT -> n.(*ir.SelectorExpr)
        n.Op() == ir.ODOTINTER -> n.(*ir.SelectorExpr)
        n.Op() == ir.ODOTMETH -> n.(*ir.SelectorExpr)
        n.Op() == ir.ODOTPTR -> n.(*ir.SelectorExpr)
        n.Op() == ir.ODOTTYPE -> n.(*ir.TypeAssertExpr)
        n.Op() == ir.ODOTTYPE2 -> n.(*ir.TypeAssertExpr)
        n.Op() == ir.OEFACE -> n.(*ir.BinaryExpr)
        n.Op() == ir.OEQ -> n.(*ir.BinaryExpr)
        n.Op() == ir.OFALL -> n.(*ir.BranchStmt)
        n.Op() == ir.OFOR -> n.(*ir.ForStmt)
        n.Op() == ir.OFORUNTIL -> n.(*ir.ForStmt)
        n.Op() == ir.OGE -> n.(*ir.BinaryExpr)
        n.Op() == ir.OGETG -> n.(*ir.CallExpr)
        n.Op() == ir.OGO -> n.(*ir.GoDeferStmt)
        n.Op() == ir.OGOTO -> n.(*ir.BranchStmt)
        n.Op() == ir.OGT -> n.(*ir.BinaryExpr)
        n.Op() == ir.OIDATA -> n.(*ir.UnaryExpr)
        n.Op() == ir.OIF -> n.(*ir.IfStmt)
        n.Op() == ir.OIMAG -> n.(*ir.UnaryExpr)
        n.Op() == ir.OINDEX -> n.(*ir.IndexExpr)
        n.Op() == ir.OINDEXMAP -> n.(*ir.IndexExpr)
        n.Op() == ir.OINLCALL -> n.(*ir.InlinedCallExpr)
        n.Op() == ir.OINLMARK -> n.(*ir.InlineMarkStmt)
        n.Op() == ir.OITAB -> n.(*ir.UnaryExpr)
        n.Op() == ir.OKEY -> n.(*ir.KeyExpr)
        n.Op() == ir.OLABEL -> n.(*ir.LabelStmt)
        n.Op() == ir.OLE -> n.(*ir.BinaryExpr)
        n.Op() == ir.OLEN -> n.(*ir.UnaryExpr)
        n.Op() == ir.OLSH -> n.(*ir.BinaryExpr)
        n.Op() == ir.OLT -> n.(*ir.BinaryExpr)
        n.Op() == ir.OMAKE -> n.(*ir.CallExpr)
        n.Op() == ir.OMAKECHAN -> n.(*ir.MakeExpr)
        n.Op() == ir.OMAKEMAP -> n.(*ir.MakeExpr)
        n.Op() == ir.OMAKESLICE -> n.(*ir.MakeExpr)
        n.Op() == ir.OMAKESLICECOPY -> n.(*ir.MakeExpr)
        n.Op() == ir.OMAPLIT -> n.(*ir.CompLitExpr)
        n.Op() == ir.OMETHEXPR -> n.(*ir.MethodExpr)
        n.Op() == ir.OMOD -> n.(*ir.BinaryExpr)
        n.Op() == ir.OMUL -> n.(*ir.BinaryExpr)
        n.Op() == ir.ONAME -> n.(*ir.Name)
        n.Op() == ir.ONE -> n.(*ir.BinaryExpr)
        n.Op() == ir.ONEG -> n.(*ir.UnaryExpr)
        n.Op() == ir.ONEW -> n.(*ir.UnaryExpr)
        n.Op() == ir.ONEWOBJ -> n.(*ir.UnaryExpr)
        n.Op() == ir.ONIL -> n.(*ir.NilExpr)
        n.Op() == ir.ONOT -> n.(*ir.UnaryExpr)
        n.Op() == ir.OOFFSETOF -> n.(*ir.UnaryExpr)
        n.Op() == ir.OOR -> n.(*ir.BinaryExpr)
        n.Op() == ir.OOROR -> n.(*ir.LogicalExpr)
        n.Op() == ir.OPACK -> n.(*ir.PkgName)
        n.Op() == ir.OPANIC -> n.(*ir.UnaryExpr)
        n.Op() == ir.OPAREN -> n.(*ir.ParenExpr)
        n.Op() == ir.OPLUS -> n.(*ir.UnaryExpr)
        n.Op() == ir.OPRINT -> n.(*ir.CallExpr)
        n.Op() == ir.OPRINTN -> n.(*ir.CallExpr)
        n.Op() == ir.OPTRLIT -> n.(*ir.AddrExpr)
        n.Op() == ir.ORANGE -> n.(*ir.RangeStmt)
        n.Op() == ir.OREAL -> n.(*ir.UnaryExpr)
        n.Op() == ir.ORECOVER -> n.(*ir.CallExpr)
        n.Op() == ir.ORECV -> n.(*ir.UnaryExpr)
        n.Op() == ir.ORESULT -> n.(*ir.ResultExpr)
        n.Op() == ir.ORETJMP -> n.(*ir.BranchStmt)
        n.Op() == ir.ORETURN -> n.(*ir.ReturnStmt)
        n.Op() == ir.ORSH -> n.(*ir.BinaryExpr)
        n.Op() == ir.ORUNES2STR -> n.(*ir.ConvExpr)
        n.Op() == ir.ORUNESTR -> n.(*ir.ConvExpr)
        n.Op() == ir.OSELECT -> n.(*ir.SelectStmt)
        n.Op() == ir.OSELRECV2 -> n.(*ir.AssignListStmt)
        n.Op() == ir.OSEND -> n.(*ir.SendStmt)
        n.Op() == ir.OSIZEOF -> n.(*ir.UnaryExpr)
        n.Op() == ir.OSLICE -> n.(*ir.SliceExpr)
        n.Op() == ir.OSLICE3 -> n.(*ir.SliceExpr)
        n.Op() == ir.OSLICE3ARR -> n.(*ir.SliceExpr)
        n.Op() == ir.OSLICEARR -> n.(*ir.SliceExpr)
        n.Op() == ir.OSLICEHEADER -> n.(*ir.SliceHeaderExpr)
        n.Op() == ir.OSLICELIT -> n.(*ir.CompLitExpr)
        n.Op() == ir.OSLICESTR -> n.(*ir.SliceExpr)
        n.Op() == ir.OSPTR -> n.(*ir.UnaryExpr)
        n.Op() == ir.OSTR2BYTES -> n.(*ir.ConvExpr)
        n.Op() == ir.OSTR2BYTESTMP -> n.(*ir.ConvExpr)
        n.Op() == ir.OSTR2RUNES -> n.(*ir.ConvExpr)
        n.Op() == ir.OSTRUCTLIT -> n.(*ir.CompLitExpr)
        n.Op() == ir.OSUB -> n.(*ir.BinaryExpr)
        n.Op() == ir.OSWITCH -> n.(*ir.SwitchStmt)
        n.Op() == ir.OTYPESW -> n.(*ir.TypeSwitchGuard)
        n.Op() == ir.OVARDEF -> n.(*ir.UnaryExpr)
        n.Op() == ir.OVARKILL -> n.(*ir.UnaryExpr)
        n.Op() == ir.OVARLIVE -> n.(*ir.UnaryExpr)
        n.Op() == ir.OXDOT -> n.(*ir.SelectorExpr)
        n.Op() == ir.OXOR -> n.(*ir.BinaryExpr)
}
'

cd ../ir
rf '
        rm \
                Node.SetOp \
                miniNode.SetOp \
                Node.Func \
                miniNode.Func \
                Node.Left Node.SetLeft \
                miniNode.Left miniNode.SetLeft \
                Node.Right Node.SetRight \
                miniNode.Right miniNode.SetRight \
                Node.List Node.PtrList Node.SetList \
                miniNode.List miniNode.PtrList miniNode.SetList \
                Node.Rlist Node.PtrRlist Node.SetRlist \
                miniNode.Rlist miniNode.PtrRlist miniNode.SetRlist \
                Node.Body Node.PtrBody Node.SetBody \
                miniNode.Body miniNode.PtrBody miniNode.SetBody \
                Node.SubOp Node.SetSubOp \
                miniNode.SubOp miniNode.SetSubOp \
                Node.SetSym \
                miniNode.SetSym \
                Node.Offset Node.SetOffset \
                miniNode.Offset miniNode.SetOffset \
                Node.Class Node.SetClass \
                miniNode.Class miniNode.SetClass \
                Node.Iota Node.SetIota \
                miniNode.Iota miniNode.SetIota \
                Node.Colas Node.SetColas \
                miniNode.Colas miniNode.SetColas \
                Node.Transient Node.SetTransient \
                miniNode.Transient miniNode.SetTransient \
                Node.Implicit Node.SetImplicit \
                miniNode.Implicit miniNode.SetImplicit \
                Node.IsDDD Node.SetIsDDD \
                miniNode.IsDDD miniNode.SetIsDDD \
                Node.MarkReadonly \
                miniNode.MarkReadonly \
                Node.Likely Node.SetLikely \
                miniNode.Likely miniNode.SetLikely \
                Node.SliceBounds Node.SetSliceBounds \
                miniNode.SliceBounds miniNode.SetSliceBounds \
                Node.NoInline Node.SetNoInline \
                miniNode.NoInline miniNode.SetNoInline \
                Node.IndexMapLValue Node.SetIndexMapLValue \
                miniNode.IndexMapLValue miniNode.SetIndexMapLValue \
                Node.ResetAux \
                miniNode.ResetAux \
                Node.HasBreak Node.SetHasBreak \
                miniNode.HasBreak miniNode.SetHasBreak \
                Node.Bounded Node.SetBounded \
                miniNode.Bounded miniNode.SetBounded \
                miniNode.Embedded miniNode.SetEmbedded \
                miniNode.Int64Val miniNode.Uint64Val miniNode.CanInt64 \
                miniNode.BoolVal miniNode.StringVal \
                miniNode.TChanDir miniNode.SetTChanDir \
                miniNode.Format \
                miniNode.copy miniNode.doChildren miniNode.editChildren \

'

Change-Id: I2a05b535963b43f83b1849fcf653f82b99af6035
Reviewed-on: https://go-review.googlesource.com/c/go/+/277934
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:37:34 +00:00
Russ Cox 6f27d29be0 [dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.

Passes buildall w/ toolstash -cmp.

[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
	import "cmd/compile/internal/ir"
	import "cmd/compile/internal/types"
	import "cmd/compile/internal/syntax"
	import "cmd/internal/src"

	var p *noder
	var orig syntax.Node
	var op ir.Op
	var l, r ir.Node
	var sym *types.Sym
	p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
	p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)

	var xpos src.XPos
	var ns ir.Nodes
	npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
	npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
	import "cmd/compile/internal/base"
	import "cmd/compile/internal/ir"
	import "cmd/compile/internal/types"

	var op ir.Op
	var l, r ir.Node
	ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)

	var sym *types.Sym
	nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
	import "cmd/compile/internal/ir"
	import "cmd/internal/src"

	# rf overlapping match handling is not quite good enough
	# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
	var l, r ir.Node
	var xpos src.XPos
	ir.NodAt(xpos, ir.OAS, l, r)              -> ir.NewAssignStmt(xpos, l, r)
	ir.NodAt(xpos, ir.OIF, l, nil)            -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
	import "cmd/compile/internal/ir"
	import "cmd/compile/internal/types"
	import "cmd/internal/src"

	var l, r ir.Node
	var sym *types.Sym
	var xpos src.XPos

	nodlSym(xpos, ir.ODOT, l, sym)                   -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
	nodlSym(xpos, ir.OXDOT, l, sym)                  -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
	nodlSym(xpos, ir.ODOTPTR, l, sym)                -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
	nodlSym(xpos, ir.OGOTO, nil, sym)                -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
	nodlSym(xpos, ir.ORETJMP, nil, sym)              -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
	nodlSym(xpos, ir.OLABEL, nil, sym)               -> ir.NewLabelStmt(xpos, sym)
	nodlSym(xpos, ir.OSTRUCTKEY, l, sym)             -> ir.NewStructKeyExpr(xpos, sym, l)

	ir.NodAt(xpos, ir.OADD, l, r)             -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
	ir.NodAt(xpos, ir.OAND, l, r)             -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
	ir.NodAt(xpos, ir.OANDNOT, l, r)          -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
	ir.NodAt(xpos, ir.ODIV, l, r)             -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
	ir.NodAt(xpos, ir.OEQ, l, r)              -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
	ir.NodAt(xpos, ir.OGE, l, r)              -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
	ir.NodAt(xpos, ir.OGT, l, r)              -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
	ir.NodAt(xpos, ir.OLE, l, r)              -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
	ir.NodAt(xpos, ir.OLSH, l, r)             -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
	ir.NodAt(xpos, ir.OLT, l, r)              -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
	ir.NodAt(xpos, ir.OMOD, l, r)             -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
	ir.NodAt(xpos, ir.OMUL, l, r)             -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
	ir.NodAt(xpos, ir.ONE, l, r)              -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
	ir.NodAt(xpos, ir.OOR, l, r)              -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
	ir.NodAt(xpos, ir.ORSH, l, r)             -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
	ir.NodAt(xpos, ir.OSUB, l, r)             -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
	ir.NodAt(xpos, ir.OXOR, l, r)             -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
	ir.NodAt(xpos, ir.OCOPY, l, r)            -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
	ir.NodAt(xpos, ir.OCOMPLEX, l, r)         -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
	ir.NodAt(xpos, ir.OEFACE, l, r)           -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
	ir.NodAt(xpos, ir.OADDR, l, nil)          -> ir.NewAddrExpr(xpos, l)
	ir.NodAt(xpos, ir.OADDSTR, nil, nil)      -> ir.NewAddStringExpr(xpos, nil)
	ir.NodAt(xpos, ir.OANDAND, l, r)          -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
	ir.NodAt(xpos, ir.OOROR, l, r)            -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
	ir.NodAt(xpos, ir.OARRAYLIT, nil, nil)    -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
	ir.NodAt(xpos, ir.OCOMPLIT, nil, nil)     -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
	ir.NodAt(xpos, ir.OMAPLIT, nil, nil)      -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
	ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil)   -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
	ir.NodAt(xpos, ir.OSLICELIT, nil, nil)    -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
	ir.NodAt(xpos, ir.OARRAYLIT, nil, r)      -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
	ir.NodAt(xpos, ir.OCOMPLIT, nil, r)       -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
	ir.NodAt(xpos, ir.OMAPLIT, nil, r)        -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
	ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r)     -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
	ir.NodAt(xpos, ir.OSLICELIT, nil, r)      -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
	ir.NodAt(xpos, ir.OAS2, nil, nil)         -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
	ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil)  -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
	ir.NodAt(xpos, ir.OAS2FUNC, nil, nil)     -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
	ir.NodAt(xpos, ir.OAS2MAPR, nil, nil)     -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
	ir.NodAt(xpos, ir.OAS2RECV, nil, nil)     -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
	ir.NodAt(xpos, ir.OSELRECV2, nil, nil)    -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
	ir.NodAt(xpos, ir.OASOP, l, r)            -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
	ir.NodAt(xpos, ir.OBITNOT, l, nil)        -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
	ir.NodAt(xpos, ir.ONEG, l, nil)           -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
	ir.NodAt(xpos, ir.ONOT, l, nil)           -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
	ir.NodAt(xpos, ir.OPLUS, l, nil)          -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
	ir.NodAt(xpos, ir.ORECV, l, nil)          -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
	ir.NodAt(xpos, ir.OALIGNOF, l, nil)       -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
	ir.NodAt(xpos, ir.OCAP, l, nil)           -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
	ir.NodAt(xpos, ir.OCLOSE, l, nil)         -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
	ir.NodAt(xpos, ir.OIMAG, l, nil)          -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
	ir.NodAt(xpos, ir.OLEN, l, nil)           -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
	ir.NodAt(xpos, ir.ONEW, l, nil)           -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
	ir.NodAt(xpos, ir.ONEWOBJ, l, nil)        -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
	ir.NodAt(xpos, ir.OOFFSETOF, l, nil)      -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
	ir.NodAt(xpos, ir.OPANIC, l, nil)         -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
	ir.NodAt(xpos, ir.OREAL, l, nil)          -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
	ir.NodAt(xpos, ir.OSIZEOF, l, nil)        -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
	ir.NodAt(xpos, ir.OCHECKNIL, l, nil)      -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
	ir.NodAt(xpos, ir.OCFUNC, l, nil)         -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
	ir.NodAt(xpos, ir.OIDATA, l, nil)         -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
	ir.NodAt(xpos, ir.OITAB, l, nil)          -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
	ir.NodAt(xpos, ir.OSPTR, l, nil)          -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
	ir.NodAt(xpos, ir.OVARDEF, l, nil)        -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
	ir.NodAt(xpos, ir.OVARKILL, l, nil)       -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
	ir.NodAt(xpos, ir.OVARLIVE, l, nil)       -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
	ir.NodAt(xpos, ir.OBLOCK, nil, nil)       -> ir.NewBlockStmt(xpos, nil)
	ir.NodAt(xpos, ir.OBREAK, nil, nil)       -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
	ir.NodAt(xpos, ir.OCONTINUE, nil, nil)    -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
	ir.NodAt(xpos, ir.OFALL, nil, nil)        -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
	ir.NodAt(xpos, ir.OGOTO, nil, nil)        -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
	ir.NodAt(xpos, ir.ORETJMP, nil, nil)      -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
	ir.NodAt(xpos, ir.OCALL, l, nil)          -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
	ir.NodAt(xpos, ir.OCALLFUNC, l, nil)      -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
	ir.NodAt(xpos, ir.OCALLINTER, l, nil)     -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
	ir.NodAt(xpos, ir.OCALLMETH, l, nil)      -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
	ir.NodAt(xpos, ir.OAPPEND, l, nil)        -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
	ir.NodAt(xpos, ir.ODELETE, l, nil)        -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
	ir.NodAt(xpos, ir.OGETG, l, nil)          -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
	ir.NodAt(xpos, ir.OMAKE, l, nil)          -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
	ir.NodAt(xpos, ir.OPRINT, l, nil)         -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
	ir.NodAt(xpos, ir.OPRINTN, l, nil)        -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
	ir.NodAt(xpos, ir.ORECOVER, l, nil)       -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
	ir.NodAt(xpos, ir.OCASE, nil, nil)        -> ir.NewCaseStmt(xpos, nil, nil)
	ir.NodAt(xpos, ir.OCONV, l, nil)          -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
	ir.NodAt(xpos, ir.OCONVIFACE, l, nil)     -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
	ir.NodAt(xpos, ir.OCONVNOP, l, nil)       -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
	ir.NodAt(xpos, ir.ORUNESTR, l, nil)       -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
	ir.NodAt(xpos, ir.ODCL, l, nil)           -> ir.NewDecl(xpos, ir.ODCL, l)
	ir.NodAt(xpos, ir.ODCLCONST, l, nil)      -> ir.NewDecl(xpos, ir.ODCLCONST, l)
	ir.NodAt(xpos, ir.ODCLTYPE, l, nil)       -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
	ir.NodAt(xpos, ir.ODCLFUNC, nil, nil)     -> ir.NewFunc(xpos)
	ir.NodAt(xpos, ir.ODEFER, l, nil)         -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
	ir.NodAt(xpos, ir.OGO, l, nil)            -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
	ir.NodAt(xpos, ir.ODEREF, l, nil)         -> ir.NewStarExpr(xpos, l)
	ir.NodAt(xpos, ir.ODOT, l, nil)           -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
	ir.NodAt(xpos, ir.ODOTPTR, l, nil)        -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
	ir.NodAt(xpos, ir.ODOTMETH, l, nil)       -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
	ir.NodAt(xpos, ir.ODOTINTER, l, nil)      -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
	ir.NodAt(xpos, ir.OXDOT, l, nil)          -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
	ir.NodAt(xpos, ir.ODOTTYPE, l, nil)       -> ir.NewTypeAssertExpr(xpos, l, nil)
	ir.NodAt(xpos, ir.ODOTTYPE, l, r)         -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
	ir.NodAt(xpos, ir.OFOR, l, r)             -> ir.NewForStmt(xpos, nil, l, r, nil)
	ir.NodAt(xpos, ir.OINDEX, l, r)           -> ir.NewIndexExpr(xpos, l, r)
	ir.NodAt(xpos, ir.OINLMARK, nil, nil)     -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
	ir.NodAt(xpos, ir.OKEY, l, r)             -> ir.NewKeyExpr(xpos, l, r)
	ir.NodAt(xpos, ir.OLABEL, nil, nil)       -> ir.NewLabelStmt(xpos, nil)
	ir.NodAt(xpos, ir.OMAKECHAN, l, r)        -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
	ir.NodAt(xpos, ir.OMAKEMAP, l, r)         -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
	ir.NodAt(xpos, ir.OMAKESLICE, l, r)       -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
	ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r)   -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
	ir.NodAt(xpos, ir.ONIL, nil, nil)         -> ir.NewNilExpr(xpos)
	ir.NodAt(xpos, ir.OPACK, nil, nil)        -> ir.NewPkgName(xpos, nil, nil)
	ir.NodAt(xpos, ir.OPAREN, l, nil)         -> ir.NewParenExpr(xpos, l)
	ir.NodAt(xpos, ir.ORANGE, nil, r)         -> ir.NewRangeStmt(xpos, nil, r, nil)
	ir.NodAt(xpos, ir.ORESULT, nil, nil)      -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
	ir.NodAt(xpos, ir.ORETURN, nil, nil)      -> ir.NewReturnStmt(xpos, nil)
	ir.NodAt(xpos, ir.OSELECT, nil, nil)      -> ir.NewSelectStmt(xpos, nil)
	ir.NodAt(xpos, ir.OSEND, l, r)            -> ir.NewSendStmt(xpos, l, r)
	ir.NodAt(xpos, ir.OSLICE, l, nil)         -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
	ir.NodAt(xpos, ir.OSLICEARR, l, nil)      -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
	ir.NodAt(xpos, ir.OSLICESTR, l, nil)      -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
	ir.NodAt(xpos, ir.OSLICE3, l, nil)        -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
	ir.NodAt(xpos, ir.OSLICE3ARR, l, nil)     -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
	ir.NodAt(xpos, ir.OSLICEHEADER, l, nil)   -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
	ir.NodAt(xpos, ir.OSWITCH, l, nil)        -> ir.NewSwitchStmt(xpos, l, nil)
	ir.NodAt(xpos, ir.OINLCALL, nil, nil)     -> ir.NewInlinedCallExpr(xpos, nil, nil)
}

rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'

Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:37:28 +00:00
Andrew G. Morgan fd6ba1c8a2 os/signal: fix a deadlock with syscall.AllThreadsSyscall() use
The syscall.AllThreadsSyscall() fixup mechanism needs to cooperate
with signal handling to ensure a notetsleepg() thread can wake up
to run the mDoFixup() function.

Fixes #43149

Change-Id: I6651b25bc44a4de47d3fb71d0293d51aef8b79c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/277434
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-23 05:27:04 +00:00
Russ Cox 69cf39089f [dev.regabi] cmd/compile: do not die in early base.FlushErrors
Change-Id: I72bac8a85db14494298059f8efddc5cbbf45f7ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/279214
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 05:03:59 +00:00
Matthew Dempsky 6d03cde88a [dev.regabi] cmd/dist: automatically bootstrap cmd subdirs
We want almost all cmd subdirectories anyway, and relative to the cost
of the rest of toolchain bootstrapping, copying/rewriting a few extra
source files is way cheaper than the engineering cost of forgetting to
maintain these lists as we split out new packages.

While here, also add cmd/internal/archive (and make it compile with Go
1.4) because it'll be needed in subsequent refactorings anyway; and
skip files starting with # (emacs temporary files) and test files
ending with _test.go.

Change-Id: Ic86e680a5fdfaecd617c36d5d04413293b2d6f52
Reviewed-on: https://go-review.googlesource.com/c/go/+/279832
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2020-12-23 04:20:02 +00:00
Andrew G. Morgan b0b0d98283 runtime: linux iscgo support for not blocking nptl signals
Under linux+cgo, OS threads are launched via pthread_create().
This abstraction, under linux, requires we avoid blocking
signals 32,33 and 34 indefinitely because they are needed to
reliably execute POSIX-semantics threading in glibc and/or musl.

When blocking signals the go runtime generally re-enables them
quickly. However, when a thread exits (under cgo, this is
via a return from mstart()), we avoid a deadlock in C-code by
not blocking these three signals.

Fixes #42494

Change-Id: I02dfb2480a1f97d11679e0c4b132b51bddbe4c14
Reviewed-on: https://go-review.googlesource.com/c/go/+/269799
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2020-12-23 02:10:51 +00:00
Russ Cox d1d1099c91 [dev.regabi] cmd/compile: fixes for big rewrite
Adjust the new regabi code a bit to make the rewrites apply cleanly.

Change-Id: Ice5378e94d94ab45ca0572f44ab8c94b847271b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/279530
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 00:51:53 +00:00
Jay Conrod 223331fc0c cmd/go/internal/modload: add hint for missing implicit dependency
By default (and with -mod=readonly), the go command imports an error
if a package provided by an implicitly required module is
imported by a package in the main module. This import requires an
update to go.mod: the module must be required explicitly.

The package loader now provides a hint that 'go get' should be run on
the importing package. This is preferred to 'go get' on the imported
package, since that would add an "// indirect" requirement.

For #43131

Change-Id: I0b353ce8ac8c4ddf1a9863544dfaf6c1964daf42
Reviewed-on: https://go-review.googlesource.com/c/go/+/279528
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-12-22 23:39:46 +00:00
Russ Cox ec741b0447 [dev.regabi] all: merge master (c9fb4eb) into dev.regabi
Merge List:

* 2020-12-22 c9fb4eb0a2 cmd/link: handle grouped resource sections
* 2020-12-22 c06a354bcc test: trigger SIGSEGV instead of SIGTRAP in issue11656.go
* 2020-12-22 0aa9b4709a cmd/pack: r command create output file if not exist
* 2020-12-22 4d27c4c223 runtime: correct error handling in several FreeBSD syscall wrappers
* 2020-12-22 9b6147120a cmd/pack: treat compiler's -linkobj output as "compiler object"
* 2020-12-21 bc7e4d9257 syscall: don't generate ptrace on iOS
* 2020-12-21 6cff874c47 runtime/metrics: add Read examples
* 2020-12-21 8438a5779b runtime: use _exit on darwin
* 2020-12-21 cb95819cf6 runtime: detect netbsd netpoll overrun in sysmon
* 2020-12-21 53c984d976 runtime: skip wakep call in wakeNetPoller on Plan 9
* 2020-12-21 9abbe27710 test: skip issue11656.go on mips/mips64/ppc64

Change-Id: Ibb235fbf6a86ebcf50c686dc11f7c02d1865f845
2020-12-22 16:55:15 -05:00
Russ Cox acc32ea124 [dev.regabi] codereview.cfg: add config for dev.regabi
Change-Id: Ida5cae7475bc19388fa46ceca25d983f560fa4e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/279524
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-22 21:02:04 +00:00
Jason A. Donenfeld c9fb4eb0a2 cmd/link: handle grouped resource sections
The Go PE linker does not support enough generalized PE logic to
properly handle .rsrc sections gracefully. Instead a few things are
special cased for these. The linker also does not support PE's "grouped
sections" features, in which input objects have several named sections
that are sorted, merged, and renamed in the output file. In the past,
more sophisticated support for resources or for PE features like grouped
sections have not been necessary, as Go's own object formats are pretty
vanilla, and GNU binutils also produces pretty vanilla objects where all
sections are already merged.

However, GNU binutils is lagging with arm support, and here LLVM has
picked up the slack. In particular, LLVM has its own rc/cvtres combo,
which are glued together in mingw LLVM distributions as windres, a
command line compatible tool with binutils' windres, which supports arm
and arm64. But there's a key difference between binutils' windres and
LLVM's windres: the LLVM one uses proper grouped sections.

So, this commit adds grouped sections support for resource sections to
the linker. We don't attempt to plumb generic support for grouped
sections, just as there isn't generic support already for what resources
require. Instead we augment the resource handling logic to deal with
standard two-section resource objects.

We also add a test for this, akin to the current test for more vanilla
binutils resource objects, and make sure that the rsrc tests are always
performed.

Fixes #42866.
Fixes #43182.

Change-Id: I059450021405cdf2ef1c195ddbab3960764ad711
Reviewed-on: https://go-review.googlesource.com/c/go/+/268337
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
2020-12-22 20:00:00 +00:00
Russ Cox c40934b33d [dev.regabi] cmd/compile: adjust one case in walkexpr
The mid-case n := n.(*ir.AssignExpr) does not lend itself
well to pulling the code into a new function, because n will
be a function argument and will not be redeclarable.

Change-Id: I673f2aa37eea64b083725326ed3fa36447bcc7af
Reviewed-on: https://go-review.googlesource.com/c/go/+/279426
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 19:45:35 +00:00
Russ Cox 280e7fd1ee [dev.regabi] cmd/compile: only access Func method on concrete types
Sets up for removing Func from Node interface.
That means that once the Name reorg is done,
which will let us remove Name, Sym, and Val,
Node will be basically a minimal interface.

Passes buildall w/ toolstash -cmp.

Change-Id: I6e87897572debd7f8e29b4f5167763dc2792b408
Reviewed-on: https://go-review.googlesource.com/c/go/+/279484
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 19:32:21 +00:00
Russ Cox 51ba53f5c2 [dev.regabi] cmd/compile: separate misc for gc split
Misc cleanup for splitting package gc: API tweaks
and boundary adjustments.

The change in ir.NewBlockStmt makes it a drop-in
replacement for liststmt.

Change-Id: I9455fe8ccae7d71fe8ccf390ac96672389bf4f3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/279305
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 19:32:16 +00:00
Russ Cox 572f168ed2 [dev.regabi] cmd/compile: separate various from Main
Move various code out of Main itself and into helper functions
that can be moved into other packages as package gc splits up.

Similarly, move order and instrument inside walk to reduce the amount
of API surface needed from the eventual package walk.

Change-Id: I7849258038c6e39625a0385af9c0edd6a3b654a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/279304
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 19:32:10 +00:00
Russ Cox 3b12c6dc08 [dev.regabi] cmd/compile: separate typecheck more cleanly
Abstract the typecheck API a bit more so that it is
easier to move into a new package.

Change-Id: Ia0a0146151fa7f6073113e68a2c3f6e42a5d0ad8
Reviewed-on: https://go-review.googlesource.com/c/go/+/279303
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 19:32:03 +00:00
Russ Cox 7c8f5356ab [dev.regabi] cmd/compile: separate dowidth better
Having a global MaxWidth lets us avoid needing to
refer to thearch from split-out packages when all
they need is thearch.MAXWIDTH.

And make a couple interface changes to let dowidth
avoid importing package ir directly.
Then it can move into package types.

Change-Id: I2c12e8e22252597530e648848320e19bdd490a01
Reviewed-on: https://go-review.googlesource.com/c/go/+/279302
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 19:31:57 +00:00
Cherry Zhang c06a354bcc test: trigger SIGSEGV instead of SIGTRAP in issue11656.go
In issue11656.go, it tests that if the runtime can get a
reasonable traceback when it faults at a non-function PC. It does
it by jumping to an address that contains an illegal or trap
instruction. When it traps, the SIGTRAP crashes the runtime.

This CL changes it to use an instruction that triggers SIGSEGV.
This is due to two reasons:
- currently, the handling of bad PC is done by preparePanic,
  which is only used for a panicking signal (SIGSEGV, SIGBUS,
  SIGFPE), not a fatal signal (e.g. SIGTRAP).
- the test uses defer+recover to get a traceback, which only
  works for panicking signals, not fatal signals.

Ideally, we should handle all kinds of faults (SIGSEGV, SIGBUS,
SIGILL, SIGTRAP, etc.) with a nice traceback. I'll leave this
for the future.

This CL also adds RISCV64 support.

Fixes #43283.

Change-Id: I5e0fbf8530cc89d16e05c3257d282bc1d4d03405
Reviewed-on: https://go-review.googlesource.com/c/go/+/279423
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-22 18:36:29 +00:00
Cherry Zhang 0aa9b4709a cmd/pack: r command create output file if not exist
Go 1.15 pack's r command creates the output file if it does not
exist. The system "ar" command does this as well. Do the same.

For bazelbuild/rules_go#2762.

Change-Id: Icd88396b5c714b735c859a29ab29851e4301f4d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/279516
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-22 18:16:54 +00:00
Than McIntosh cb28c96be8 [dev.regabi] cmd/compile,cmd/link: initial support for ABI wrappers
Add compiler support for emitting ABI wrappers by creating real IR as
opposed to introducing ABI aliases. At the moment these are "no-op"
wrappers in the sense that they make a simple call (using the existing
ABI) to their target. The assumption here is that once late call
expansion can handle both ABI0 and the "new" ABIInternal (register
version), it can expand the call to do the right thing.

Note that the runtime contains functions that do not strictly follow
the rules of the current Go ABI0; this has been handled in most cases
by treating these as ABIInternal instead (these changes have been made
in previous patches).

Generation of ABI wrappers (as opposed to ABI aliases) is currently
gated by GOEXPERIMENT=regabi -- wrapper generation is on by default if
GOEXPERIMENT=regabi is set and off otherwise (but can be turned on
using "-gcflags=all=-abiwrap -ldflags=-abiwrap"). Wrapper generation
currently only workd on AMD64; explicitly enabling wrapper for other
architectures (via the command line) is not supported.

Also in this patch are a few other command line options for debugging
(tracing and/or limiting wrapper creation). These will presumably go
away at some point.

Updates #27539, #40724.

Change-Id: I1ee3226fc15a3c32ca2087b8ef8e41dbe6df4a75
Reviewed-on: https://go-review.googlesource.com/c/go/+/270863
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>
2020-12-22 18:13:48 +00:00
Matthew Dempsky c8610e4700 [dev.regabi] cmd/compile: add ir.BasicLit to represent literals
This CL changes so that all literals are represented with a new,
smaller ir.BasicLit type, so that ir.Name is only used to represent
declared constants.

Passes buildall w/ toolstash -cmp.

Change-Id: I4702b8e3fa945617bd05881d7a2be1205f229633
Reviewed-on: https://go-review.googlesource.com/c/go/+/279153
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2020-12-22 17:04:46 +00:00
Matthew Dempsky 3512cde10a [dev.regabi] cmd/compile: stop reusing Ntype for OSLICELIT length
For OSLICELITs, we were reusing the Ntype field after type checking to
hold the length of the OSLICELIT's backing array. However, Ntype is
only meant for nodes that can represent types. Today, this works only
because we currently use Name for all OLITERAL constants (whether
declared or not), whereas we should be able to represent them more
compactly with a dedicated type that doesn't implement Ntype.

Passes buildall w/ toolstash -cmp.

Change-Id: I385f1d787c41b016f507a5bad9489d59ccfde7f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/279152
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2020-12-22 17:04:18 +00:00
Matthew Dempsky 2755361e6a [dev.regabi] cmd/compile: change noder.declNames to returns ir.Names
declNames always returns a slice of *ir.Names, so return that directly
rather than as []ir.Node.

While here, also change iimport to directly create ir.ODCL/ir.OAS
statements, rather than calling variter. Allows eliminating a use of
ir.TypeNode.

Passes buildall w/ toolstash -cmp.

Change-Id: Icb75e993c4957b6050c797ba64ee71cfb7a19644
Reviewed-on: https://go-review.googlesource.com/c/go/+/279315
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2020-12-22 17:04:04 +00:00
Than McIntosh 301af2cb71 [dev.regabi] runtime/race: adjust test pattern match for ABI wrapper
Adjust the pattern matching in one of the race output test to allow
for the possible introduction of an ABI wrapper. Normally for tests
that match traceback output wrappers are not an issue since they
are screened out by Go's traceback mechanism, but in this case the
race runtime is doing the unwinding, so the wrapper may be visible.

Change-Id: I45413b5c4701d4c28cc760fccc8203493dbe2874
Reviewed-on: https://go-review.googlesource.com/c/go/+/278756
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>
2020-12-22 16:35:20 +00:00
Nikhil Benesch 4d27c4c223 runtime: correct error handling in several FreeBSD syscall wrappers
The FreeBSD syscall convention uses the carry flag to indicate whether
an error has occured. The sys_umtx_op, thr_new, and pipe2 syscall
wrappers were failing to account for this convention and silently
suppressing errors as a result. This commit corrects these wrappers
by copying the pattern used by the other fallible syscall wrappers.

Note that futexsleep1 must now explicitly ignore the ETIMEDOUT error
from sys_umtx_op. Previously ETIMEDOUT was implicitly ignored because
sys_umtx_op never returned an error.

Fixes #43106.

Change-Id: I9c422b87cf4c6d308003bf42c3b419f785578b5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/276892
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Than McIntosh <thanm@google.com>
2020-12-22 15:59:17 +00:00
Cherry Zhang 9b6147120a cmd/pack: treat compiler's -linkobj output as "compiler object"
Treat the compiler's -linkobj output as "compiler object, which
means "pack c" will "see through" the file and add individual
entry to the new archive, instead of the object as a whole.

This is somewhat peculiar. But Go 1.15's cmd/pack does this,
although seemingly accidental. We just do the same. FWIW, it
does make things more consistent with/without -linkobj flag.

Fixes #43271.

Change-Id: I6b2d99256db7ebf0fa430f85afa7464e334f6bcb
Reviewed-on: https://go-review.googlesource.com/c/go/+/279483
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-22 15:50:18 +00:00
Than McIntosh 306b2451c8 [dev.regabi] runtime: fix ABI targets in runtime.panic{Index,Slice} shims
Fix up the assembly shim routines runtime.panic{Index,Slice} and
friends so that their tail calls target ABIInternal and not ABI0
functions. This is so as to ensure that these calls don't go through
an ABI0->ABIInternal wrapper (which would throw off the machinery in
the called routines designed to detect whether the violation happened
in the runtime).

Note that when the compiler starts emitting real register calls to
these routines, we'll need to rewrite them to update the arg size and
ensure that args are in the correct registers. For example, the
current shim

TEXT runtime·panicIndex<ABIInternal>(SB),NOSPLIT,$0-16
	MOVQ	AX, x+0(FP)
	MOVQ	CX, y+8(FP)
	JMP	runtime·goPanicIndex<ABIInternal>(SB)

will need to change to

TEXT runtime·panicIndex<ABIInternal>(SB),NOSPLIT,$0
	// AX already set up properly
	MOVQ	CX, BX // second argument expected in BX
	JMP	runtime·goPanicIndex<ABIInternal>(SB)

Change-Id: I48d1b5138fb4d229380ad12735cfaca5c50e6cc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/278755
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>
2020-12-22 14:50:50 +00:00
Cherry Zhang bc7e4d9257 syscall: don't generate ptrace on iOS
May fix #43302.

Change-Id: I6b7ddf94495c4fa80cf8a50a38eef5f8b2872669
Reviewed-on: https://go-review.googlesource.com/c/go/+/279481
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-21 21:48:47 +00:00
Matthew Dempsky 94cfeca0a5 [dev.regabi] cmd/compile: stop using ONONAME with Name
This CL changes NewDeclNameAt to take an Op argument to set the Op up
front, and updates all callers to provide the appropriate Op. This
allows dropping the Name.SetOp method.

Passes buildall w/ toolstash -cmp.

Change-Id: I20e580f62d3c8a81223d1c162327c11b37bbf3f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/279314
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2020-12-21 19:42:21 +00:00
Matthew Dempsky cb4898a77d [dev.regabi] cmd/compile: simplify declaration importing
Rather than creating Names w/ ONONAME earlier and later adding in the
details, this CL changes the import logic to create and add details at
the same time.

Passes buildall w/ toolstash -cmp.

Change-Id: Ifaabade3cef8cd80ddd6644bff79393b934255d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/279313
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2020-12-21 19:42:00 +00:00
Matthew Dempsky 06915ac14d [dev.regabi] cmd/compile: move itabname call out of implements
We only need to call itabname when actually creating the OCONVIFACE
ops, not any time we test whether a type implements an
interface. Additionally, by moving this call out of implements, we
make it purely based on types, which makes it safe to move to package
types.

Does not pass toolstash -cmp, because it shuffles symbol creation
order.

Change-Id: Iea8e0c9374218f4d97b4339020ebd758d051bd03
Reviewed-on: https://go-review.googlesource.com/c/go/+/279333
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2020-12-21 19:41:21 +00:00
Michael Anthony Knyszek 6cff874c47 runtime/metrics: add Read examples
This change adds two examples of using the Read function: one that reads
one metric and one that reads all metrics.

Change-Id: I4940a44c9b1d65f3f7a1554e3145ff07e6492fc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/275855
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
2020-12-21 19:28:12 +00:00
Gerrit Code Review 4e8f681eff Merge "[dev.regabi] all: merge master into dev.regabi" into dev.regabi 2020-12-21 19:23:41 +00:00
Russ Cox 1a523c8ab0 [dev.regabi] cmd/compile: separate nowritebarrierrec from main
Main knows a bit too much about nowritebarrierrec.
Abstract the API a little bit to make the package split easier.

Change-Id: I4b76bdb1fed73dfb0d44e1a6c86de8c2d29a9488
Reviewed-on: https://go-review.googlesource.com/c/go/+/279301
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-21 19:23:33 +00:00
Russ Cox e999c17022 [dev.regabi] cmd/compile: separate ssa from other phases
isIntrinsicCall and ssaDumpInline are the only two "forward references"
to ssa by earlier phases. Make them a bit more explicit so that the
uses and the definitions can end up in different packages.

Change-Id: I02c7a27464fbedef9fee43c0e4094fa08b4d7a5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/279300
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-21 19:23:31 +00:00
Russ Cox 4836e28ac0 [dev.regabi] cmd/compile: separate noder more cleanly
Separate embed, cgo pragmas, and Main trackScopes variable
from noder more cleanly.

This lets us split embed and noder into new packages.
It also assumes that the local embedded variables will be
removed and deletes them now for simplicity.

Change-Id: I9638bcc2c5f0e76440de056c6285b6aa2f73a00d
Reviewed-on: https://go-review.googlesource.com/c/go/+/279299
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-21 19:23:30 +00:00
Russ Cox 85ce6ecfe3 [dev.regabi] cmd/compile: separate exportsym more cleanly
Clean up a TODO (and make the package gc split easier)
by moving the exportsym walk out of iexport proper.

Also move exportsym call out of fninit.

Change-Id: Ie5887a68d325f7154201f4a35b9b4be4bf4b48dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/279298
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-21 19:23:29 +00:00
Russ Cox 1a3b036b83 [dev.regabi] cmd/compile: collect global compilation state
There are various global variables tracking the state of the
compilation. Collect them in a single global struct instead.
The struct definition is in package ir, but the struct itself is
still in package gc. It may eventually be threaded through the
code, but in the short term will end up in package typecheck.

Change-Id: I019db07aaedaed2c9b67dd45a4e138dc6028e54c
Reviewed-on: https://go-review.googlesource.com/c/go/+/279297
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-21 19:23:28 +00:00
Russ Cox 2153a99914 [dev.regabi] cmd/compile: setup to move Addrconst, Patch into cmd/internal/obj
Deleting the Pc assignment from Patch is safe because the actual PCs
are not assigned until well after the compiler is done patching jumps.
And it proves that replacing uses of Patch with SetTarget will be safe later.

Change-Id: Iffcbe03f0b5949ccd4c91e79c1272cd06be0f434
Reviewed-on: https://go-review.googlesource.com/c/go/+/279296
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-21 19:23:27 +00:00
Russ Cox 0bb0baf683 [dev.regabi] cmd/compile: cleanup for concrete types - more
Accumulated fixes to recent changes, to make the code safe
for automated deinterfacing.

Change-Id: I200737046cea88f3356b2402f09e2ca477fb8456
Reviewed-on: https://go-review.googlesource.com/c/go/+/279232
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-21 19:23:26 +00:00
Matthew Dempsky ca8e17164e [dev.regabi] all: merge master into dev.regabi
The list of conflicted files for this merge is:

   src/cmd/compile/internal/gc/inl.go
   src/cmd/compile/internal/gc/order.go
   src/cmd/compile/internal/gc/ssa.go
   test/fixedbugs/issue20415.go
   test/fixedbugs/issue22822.go
   test/fixedbugs/issue28079b.go

inl.go was updated for changes on dev.regabi: namely that OSELRECV has
been removed, and that OSELRECV2 now only uses List, rather than both
Left and List.

order.go was updated IsAutoTmp is now a standalone function, rather
than a method on Node.

ssa.go was similarly updated for new APIs involving package ir.

The tests are all merging upstream additions for gccgo error messages
with changes to cmd/compile's error messages on the dev.regabi branch.

Change-Id: Icaaf186d69da791b5994dbb6688ec989caabec42
2020-12-21 11:19:04 -08:00
Cherry Zhang 8438a5779b runtime: use _exit on darwin
On darwin, where we use libc for syscalls, when the runtime exits,
it calls libc exit function, which may call back into user code,
e.g. invoking functions registered with atexit. In particular, it
may call back into Go. But at this point, the Go runtime is
already exiting, so this wouldn't work.

On non-libc platforms we use exit syscall directly, which doesn't
invoke any callbacks. Use _exit on darwin to achieve the same
behavior.

No test for now, as it doesn't pass on all platforms (see trybot
run of PS2).

May fix #42465.
May fix #43294.

Change-Id: Ia1ada22b5da8cb64fdd598d0541eb90e195367eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/269378
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-21 19:16:38 +00:00
Michael Pratt cb95819cf6 runtime: detect netbsd netpoll overrun in sysmon
The netbsd kernel has a bug [1] that occassionally prevents netpoll from
waking with netpollBreak, which could result in missing timers for an
unbounded amount of time, as netpoll can't restart with a shorter delay
when an earlier timer is added.

Prior to CL 232298, sysmon could detect these overrun timers and
manually start an M to run them. With this fallback gone, the bug
actually prevents timer execution indefinitely.

As a workaround, we add back sysmon detection only for netbsd.

[1] https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=50094

Updates #42515

Change-Id: I8391f5b9dabef03dd1d94c50b3b4b3bd4f889e66
Reviewed-on: https://go-review.googlesource.com/c/go/+/277332
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Pratt <mpratt@google.com>
2020-12-21 18:00:57 +00:00
Richard Miller 53c984d976 runtime: skip wakep call in wakeNetPoller on Plan 9
This was part of a performance improvement made by CL 232298 to
reduce timer latency. On multiprocessor Plan 9 machines, it triggers
memory faults often enough that the builder test suite never completes
successfully. See issue #42303 for discussion. As shown by the benchmark
result below, worst case latency on plan9_arm is very bad even with the
wakep call in place - in the tickers-per-P=1 case, a 3ms timer is 270ms late.
Skipping the wakep call and running the benchmark again shows some cases
worse, some better. The performance cost doesn't seem excessive for this
temporary workaround which makes the plan9_arm builders usable again.

With wakep call:

cpu% go test -bench Latency time
goos: plan9
goarch: arm
pkg: time
BenchmarkParallelTimerLatency-4     	     100	  10985859 avg-late-ns	  18630963 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=1-4          	     195	 270294688 avg-late-ns	 542057670 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=2-4          	     234	 182452000 avg-late-ns	 423933688 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=3-4          	     280	 193003004 avg-late-ns	 408034405 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=4-4          	     282	 132819086 avg-late-ns	 313624570 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=5-4          	     339	  71152187 avg-late-ns	 189014519 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=6-4          	     315	  26860484 avg-late-ns	 101759844 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=7-4          	     357	  19106739 avg-late-ns	  59435620 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=8-4          	     376	   7246933 avg-late-ns	  38888461 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=9-4          	     267	  40476892 avg-late-ns	 205851926 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=10-4         	     294	  87836303 avg-late-ns	 252059695 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=2ms/tickers-per-P=1-4            	     379	   4127144 avg-late-ns	  10494927 max-late-ns

Without wakep call:

BenchmarkParallelTimerLatency-4     	      61	  10775151 avg-late-ns	  18668517 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=1-4          	     199	 299587535 avg-late-ns	 597182307 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=2-4          	     272	 184561831 avg-late-ns	 449739837 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=3-4          	     235	 154983257 avg-late-ns	 370940553 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=4-4          	     290	 150034689 avg-late-ns	 332399843 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=5-4          	     298	  47540764 avg-late-ns	 133709031 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=6-4          	     350	  20379394 avg-late-ns	  81742809 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=7-4          	     363	  14403223 avg-late-ns	  98901212 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=8-4          	     375	  12293090 avg-late-ns	  50266552 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=9-4          	     336	  40628820 avg-late-ns	 150946099 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=300µs/tickers-per-P=10-4         	     289	  88265539 avg-late-ns	 280770418 max-late-ns
BenchmarkStaggeredTickerLatency/work-dur=2ms/tickers-per-P=1-4            	     375	   8364937 avg-late-ns	  22598421 max-late-ns

Fixes #42303

Change-Id: I70c63cb2a2bad46950a7cd9dfc7bb32943710d32
Reviewed-on: https://go-review.googlesource.com/c/go/+/275672
Reviewed-by: David du Colombier <0intro@gmail.com>
Trust: Michael Pratt <mpratt@google.com>
2020-12-21 17:56:36 +00:00
Ian Lance Taylor 9abbe27710 test: skip issue11656.go on mips/mips64/ppc64
For #11656
For #43283

Change-Id: I1fcf2b24800f421e36201af43130b487abe605b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/279312
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2020-12-21 04:23:39 +00:00
Matthew Dempsky 89b44b4e2b cmd/compile: recognize reassignments involving receives
Previously, reassigned was failing to detect reassignments due to
channel receives in select statements (OSELRECV, OSELRECV2), or due to
standalone 2-value receive assignments (OAS2RECV). This was reported
as a devirtualization panic, but could have caused mis-inlining as
well.

Fixes #43292.

Change-Id: Ic8079c20c0587aeacff9596697fdeba80a697b12
Reviewed-on: https://go-review.googlesource.com/c/go/+/279352
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-20 09:43:29 +00:00
Ian Lance Taylor 55b58018f4 test: for issue11656 try to execute trap, not call it
The issue11656 code was using the trap instruction as a PC value,
but it is intended to call a PC value that contains the trap instruction.

It doesn't matter too much as in practice the address is not
executable anyhow. But may as well have the code act the way it
is documented to act.

Also, don't run the test with gccgo/GoLLVM, as it can't work.
The illegal instruction will have no unwind data, so the unwinder
won't be able to get past it. In other words, gccgo/GoLLVM suffer
from the exact problem that the issue describes, but it seems insoluble.

For golang/go#11656

Change-Id: Ib2e50ffc91d215fd50e78f742fafe476c92d704e
Reviewed-on: https://go-review.googlesource.com/c/go/+/278473
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-19 00:20:38 +00:00