Skip to content

Commit e84c007

Browse files
mdempskypull[bot]
authored andcommitted
cmd/compile/internal/ir: tweak a couple names
CallExpr.X -> CallExpr.Fun This consistent with go/ast and cmd/compile/internal/syntax. OPRINTN -> OPRINTLN This op represents the "println" builtin; might as well spell it the same way. Change-Id: Iead1b007776658c717879cf0997b3c48028428f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/532795 Reviewed-by: Cuong Manh Le <[email protected]> Reviewed-by: Keith Randall <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]> Auto-Submit: Matthew Dempsky <[email protected]>
1 parent d680ed4 commit e84c007

32 files changed

+121
-121
lines changed

src/cmd/compile/internal/devirtualize/devirtualize.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func staticCall(call *ir.CallExpr) {
5151
if call.Op() != ir.OCALLINTER {
5252
return
5353
}
54-
sel := call.X.(*ir.SelectorExpr)
54+
sel := call.Fun.(*ir.SelectorExpr)
5555
r := ir.StaticValue(sel.X)
5656
if r.Op() != ir.OCONVIFACE {
5757
return
@@ -120,14 +120,14 @@ func staticCall(call *ir.CallExpr) {
120120
base.WarnfAt(call.Pos(), "devirtualizing %v to %v", sel, typ)
121121
}
122122
call.SetOp(ir.OCALLMETH)
123-
call.X = x
123+
call.Fun = x
124124
case ir.ODOTINTER:
125125
// Promoted method from embedded interface-typed field (#42279).
126126
if base.Flag.LowerM != 0 {
127127
base.WarnfAt(call.Pos(), "partially devirtualizing %v to %v", sel, typ)
128128
}
129129
call.SetOp(ir.OCALLINTER)
130-
call.X = x
130+
call.Fun = x
131131
default:
132132
base.FatalfAt(call.Pos(), "failed to devirtualize %v (%v)", x, x.Op())
133133
}

src/cmd/compile/internal/devirtualize/pgo.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func constructCallStat(p *pgo.Profile, fn *ir.Func, name string, call *ir.CallEx
260260
case ir.OCALLFUNC:
261261
stat.Interface = false
262262

263-
callee := pgo.DirectCallee(call.X)
263+
callee := pgo.DirectCallee(call.Fun)
264264
if callee != nil {
265265
stat.Direct = true
266266
if stat.Hottest == "" {
@@ -283,7 +283,7 @@ func constructCallStat(p *pgo.Profile, fn *ir.Func, name string, call *ir.CallEx
283283
// concretetyp.
284284
func rewriteCondCall(call *ir.CallExpr, curfn, callee *ir.Func, concretetyp *types.Type) ir.Node {
285285
if base.Flag.LowerM != 0 {
286-
fmt.Printf("%v: PGO devirtualizing %v to %v\n", ir.Line(call), call.X, callee)
286+
fmt.Printf("%v: PGO devirtualizing %v to %v\n", ir.Line(call), call.Fun, callee)
287287
}
288288

289289
// We generate an OINCALL of:
@@ -316,13 +316,13 @@ func rewriteCondCall(call *ir.CallExpr, curfn, callee *ir.Func, concretetyp *typ
316316

317317
var retvars []ir.Node
318318

319-
sig := call.X.Type()
319+
sig := call.Fun.Type()
320320

321321
for _, ret := range sig.Results() {
322322
retvars = append(retvars, typecheck.TempAt(base.Pos, curfn, ret.Type))
323323
}
324324

325-
sel := call.X.(*ir.SelectorExpr)
325+
sel := call.Fun.(*ir.SelectorExpr)
326326
method := sel.Sel
327327
pos := call.Pos()
328328
init := ir.TakeInit(call)
@@ -421,7 +421,7 @@ func interfaceCallRecvTypeAndMethod(call *ir.CallExpr) (*types.Type, *types.Sym)
421421
base.Fatalf("Call isn't OCALLINTER: %+v", call)
422422
}
423423

424-
sel, ok := call.X.(*ir.SelectorExpr)
424+
sel, ok := call.Fun.(*ir.SelectorExpr)
425425
if !ok {
426426
base.Fatalf("OCALLINTER doesn't contain SelectorExpr: %+v", call)
427427
}

src/cmd/compile/internal/escape/call.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ func (e *escape) call(ks []hole, call ir.Node) {
3939
var fn *ir.Name
4040
switch call.Op() {
4141
case ir.OCALLFUNC:
42-
v := ir.StaticValue(call.X)
42+
v := ir.StaticValue(call.Fun)
4343
fn = ir.StaticCalleeName(v)
4444
}
4545

46-
fntype := call.X.Type()
46+
fntype := call.Fun.Type()
4747
if fn != nil {
4848
fntype = fn.Type()
4949
}
@@ -70,9 +70,9 @@ func (e *escape) call(ks []hole, call ir.Node) {
7070
}
7171
}
7272
}
73-
e.expr(calleeK, call.X)
73+
e.expr(calleeK, call.Fun)
7474
} else {
75-
recvArg = call.X.(*ir.SelectorExpr).X
75+
recvArg = call.Fun.(*ir.SelectorExpr).X
7676
}
7777

7878
// argumentParam handles escape analysis of assigning a call
@@ -155,7 +155,7 @@ func (e *escape) call(ks []hole, call ir.Node) {
155155
e.discard(call.X)
156156
e.discard(call.Y)
157157

158-
case ir.ODELETE, ir.OMAX, ir.OMIN, ir.OPRINT, ir.OPRINTN, ir.ORECOVERFP:
158+
case ir.ODELETE, ir.OMAX, ir.OMIN, ir.OPRINT, ir.OPRINTLN, ir.ORECOVERFP:
159159
call := call.(*ir.CallExpr)
160160
for i := range call.Args {
161161
e.discard(call.Args[i])
@@ -206,15 +206,15 @@ func (e *escape) goDeferStmt(n *ir.GoDeferStmt) {
206206
if !ok || call.Op() != ir.OCALLFUNC {
207207
base.FatalfAt(n.Pos(), "expected function call: %v", n.Call)
208208
}
209-
if sig := call.X.Type(); sig.NumParams()+sig.NumResults() != 0 {
209+
if sig := call.Fun.Type(); sig.NumParams()+sig.NumResults() != 0 {
210210
base.FatalfAt(n.Pos(), "expected signature without parameters or results: %v", sig)
211211
}
212212

213-
if clo, ok := call.X.(*ir.ClosureExpr); ok && n.Op() == ir.OGO {
213+
if clo, ok := call.Fun.(*ir.ClosureExpr); ok && n.Op() == ir.OGO {
214214
clo.IsGoWrap = true
215215
}
216216

217-
e.expr(k, call.X)
217+
e.expr(k, call.Fun)
218218
}
219219

220220
// rewriteArgument rewrites the argument arg of the given call expression.

src/cmd/compile/internal/escape/stmt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func (e *escape) stmt(n ir.Node) {
183183
dsts[i] = res.Nname.(*ir.Name)
184184
}
185185
e.assignList(dsts, n.Results, "return", n)
186-
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:
186+
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:
187187
e.call(nil, n)
188188
case ir.OGO, ir.ODEFER:
189189
n := n.(*ir.GoDeferStmt)

src/cmd/compile/internal/inline/inl.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ opSwitch:
536536
//
537537
// runtime.throw is a "cheap call" like panic in normal code.
538538
var cheap bool
539-
if n.X.Op() == ir.ONAME {
540-
name := n.X.(*ir.Name)
539+
if n.Fun.Op() == ir.ONAME {
540+
name := n.Fun.(*ir.Name)
541541
if name.Class == ir.PFUNC {
542542
switch fn := types.RuntimeSymName(name.Sym()); fn {
543543
case "getcallerpc", "getcallersp":
@@ -568,8 +568,8 @@ opSwitch:
568568
return false
569569
}
570570
}
571-
if n.X.Op() == ir.OMETHEXPR {
572-
if meth := ir.MethodExprName(n.X); meth != nil {
571+
if n.Fun.Op() == ir.OMETHEXPR {
572+
if meth := ir.MethodExprName(n.Fun); meth != nil {
573573
if fn := meth.Func; fn != nil {
574574
s := fn.Sym()
575575
if types.RuntimeSymName(s) == "heapBits.nextArena" {
@@ -602,7 +602,7 @@ opSwitch:
602602

603603
// Determine if the callee edge is for an inlinable hot callee or not.
604604
if v.profile != nil && v.curFunc != nil {
605-
if fn := inlCallee(v.curFunc, n.X, v.profile); fn != nil && typecheck.HaveInlineBody(fn) {
605+
if fn := inlCallee(v.curFunc, n.Fun, v.profile); fn != nil && typecheck.HaveInlineBody(fn) {
606606
lineOffset := pgo.NodeLineOffset(n, fn)
607607
csi := pgo.CallSiteInfo{LineOffset: lineOffset, Caller: v.curFunc}
608608
if _, o := candHotEdgeMap[csi]; o {
@@ -618,7 +618,7 @@ opSwitch:
618618
break
619619
}
620620

621-
if fn := inlCallee(v.curFunc, n.X, v.profile); fn != nil && typecheck.HaveInlineBody(fn) {
621+
if fn := inlCallee(v.curFunc, n.Fun, v.profile); fn != nil && typecheck.HaveInlineBody(fn) {
622622
// In the existing inliner, it makes sense to use fn.Inl.Cost
623623
// here due to the fact that an "inline F everywhere if F inlinable"
624624
// strategy is used. With the new inliner, however, it is not
@@ -902,10 +902,10 @@ func inlnode(callerfn *ir.Func, n ir.Node, bigCaller bool, inlCalls *[]*ir.Inlin
902902
base.FatalfAt(n.Pos(), "OCALLMETH missed by typecheck")
903903
case ir.OCALLFUNC:
904904
n := n.(*ir.CallExpr)
905-
if n.X.Op() == ir.OMETHEXPR {
905+
if n.Fun.Op() == ir.OMETHEXPR {
906906
// Prevent inlining some reflect.Value methods when using checkptr,
907907
// even when package reflect was compiled without it (#35073).
908-
if meth := ir.MethodExprName(n.X); meth != nil {
908+
if meth := ir.MethodExprName(n.Fun); meth != nil {
909909
s := meth.Sym()
910910
if base.Debug.Checkptr != 0 {
911911
switch types.ReflectSymName(s) {
@@ -934,12 +934,12 @@ func inlnode(callerfn *ir.Func, n ir.Node, bigCaller bool, inlCalls *[]*ir.Inlin
934934
break
935935
}
936936
if base.Flag.LowerM > 3 {
937-
fmt.Printf("%v:call to func %+v\n", ir.Line(n), call.X)
937+
fmt.Printf("%v:call to func %+v\n", ir.Line(n), call.Fun)
938938
}
939939
if ir.IsIntrinsicCall(call) {
940940
break
941941
}
942-
if fn := inlCallee(callerfn, call.X, profile); fn != nil && typecheck.HaveInlineBody(fn) {
942+
if fn := inlCallee(callerfn, call.Fun, profile); fn != nil && typecheck.HaveInlineBody(fn) {
943943
n = mkinlcall(callerfn, call, fn, bigCaller, inlCalls)
944944
}
945945
}
@@ -1151,12 +1151,12 @@ func mkinlcall(callerfn *ir.Func, n *ir.CallExpr, fn *ir.Func, bigCaller bool, i
11511151
// Not a standard call.
11521152
return
11531153
}
1154-
if n.X.Op() != ir.OCLOSURE {
1154+
if n.Fun.Op() != ir.OCLOSURE {
11551155
// Not a direct closure call.
11561156
return
11571157
}
11581158

1159-
clo := n.X.(*ir.ClosureExpr)
1159+
clo := n.Fun.(*ir.ClosureExpr)
11601160
if ir.IsTrivialClosure(clo) {
11611161
// enqueueFunc will handle trivial closures anyways.
11621162
return
@@ -1276,10 +1276,10 @@ func isIndexingCoverageCounter(n ir.Node) bool {
12761276
// determine whether it represents a call to sync/atomic.AddUint32 to
12771277
// increment a coverage counter.
12781278
func isAtomicCoverageCounterUpdate(cn *ir.CallExpr) bool {
1279-
if cn.X.Op() != ir.ONAME {
1279+
if cn.Fun.Op() != ir.ONAME {
12801280
return false
12811281
}
1282-
name := cn.X.(*ir.Name)
1282+
name := cn.Fun.(*ir.Name)
12831283
if name.Class != ir.PFUNC {
12841284
return false
12851285
}

src/cmd/compile/internal/inline/inlheur/analyze_func_callsites.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func (csa *callSiteAnalyzer) nodeVisitPre(n ir.Node) {
234234
}
235235
case ir.OCALLFUNC:
236236
ce := n.(*ir.CallExpr)
237-
callee := pgo.DirectCallee(ce.X)
237+
callee := pgo.DirectCallee(ce.Fun)
238238
if callee != nil && callee.Inl != nil {
239239
csa.addCallSite(callee, ce)
240240
}

src/cmd/compile/internal/inline/inlheur/analyze_func_flags.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func isExitCall(n ir.Node) bool {
180180
return false
181181
}
182182
cx := n.(*ir.CallExpr)
183-
name := ir.StaticCalleeName(cx.X)
183+
name := ir.StaticCalleeName(cx.Fun)
184184
if name == nil {
185185
return false
186186
}
@@ -330,7 +330,7 @@ func (ffa *funcFlagsAnalyzer) nodeVisitPost(n ir.Node) {
330330
case ir.OFALL:
331331
// Not important.
332332
case ir.ODCLFUNC, ir.ORECOVER, ir.OAS, ir.OAS2, ir.OAS2FUNC, ir.OASOP,
333-
ir.OPRINTN, ir.OPRINT, ir.OLABEL, ir.OCALLINTER, ir.ODEFER,
333+
ir.OPRINTLN, ir.OPRINT, ir.OLABEL, ir.OCALLINTER, ir.ODEFER,
334334
ir.OSEND, ir.ORECV, ir.OSELRECV2, ir.OGO, ir.OAPPEND, ir.OAS2DOTTYPE,
335335
ir.OAS2MAPR, ir.OGETG, ir.ODELETE, ir.OINLMARK, ir.OAS2RECV,
336336
ir.OMIN, ir.OMAX, ir.OMAKE, ir.ORECOVERFP, ir.OGETCALLERSP:

src/cmd/compile/internal/inline/inlheur/analyze_func_params.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (pa *paramsAnalyzer) callCheckParams(ce *ir.CallExpr) {
131131
if ce.Op() != ir.OCALLINTER {
132132
return
133133
}
134-
sel := ce.X.(*ir.SelectorExpr)
134+
sel := ce.Fun.(*ir.SelectorExpr)
135135
r := ir.StaticValue(sel.X)
136136
if r.Op() != ir.ONAME {
137137
return
@@ -147,10 +147,10 @@ func (pa *paramsAnalyzer) callCheckParams(ce *ir.CallExpr) {
147147
return name == p, false
148148
})
149149
case ir.OCALLFUNC:
150-
if ce.X.Op() != ir.ONAME {
150+
if ce.Fun.Op() != ir.ONAME {
151151
return
152152
}
153-
called := ir.StaticValue(ce.X)
153+
called := ir.StaticValue(ce.Fun)
154154
if called.Op() != ir.ONAME {
155155
return
156156
}

src/cmd/compile/internal/inline/inlheur/analyze_func_returns.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ func deriveReturnFlagsFromCallee(n ir.Node) (ResultPropBits, bool) {
247247
return 0, false
248248
}
249249
ce := n.(*ir.CallExpr)
250-
if ce.X.Op() != ir.ONAME {
250+
if ce.Fun.Op() != ir.ONAME {
251251
return 0, false
252252
}
253-
called := ir.StaticValue(ce.X)
253+
called := ir.StaticValue(ce.Fun)
254254
if called.Op() != ir.ONAME {
255255
return 0, false
256256
}

src/cmd/compile/internal/inline/inlheur/score_callresult_uses.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,10 @@ func (rua *resultUseAnalyzer) returnHasProp(name *ir.Name, prop ResultPropBits)
386386

387387
func (rua *resultUseAnalyzer) getCallResultName(ce *ir.CallExpr) *ir.Name {
388388
var callTarg ir.Node
389-
if sel, ok := ce.X.(*ir.SelectorExpr); ok {
389+
if sel, ok := ce.Fun.(*ir.SelectorExpr); ok {
390390
// method call
391391
callTarg = sel.X
392-
} else if ctarg, ok := ce.X.(*ir.Name); ok {
392+
} else if ctarg, ok := ce.Fun.(*ir.Name); ok {
393393
// regular call
394394
callTarg = ctarg
395395
} else {

src/cmd/compile/internal/ir/expr.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (n *BinaryExpr) SetOp(op Op) {
184184
// A CallExpr is a function call X(Args).
185185
type CallExpr struct {
186186
miniExpr
187-
X Node
187+
Fun Node
188188
Args Nodes
189189
DeferAt Node
190190
RType Node `mknode:"-"` // see reflectdata/helpers.go
@@ -194,7 +194,7 @@ type CallExpr struct {
194194
}
195195

196196
func NewCallExpr(pos src.XPos, op Op, fun Node, args []Node) *CallExpr {
197-
n := &CallExpr{X: fun}
197+
n := &CallExpr{Fun: fun}
198198
n.pos = pos
199199
n.SetOp(op)
200200
n.Args = args
@@ -211,7 +211,7 @@ func (n *CallExpr) SetOp(op Op) {
211211
OCALL, OCALLFUNC, OCALLINTER, OCALLMETH,
212212
ODELETE,
213213
OGETG, OGETCALLERPC, OGETCALLERSP,
214-
OMAKE, OMAX, OMIN, OPRINT, OPRINTN,
214+
OMAKE, OMAX, OMIN, OPRINT, OPRINTLN,
215215
ORECOVER, ORECOVERFP:
216216
n.op = op
217217
}

src/cmd/compile/internal/ir/fmt.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ var OpNames = []string{
7373
OOR: "|",
7474
OPANIC: "panic",
7575
OPLUS: "+",
76-
OPRINTN: "println",
76+
OPRINTLN: "println",
7777
OPRINT: "print",
7878
ORANGE: "range",
7979
OREAL: "real",
@@ -203,7 +203,7 @@ var OpPrec = []int{
203203
ONONAME: 8,
204204
OPANIC: 8,
205205
OPAREN: 8,
206-
OPRINTN: 8,
206+
OPRINTLN: 8,
207207
OPRINT: 8,
208208
ORUNESTR: 8,
209209
OSLICE2ARR: 8,
@@ -741,7 +741,7 @@ func exprFmt(n Node, s fmt.State, prec int) {
741741
OMIN,
742742
ORECOVER,
743743
OPRINT,
744-
OPRINTN:
744+
OPRINTLN:
745745
n := n.(*CallExpr)
746746
if n.IsDDD {
747747
fmt.Fprintf(s, "%v(%.v...)", n.Op(), n.Args)
@@ -751,7 +751,7 @@ func exprFmt(n Node, s fmt.State, prec int) {
751751

752752
case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG:
753753
n := n.(*CallExpr)
754-
exprFmt(n.X, s, nprec)
754+
exprFmt(n.Fun, s, nprec)
755755
if n.IsDDD {
756756
fmt.Fprintf(s, "(%.v...)", n.Args)
757757
return

src/cmd/compile/internal/ir/func.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,10 @@ func NewClosureFunc(fpos, cpos src.XPos, why Op, typ *types.Type, outerfn *Func,
435435

436436
// IsFuncPCIntrinsic returns whether n is a direct call of internal/abi.FuncPCABIxxx functions.
437437
func IsFuncPCIntrinsic(n *CallExpr) bool {
438-
if n.Op() != OCALLFUNC || n.X.Op() != ONAME {
438+
if n.Op() != OCALLFUNC || n.Fun.Op() != ONAME {
439439
return false
440440
}
441-
fn := n.X.(*Name).Sym()
441+
fn := n.Fun.(*Name).Sym()
442442
return (fn.Name == "FuncPCABI0" || fn.Name == "FuncPCABIInternal") &&
443443
fn.Pkg.Path == "internal/abi"
444444
}

src/cmd/compile/internal/ir/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ const (
223223
OOROR // X || Y
224224
OPANIC // panic(X)
225225
OPRINT // print(List)
226-
OPRINTN // println(List)
226+
OPRINTLN // println(List)
227227
OPAREN // (X)
228228
OSEND // Chan <- Value
229229
OSLICE // X[Low : High] (X is untypechecked or slice)

0 commit comments

Comments
 (0)