if call.Op() != ir.OCALLINTER {
return
}
- sel := call.X.(*ir.SelectorExpr)
+ sel := call.Fun.(*ir.SelectorExpr)
r := ir.StaticValue(sel.X)
if r.Op() != ir.OCONVIFACE {
return
base.WarnfAt(call.Pos(), "devirtualizing %v to %v", sel, typ)
}
call.SetOp(ir.OCALLMETH)
- call.X = x
+ call.Fun = x
case ir.ODOTINTER:
// Promoted method from embedded interface-typed field (#42279).
if base.Flag.LowerM != 0 {
base.WarnfAt(call.Pos(), "partially devirtualizing %v to %v", sel, typ)
}
call.SetOp(ir.OCALLINTER)
- call.X = x
+ call.Fun = x
default:
base.FatalfAt(call.Pos(), "failed to devirtualize %v (%v)", x, x.Op())
}
case ir.OCALLFUNC:
stat.Interface = false
- callee := pgo.DirectCallee(call.X)
+ callee := pgo.DirectCallee(call.Fun)
if callee != nil {
stat.Direct = true
if stat.Hottest == "" {
// concretetyp.
func rewriteCondCall(call *ir.CallExpr, curfn, callee *ir.Func, concretetyp *types.Type) ir.Node {
if base.Flag.LowerM != 0 {
- fmt.Printf("%v: PGO devirtualizing %v to %v\n", ir.Line(call), call.X, callee)
+ fmt.Printf("%v: PGO devirtualizing %v to %v\n", ir.Line(call), call.Fun, callee)
}
// We generate an OINCALL of:
var retvars []ir.Node
- sig := call.X.Type()
+ sig := call.Fun.Type()
for _, ret := range sig.Results() {
retvars = append(retvars, typecheck.TempAt(base.Pos, curfn, ret.Type))
}
- sel := call.X.(*ir.SelectorExpr)
+ sel := call.Fun.(*ir.SelectorExpr)
method := sel.Sel
pos := call.Pos()
init := ir.TakeInit(call)
base.Fatalf("Call isn't OCALLINTER: %+v", call)
}
- sel, ok := call.X.(*ir.SelectorExpr)
+ sel, ok := call.Fun.(*ir.SelectorExpr)
if !ok {
base.Fatalf("OCALLINTER doesn't contain SelectorExpr: %+v", call)
}
var fn *ir.Name
switch call.Op() {
case ir.OCALLFUNC:
- v := ir.StaticValue(call.X)
+ v := ir.StaticValue(call.Fun)
fn = ir.StaticCalleeName(v)
}
- fntype := call.X.Type()
+ fntype := call.Fun.Type()
if fn != nil {
fntype = fn.Type()
}
}
}
}
- e.expr(calleeK, call.X)
+ e.expr(calleeK, call.Fun)
} else {
- recvArg = call.X.(*ir.SelectorExpr).X
+ recvArg = call.Fun.(*ir.SelectorExpr).X
}
// argumentParam handles escape analysis of assigning a call
e.discard(call.X)
e.discard(call.Y)
- case ir.ODELETE, ir.OMAX, ir.OMIN, ir.OPRINT, ir.OPRINTN, ir.ORECOVERFP:
+ case ir.ODELETE, ir.OMAX, ir.OMIN, ir.OPRINT, ir.OPRINTLN, ir.ORECOVERFP:
call := call.(*ir.CallExpr)
for i := range call.Args {
e.discard(call.Args[i])
if !ok || call.Op() != ir.OCALLFUNC {
base.FatalfAt(n.Pos(), "expected function call: %v", n.Call)
}
- if sig := call.X.Type(); sig.NumParams()+sig.NumResults() != 0 {
+ if sig := call.Fun.Type(); sig.NumParams()+sig.NumResults() != 0 {
base.FatalfAt(n.Pos(), "expected signature without parameters or results: %v", sig)
}
- if clo, ok := call.X.(*ir.ClosureExpr); ok && n.Op() == ir.OGO {
+ if clo, ok := call.Fun.(*ir.ClosureExpr); ok && n.Op() == ir.OGO {
clo.IsGoWrap = true
}
- e.expr(k, call.X)
+ e.expr(k, call.Fun)
}
// rewriteArgument rewrites the argument arg of the given call expression.
dsts[i] = res.Nname.(*ir.Name)
}
e.assignList(dsts, n.Results, "return", n)
- case ir.OCALLFUNC, ir.OCALLMETH, ir.OCALLINTER, ir.OINLCALL, ir.OCLEAR, ir.OCLOSE, ir.OCOPY, ir.ODELETE, ir.OPANIC, ir.OPRINT, ir.OPRINTN, ir.ORECOVERFP:
+ case ir.OCALLFUNC, ir.OCALLMETH, ir.OCALLINTER, ir.OINLCALL, ir.OCLEAR, ir.OCLOSE, ir.OCOPY, ir.ODELETE, ir.OPANIC, ir.OPRINT, ir.OPRINTLN, ir.ORECOVERFP:
e.call(nil, n)
case ir.OGO, ir.ODEFER:
n := n.(*ir.GoDeferStmt)
//
// runtime.throw is a "cheap call" like panic in normal code.
var cheap bool
- if n.X.Op() == ir.ONAME {
- name := n.X.(*ir.Name)
+ if n.Fun.Op() == ir.ONAME {
+ name := n.Fun.(*ir.Name)
if name.Class == ir.PFUNC {
switch fn := types.RuntimeSymName(name.Sym()); fn {
case "getcallerpc", "getcallersp":
return false
}
}
- if n.X.Op() == ir.OMETHEXPR {
- if meth := ir.MethodExprName(n.X); meth != nil {
+ if n.Fun.Op() == ir.OMETHEXPR {
+ if meth := ir.MethodExprName(n.Fun); meth != nil {
if fn := meth.Func; fn != nil {
s := fn.Sym()
if types.RuntimeSymName(s) == "heapBits.nextArena" {
// Determine if the callee edge is for an inlinable hot callee or not.
if v.profile != nil && v.curFunc != nil {
- if fn := inlCallee(v.curFunc, n.X, v.profile); fn != nil && typecheck.HaveInlineBody(fn) {
+ if fn := inlCallee(v.curFunc, n.Fun, v.profile); fn != nil && typecheck.HaveInlineBody(fn) {
lineOffset := pgo.NodeLineOffset(n, fn)
csi := pgo.CallSiteInfo{LineOffset: lineOffset, Caller: v.curFunc}
if _, o := candHotEdgeMap[csi]; o {
break
}
- if fn := inlCallee(v.curFunc, n.X, v.profile); fn != nil && typecheck.HaveInlineBody(fn) {
+ if fn := inlCallee(v.curFunc, n.Fun, v.profile); fn != nil && typecheck.HaveInlineBody(fn) {
// In the existing inliner, it makes sense to use fn.Inl.Cost
// here due to the fact that an "inline F everywhere if F inlinable"
// strategy is used. With the new inliner, however, it is not
base.FatalfAt(n.Pos(), "OCALLMETH missed by typecheck")
case ir.OCALLFUNC:
n := n.(*ir.CallExpr)
- if n.X.Op() == ir.OMETHEXPR {
+ if n.Fun.Op() == ir.OMETHEXPR {
// Prevent inlining some reflect.Value methods when using checkptr,
// even when package reflect was compiled without it (#35073).
- if meth := ir.MethodExprName(n.X); meth != nil {
+ if meth := ir.MethodExprName(n.Fun); meth != nil {
s := meth.Sym()
if base.Debug.Checkptr != 0 {
switch types.ReflectSymName(s) {
break
}
if base.Flag.LowerM > 3 {
- fmt.Printf("%v:call to func %+v\n", ir.Line(n), call.X)
+ fmt.Printf("%v:call to func %+v\n", ir.Line(n), call.Fun)
}
if ir.IsIntrinsicCall(call) {
break
}
- if fn := inlCallee(callerfn, call.X, profile); fn != nil && typecheck.HaveInlineBody(fn) {
+ if fn := inlCallee(callerfn, call.Fun, profile); fn != nil && typecheck.HaveInlineBody(fn) {
n = mkinlcall(callerfn, call, fn, bigCaller, inlCalls)
}
}
// Not a standard call.
return
}
- if n.X.Op() != ir.OCLOSURE {
+ if n.Fun.Op() != ir.OCLOSURE {
// Not a direct closure call.
return
}
- clo := n.X.(*ir.ClosureExpr)
+ clo := n.Fun.(*ir.ClosureExpr)
if ir.IsTrivialClosure(clo) {
// enqueueFunc will handle trivial closures anyways.
return
// determine whether it represents a call to sync/atomic.AddUint32 to
// increment a coverage counter.
func isAtomicCoverageCounterUpdate(cn *ir.CallExpr) bool {
- if cn.X.Op() != ir.ONAME {
+ if cn.Fun.Op() != ir.ONAME {
return false
}
- name := cn.X.(*ir.Name)
+ name := cn.Fun.(*ir.Name)
if name.Class != ir.PFUNC {
return false
}
}
case ir.OCALLFUNC:
ce := n.(*ir.CallExpr)
- callee := pgo.DirectCallee(ce.X)
+ callee := pgo.DirectCallee(ce.Fun)
if callee != nil && callee.Inl != nil {
csa.addCallSite(callee, ce)
}
return false
}
cx := n.(*ir.CallExpr)
- name := ir.StaticCalleeName(cx.X)
+ name := ir.StaticCalleeName(cx.Fun)
if name == nil {
return false
}
case ir.OFALL:
// Not important.
case ir.ODCLFUNC, ir.ORECOVER, ir.OAS, ir.OAS2, ir.OAS2FUNC, ir.OASOP,
- ir.OPRINTN, ir.OPRINT, ir.OLABEL, ir.OCALLINTER, ir.ODEFER,
+ ir.OPRINTLN, ir.OPRINT, ir.OLABEL, ir.OCALLINTER, ir.ODEFER,
ir.OSEND, ir.ORECV, ir.OSELRECV2, ir.OGO, ir.OAPPEND, ir.OAS2DOTTYPE,
ir.OAS2MAPR, ir.OGETG, ir.ODELETE, ir.OINLMARK, ir.OAS2RECV,
ir.OMIN, ir.OMAX, ir.OMAKE, ir.ORECOVERFP, ir.OGETCALLERSP:
if ce.Op() != ir.OCALLINTER {
return
}
- sel := ce.X.(*ir.SelectorExpr)
+ sel := ce.Fun.(*ir.SelectorExpr)
r := ir.StaticValue(sel.X)
if r.Op() != ir.ONAME {
return
return name == p, false
})
case ir.OCALLFUNC:
- if ce.X.Op() != ir.ONAME {
+ if ce.Fun.Op() != ir.ONAME {
return
}
- called := ir.StaticValue(ce.X)
+ called := ir.StaticValue(ce.Fun)
if called.Op() != ir.ONAME {
return
}
return 0, false
}
ce := n.(*ir.CallExpr)
- if ce.X.Op() != ir.ONAME {
+ if ce.Fun.Op() != ir.ONAME {
return 0, false
}
- called := ir.StaticValue(ce.X)
+ called := ir.StaticValue(ce.Fun)
if called.Op() != ir.ONAME {
return 0, false
}
func (rua *resultUseAnalyzer) getCallResultName(ce *ir.CallExpr) *ir.Name {
var callTarg ir.Node
- if sel, ok := ce.X.(*ir.SelectorExpr); ok {
+ if sel, ok := ce.Fun.(*ir.SelectorExpr); ok {
// method call
callTarg = sel.X
- } else if ctarg, ok := ce.X.(*ir.Name); ok {
+ } else if ctarg, ok := ce.Fun.(*ir.Name); ok {
// regular call
callTarg = ctarg
} else {
// A CallExpr is a function call X(Args).
type CallExpr struct {
miniExpr
- X Node
+ Fun Node
Args Nodes
DeferAt Node
RType Node `mknode:"-"` // see reflectdata/helpers.go
}
func NewCallExpr(pos src.XPos, op Op, fun Node, args []Node) *CallExpr {
- n := &CallExpr{X: fun}
+ n := &CallExpr{Fun: fun}
n.pos = pos
n.SetOp(op)
n.Args = args
OCALL, OCALLFUNC, OCALLINTER, OCALLMETH,
ODELETE,
OGETG, OGETCALLERPC, OGETCALLERSP,
- OMAKE, OMAX, OMIN, OPRINT, OPRINTN,
+ OMAKE, OMAX, OMIN, OPRINT, OPRINTLN,
ORECOVER, ORECOVERFP:
n.op = op
}
OOR: "|",
OPANIC: "panic",
OPLUS: "+",
- OPRINTN: "println",
+ OPRINTLN: "println",
OPRINT: "print",
ORANGE: "range",
OREAL: "real",
ONONAME: 8,
OPANIC: 8,
OPAREN: 8,
- OPRINTN: 8,
+ OPRINTLN: 8,
OPRINT: 8,
ORUNESTR: 8,
OSLICE2ARR: 8,
OMIN,
ORECOVER,
OPRINT,
- OPRINTN:
+ OPRINTLN:
n := n.(*CallExpr)
if n.IsDDD {
fmt.Fprintf(s, "%v(%.v...)", n.Op(), n.Args)
case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG:
n := n.(*CallExpr)
- exprFmt(n.X, s, nprec)
+ exprFmt(n.Fun, s, nprec)
if n.IsDDD {
fmt.Fprintf(s, "(%.v...)", n.Args)
return
// IsFuncPCIntrinsic returns whether n is a direct call of internal/abi.FuncPCABIxxx functions.
func IsFuncPCIntrinsic(n *CallExpr) bool {
- if n.Op() != OCALLFUNC || n.X.Op() != ONAME {
+ if n.Op() != OCALLFUNC || n.Fun.Op() != ONAME {
return false
}
- fn := n.X.(*Name).Sym()
+ fn := n.Fun.(*Name).Sym()
return (fn.Name == "FuncPCABI0" || fn.Name == "FuncPCABIInternal") &&
fn.Pkg.Path == "internal/abi"
}
OOROR // X || Y
OPANIC // panic(X)
OPRINT // print(List)
- OPRINTN // println(List)
+ OPRINTLN // println(List)
OPAREN // (X)
OSEND // Chan <- Value
OSLICE // X[Low : High] (X is untypechecked or slice)
if doNodes(n.init, do) {
return true
}
- if n.X != nil && do(n.X) {
+ if n.Fun != nil && do(n.Fun) {
return true
}
if doNodes(n.Args, do) {
}
func (n *CallExpr) editChildren(edit func(Node) Node) {
editNodes(n.init, edit)
- if n.X != nil {
- n.X = edit(n.X).(Node)
+ if n.Fun != nil {
+ n.Fun = edit(n.Fun).(Node)
}
editNodes(n.Args, edit)
editNames(n.KeepAlive, edit)
}
func (n *CallExpr) editChildrenWithHidden(edit func(Node) Node) {
editNodes(n.init, edit)
- if n.X != nil {
- n.X = edit(n.X).(Node)
+ if n.Fun != nil {
+ n.Fun = edit(n.Fun).(Node)
}
editNodes(n.Args, edit)
if n.RType != nil {
_ = x[OOROR-86]
_ = x[OPANIC-87]
_ = x[OPRINT-88]
- _ = x[OPRINTN-89]
+ _ = x[OPRINTLN-89]
_ = x[OPAREN-90]
_ = x[OSEND-91]
_ = x[OSLICE-92]
// may contain side effects. Make sure to preserve these,
// if necessary (#42703).
if call.Op() == ir.OCALLFUNC {
- inline.CalleeEffects(&init, call.X)
+ inline.CalleeEffects(&init, call.Fun)
}
var args ir.Nodes
case ir.OCALLFUNC:
call := n.(*ir.CallExpr)
// Find the callee function from the call site and add the edge.
- callee := DirectCallee(call.X)
+ callee := DirectCallee(call.Fun)
if callee != nil {
p.addIREdge(callernode, name, n, callee)
}
case ir.OCALLMETH:
call := n.(*ir.CallExpr)
// Find the callee method from the call site and add the edge.
- callee := ir.MethodExprName(call.X).Func
+ callee := ir.MethodExprName(call.Fun).Func
p.addIREdge(callernode, name, n, callee)
}
})
if ir.CurFunc.LSym == nil {
return
}
- dot := n.X.(*ir.SelectorExpr)
+ dot := n.Fun.(*ir.SelectorExpr)
ityp := dot.X.Type()
if ityp.HasShape() {
// Here we're calling a method on a generic interface. Something like:
return
}
n := nn.(*ir.CallExpr)
- if n.X == nil || n.X.Op() != ir.ONAME {
+ if n.Fun == nil || n.Fun.Op() != ir.ONAME {
return
}
- fn := n.X.(*ir.Name)
+ fn := n.Fun.(*ir.Name)
if fn.Class != ir.PFUNC || fn.Defn == nil {
return
}
case ir.OCALLINTER:
n := n.(*ir.CallExpr)
s.callResult(n, callNormal)
- if n.Op() == ir.OCALLFUNC && n.X.Op() == ir.ONAME && n.X.(*ir.Name).Class == ir.PFUNC {
- if fn := n.X.Sym().Name; base.Flag.CompilingRuntime && fn == "throw" ||
- n.X.Sym().Pkg == ir.Pkgs.Runtime && (fn == "throwinit" || fn == "gopanic" || fn == "panicwrap" || fn == "block" || fn == "panicmakeslicelen" || fn == "panicmakeslicecap" || fn == "panicunsafeslicelen" || fn == "panicunsafeslicenilptr" || fn == "panicunsafestringlen" || fn == "panicunsafestringnilptr") {
+ if n.Op() == ir.OCALLFUNC && n.Fun.Op() == ir.ONAME && n.Fun.(*ir.Name).Class == ir.PFUNC {
+ if fn := n.Fun.Sym().Name; base.Flag.CompilingRuntime && fn == "throw" ||
+ n.Fun.Sym().Pkg == ir.Pkgs.Runtime && (fn == "throwinit" || fn == "gopanic" || fn == "panicwrap" || fn == "block" || fn == "panicmakeslicelen" || fn == "panicmakeslicecap" || fn == "panicunsafeslicelen" || fn == "panicunsafeslicenilptr" || fn == "panicunsafestringlen" || fn == "panicunsafestringnilptr") {
m := s.mem()
b := s.endBlock()
b.Kind = ssa.BlockExit
// Call growslice
s.startBlock(grow)
- taddr := s.expr(n.X)
+ taddr := s.expr(n.Fun)
r := s.rtcall(ir.Syms.Growslice, true, []*types.Type{n.Type()}, p, l, c, nargs, taddr)
// Decompose output slice
if n == nil {
return false
}
- name, ok := n.X.(*ir.Name)
+ name, ok := n.Fun.(*ir.Name)
if !ok {
return false
}
// intrinsicCall converts a call to a recognized intrinsic function into the intrinsic SSA operation.
func (s *state) intrinsicCall(n *ir.CallExpr) *ssa.Value {
- v := findIntrinsic(n.X.Sym())(s, n, s.intrinsicArgs(n))
+ v := findIntrinsic(n.Fun.Sym())(s, n, s.intrinsicArgs(n))
if ssa.IntrinsicsDebug > 0 {
x := v
if x == nil {
if x.Op == ssa.OpSelect0 || x.Op == ssa.OpSelect1 {
x = x.Args[0]
}
- base.WarnfAt(n.Pos(), "intrinsic substitution for %v with %s", n.X.Sym().Name, x.LongString())
+ base.WarnfAt(n.Pos(), "intrinsic substitution for %v with %s", n.Fun.Sym().Name, x.LongString())
}
return v
}
// (as well as the deferBits variable), and this will enable us to run the proper
// defer calls during panics.
func (s *state) openDeferRecord(n *ir.CallExpr) {
- if len(n.Args) != 0 || n.Op() != ir.OCALLFUNC || n.X.Type().NumResults() != 0 {
+ if len(n.Args) != 0 || n.Op() != ir.OCALLFUNC || n.Fun.Type().NumResults() != 0 {
s.Fatalf("defer call with arguments or results: %v", n)
}
opendefer := &openDeferInfo{
n: n,
}
- fn := n.X
+ fn := n.Fun
// We must always store the function value in a stack slot for the
// runtime panic code to use. But in the defer exit code, we will
// call the function directly if it is a static function.
// Generate code to call the function call of the defer, using the
// closure that were stored in argtmps at the point of the defer
// statement.
- fn := r.n.X
+ fn := r.n.Fun
stksize := fn.Type().ArgWidth()
var callArgs []*ssa.Value
var call *ssa.Value
var codeptr *ssa.Value // ptr to target code (if dynamic)
var dextra *ssa.Value // defer extra arg
var rcvr *ssa.Value // receiver to set
- fn := n.X
+ fn := n.Fun
var ACArgs []*types.Type // AuxCall args
var ACResults []*types.Type // AuxCall results
var callArgs []*ssa.Value // For late-expansion, the args themselves (not stored, args to the call instead).
callABI := s.f.ABIDefault
- if k != callNormal && k != callTail && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) {
+ if k != callNormal && k != callTail && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.Fun.Type().NumResults() != 0) {
s.Fatalf("go/defer call with arguments: %v", n)
}
dextra = s.expr(deferExtra)
}
- params := callABI.ABIAnalyze(n.X.Type(), false /* Do not set (register) nNames from caller side -- can cause races. */)
+ params := callABI.ABIAnalyze(n.Fun.Type(), false /* Do not set (register) nNames from caller side -- can cause races. */)
types.CalcSize(fn.Type())
stksize := params.ArgWidth() // includes receiver, args, and results
- res := n.X.Type().Results()
+ res := n.Fun.Type().Results()
if k == callNormal || k == callTail {
for _, p := range params.OutParams() {
ACResults = append(ACResults, p.Type)
}
// Write args.
- t := n.X.Type()
+ t := n.Fun.Type()
args := n.Args
for _, p := range params.InParams() { // includes receiver for interface calls
ir.ONEW,
ir.OPANIC,
ir.OPRINT,
- ir.OPRINTN,
+ ir.OPRINTLN,
ir.OREAL,
ir.ORECOVER,
ir.ORECOVERFP,
// FixVariadicCall rewrites calls to variadic functions to use an
// explicit ... argument if one is not already present.
func FixVariadicCall(call *ir.CallExpr) {
- fntype := call.X.Type()
+ fntype := call.Fun.Type()
if !fntype.IsVariadic() || call.IsDDD {
return
}
// FixMethodCall rewrites a method call t.M(...) into a function call T.M(t, ...).
func FixMethodCall(call *ir.CallExpr) {
- if call.X.Op() != ir.ODOTMETH {
+ if call.Fun.Op() != ir.ODOTMETH {
return
}
- dot := call.X.(*ir.SelectorExpr)
+ dot := call.Fun.(*ir.SelectorExpr)
fn := NewMethodExpr(dot.Pos(), dot.X.Type(), dot.Selection.Sym)
copy(args[1:], call.Args)
call.SetOp(ir.OCALLFUNC)
- call.X = fn
+ call.Fun = fn
call.Args = args
}
func AssertFixedCall(call *ir.CallExpr) {
- if call.X.Type().IsVariadic() && !call.IsDDD {
+ if call.Fun.Type().IsVariadic() && !call.IsDDD {
base.FatalfAt(call.Pos(), "missed FixVariadicCall")
}
if call.Op() == ir.OCALLMETH {
// tcCall typechecks an OCALL node.
func tcCall(n *ir.CallExpr, top int) ir.Node {
Stmts(n.Init()) // imported rewritten f(g()) calls (#30907)
- n.X = typecheck(n.X, ctxExpr|ctxType|ctxCallee)
+ n.Fun = typecheck(n.Fun, ctxExpr|ctxType|ctxCallee)
- l := n.X
+ l := n.Fun
if l.Op() == ir.ONAME && l.(*ir.Name).BuiltinOp != 0 {
l := l.(*ir.Name)
default:
base.Fatalf("unknown builtin %v", l)
- case ir.OAPPEND, ir.ODELETE, ir.OMAKE, ir.OMAX, ir.OMIN, ir.OPRINT, ir.OPRINTN, ir.ORECOVER:
+ case ir.OAPPEND, ir.ODELETE, ir.OMAKE, ir.OMAX, ir.OMIN, ir.OPRINT, ir.OPRINTLN, ir.ORECOVER:
n.SetOp(l.BuiltinOp)
- n.X = nil
+ n.Fun = nil
n.SetTypecheck(0) // re-typechecking new op is OK, not a loop
return typecheck(n, top)
panic("unreachable")
}
- n.X = DefaultLit(n.X, nil)
- l = n.X
+ n.Fun = DefaultLit(n.Fun, nil)
+ l = n.Fun
if l.Op() == ir.OTYPE {
if n.IsDDD {
base.Fatalf("invalid use of ... in type conversion to %v", l.Type())
}
}
- typecheckaste(ir.OCALL, n.X, n.IsDDD, t.Params(), n.Args, func() string { return fmt.Sprintf("argument to %v", n.X) })
+ typecheckaste(ir.OCALL, n.Fun, n.IsDDD, t.Params(), n.Args, func() string { return fmt.Sprintf("argument to %v", n.Fun) })
FixVariadicCall(n)
FixMethodCall(n)
if t.NumResults() == 0 {
if t.NumResults() == 1 {
n.SetType(l.Type().Result(0).Type)
- if n.Op() == ir.OCALLFUNC && n.X.Op() == ir.ONAME {
- if sym := n.X.(*ir.Name).Sym(); types.RuntimeSymName(sym) == "getg" {
+ if n.Op() == ir.OCALLFUNC && n.Fun.Op() == ir.ONAME {
+ if sym := n.Fun.(*ir.Name).Sym(); types.RuntimeSymName(sym) == "getg" {
// Emit code for runtime.getg() directly instead of calling function.
// Most such rewrites (for example the similar one for math.Sqrt) should be done in walk,
// so that the ordering pass can make sure to preserve the semantics of the original code
if len(lhs) != cr {
if r, ok := rhs[0].(*ir.CallExpr); ok && len(rhs) == 1 {
if r.Type() != nil {
- base.ErrorfAt(stmt.Pos(), errors.WrongAssignCount, "assignment mismatch: %d variable%s but %v returns %d value%s", len(lhs), plural(len(lhs)), r.X, cr, plural(cr))
+ base.ErrorfAt(stmt.Pos(), errors.WrongAssignCount, "assignment mismatch: %d variable%s but %v returns %d value%s", len(lhs), plural(len(lhs)), r.Fun, cr, plural(cr))
}
} else {
base.ErrorfAt(stmt.Pos(), errors.WrongAssignCount, "assignment mismatch: %d variable%s but %v value%s", len(lhs), plural(len(lhs)), len(rhs), plural(len(rhs)))
init.Append(ir.TakeInit(call)...)
if call, ok := n.Call.(*ir.CallExpr); ok && call.Op() == ir.OCALLFUNC {
- if sig := call.X.Type(); sig.NumParams()+sig.NumResults() == 0 {
+ if sig := call.Fun.Type(); sig.NumParams()+sig.NumResults() == 0 {
return // already in normal form
}
}
call := call.(*ir.CallExpr)
// If the callee is a named function, link to the original callee.
- if wrapped := ir.StaticCalleeName(call.X); wrapped != nil {
+ if wrapped := ir.StaticCalleeName(call.Fun); wrapped != nil {
wrapperFn.WrappedFunc = wrapped.Func
}
- visit(&call.X)
+ visit(&call.Fun)
visitList(call.Args)
case ir.OCALLINTER:
call := call.(*ir.CallExpr)
- argps = append(argps, &call.X.(*ir.SelectorExpr).X) // must be first for OCHECKNIL; see below
+ argps = append(argps, &call.Fun.(*ir.SelectorExpr).X) // must be first for OCHECKNIL; see below
visitList(call.Args)
- case ir.OAPPEND, ir.ODELETE, ir.OPRINT, ir.OPRINTN, ir.ORECOVERFP:
+ case ir.OAPPEND, ir.ODELETE, ir.OPRINT, ir.OPRINTLN, ir.ORECOVERFP:
call := call.(*ir.CallExpr)
visitList(call.Args)
visit(&call.RType)
n := n.(*ir.UnaryExpr)
return tcNew(n)
- case ir.OPRINT, ir.OPRINTN:
+ case ir.OPRINT, ir.OPRINTLN:
n := n.(*ir.CallExpr)
return tcPrint(n)
// RewriteNonNameCall replaces non-Name call expressions with temps,
// rewriting f()(...) to t0 := f(); t0(...).
func RewriteNonNameCall(n *ir.CallExpr) {
- np := &n.X
+ np := &n.Fun
if dot, ok := (*np).(*ir.SelectorExpr); ok && (dot.Op() == ir.ODOTMETH || dot.Op() == ir.ODOTINTER || dot.Op() == ir.OMETHVALUE) {
np = &dot.X // peel away method selector
}
{"new", ir.ONEW},
{"panic", ir.OPANIC},
{"print", ir.OPRINT},
- {"println", ir.OPRINTN},
+ {"println", ir.OPRINTLN},
{"real", ir.OREAL},
{"recover", ir.ORECOVER},
}
// Left in place for back end.
// Do not add a new write barrier.
// Set up address of type for back end.
- r.X = reflectdata.AppendElemRType(base.Pos, r)
+ r.Fun = reflectdata.AppendElemRType(base.Pos, r)
return as
}
// Otherwise, lowered for race detector.
walkExprListCheap(nn.Args, init)
// For println, add " " between elements and "\n" at the end.
- if nn.Op() == ir.OPRINTN {
+ if nn.Op() == ir.OPRINTLN {
s := nn.Args
t := make([]ir.Node, 0, len(s)*2)
for i, n := range s {
// (*&byref)++
// }(byval, &byref, 42)
func directClosureCall(n *ir.CallExpr) {
- clo := n.X.(*ir.ClosureExpr)
+ clo := n.Fun.(*ir.ClosureExpr)
clofn := clo.Func
if ir.IsTrivialClosure(clo) {
clofn.Dcl = append(decls, clofn.Dcl...)
// Rewrite call.
- n.X = f
+ n.Fun = f
n.Args.Prepend(closureArgs(clo)...)
// Update the call expression's type. We need to do this
n := n.(*ir.LogicalExpr)
return walkLogical(n, init)
- case ir.OPRINT, ir.OPRINTN:
+ case ir.OPRINT, ir.OPRINTLN:
return walkPrint(n.(*ir.CallExpr), init)
case ir.OPANIC:
if n.Op() == ir.OCALLMETH {
base.FatalfAt(n.Pos(), "OCALLMETH missed by typecheck")
}
- if n.Op() == ir.OCALLINTER || n.X.Op() == ir.OMETHEXPR {
+ if n.Op() == ir.OCALLINTER || n.Fun.Op() == ir.OMETHEXPR {
// We expect both interface call reflect.Type.Method and concrete
// call reflect.(*rtype).Method.
usemethod(n)
reflectdata.MarkUsedIfaceMethod(n)
}
- if n.Op() == ir.OCALLFUNC && n.X.Op() == ir.OCLOSURE {
+ if n.Op() == ir.OCALLFUNC && n.Fun.Op() == ir.OCLOSURE {
directClosureCall(n)
}
if ir.IsFuncPCIntrinsic(n) {
// For internal/abi.FuncPCABIxxx(fn), if fn is a defined function, rewrite
// it to the address of the function of the ABI fn is defined.
- name := n.X.(*ir.Name).Sym().Name
+ name := n.Fun.(*ir.Name).Sym().Name
arg := n.Args[0]
var wantABI obj.ABI
switch name {
return e
}
- if name, ok := n.X.(*ir.Name); ok {
+ if name, ok := n.Fun.(*ir.Name); ok {
sym := name.Sym()
if sym.Pkg.Path == "go.runtime" && sym.Name == "deferrangefunc" {
// Call to runtime.deferrangefunc is being shared with a range-over-func
}
args := n.Args
- params := n.X.Type().Params()
+ params := n.Fun.Type().Params()
- n.X = walkExpr(n.X, init)
+ n.Fun = walkExpr(n.Fun, init)
walkExprList(args, init)
for i, arg := range args {
}
}
- funSym := n.X.Sym()
+ funSym := n.Fun.Sym()
if base.Debug.Libfuzzer != 0 && funSym != nil {
if hook, found := hooks[funSym.Pkg.Path+"."+funSym.Name]; found {
if len(args) != hook.argsNum {
}
}
- dot, ok := n.X.(*ir.SelectorExpr)
+ dot, ok := n.Fun.(*ir.SelectorExpr)
if !ok {
return
}
return
}
- n.X = o.expr(n.X, nil)
+ n.Fun = o.expr(n.Fun, nil)
o.exprList(n.Args)
}
o.out = append(o.out, n)
o.popTemp(t)
- case ir.OPRINT, ir.OPRINTN, ir.ORECOVERFP:
+ case ir.OPRINT, ir.OPRINTLN, ir.ORECOVERFP:
n := n.(*ir.CallExpr)
t := o.markTemp()
o.call(n)
ir.ODELETE,
ir.OSEND,
ir.OPRINT,
- ir.OPRINTN,
+ ir.OPRINTLN,
ir.OPANIC,
ir.ORECOVERFP,
ir.OGETG:
n := n.(*ir.TailCallStmt)
var init ir.Nodes
- n.Call.X = walkExpr(n.Call.X, &init)
+ n.Call.Fun = walkExpr(n.Call.Fun, &init)
if len(init) > 0 {
init.Append(n)
// call without arguments or results.
func validGoDeferCall(call ir.Node) bool {
if call, ok := call.(*ir.CallExpr); ok && call.Op() == ir.OCALLFUNC && len(call.KeepAlive) == 0 {
- sig := call.X.Type()
+ sig := call.Fun.Type()
return sig.NumParams()+sig.NumResults() == 0
}
return false
var init ir.Nodes
call := n.Call.(*ir.CallExpr)
- call.X = walkExpr(call.X, &init)
+ call.Fun = walkExpr(call.Fun, &init)
if len(init) > 0 {
init.Append(n)