Skip to content

Commit fd9a391

Browse files
committed
[dev.regabi] cmd/compile: remove CallExpr.Rargs
Instead, push the temps assignments to init. This does not pass toolstash, since when before this, the temps were evaluated after function callee, now we evaluate them before. Change-Id: Icb9cb10e036925b56c1ef3eec468416a11f4932f Reviewed-on: https://go-review.googlesource.com/c/go/+/284894 Trust: Cuong Manh Le <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 19a6db6 commit fd9a391

File tree

4 files changed

+8
-48
lines changed

4 files changed

+8
-48
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ type CallExpr struct {
159159
origNode
160160
X Node
161161
Args Nodes
162-
Rargs Nodes // TODO(rsc): Delete.
163162
KeepAlive []*Name // vars to be kept alive until call returns
164163
IsDDD bool
165164
Use CallUse

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

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/compile/internal/ssagen/ssa.go

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4492,30 +4492,8 @@ func (s *state) intrinsicCall(n *ir.CallExpr) *ssa.Value {
44924492

44934493
// intrinsicArgs extracts args from n, evaluates them to SSA values, and returns them.
44944494
func (s *state) intrinsicArgs(n *ir.CallExpr) []*ssa.Value {
4495-
// Construct map of temps; see comments in s.call about the structure of n.
4496-
temps := map[ir.Node]*ssa.Value{}
4497-
for _, a := range n.Args {
4498-
if a.Op() != ir.OAS {
4499-
s.Fatalf("non-assignment as a temp function argument %v", a.Op())
4500-
}
4501-
a := a.(*ir.AssignStmt)
4502-
l, r := a.X, a.Y
4503-
if l.Op() != ir.ONAME {
4504-
s.Fatalf("non-ONAME temp function argument %v", a.Op())
4505-
}
4506-
// Evaluate and store to "temporary".
4507-
// Walk ensures these temporaries are dead outside of n.
4508-
temps[l] = s.expr(r)
4509-
}
4510-
args := make([]*ssa.Value, len(n.Rargs))
4511-
for i, n := range n.Rargs {
4512-
// Store a value to an argument slot.
4513-
if x, ok := temps[n]; ok {
4514-
// This is a previously computed temporary.
4515-
args[i] = x
4516-
continue
4517-
}
4518-
// This is an explicit value; evaluate it.
4495+
args := make([]*ssa.Value, len(n.Args))
4496+
for i, n := range n.Args {
45194497
args[i] = s.expr(n)
45204498
}
45214499
return args
@@ -4528,13 +4506,6 @@ func (s *state) intrinsicArgs(n *ir.CallExpr) []*ssa.Value {
45284506
// (as well as the deferBits variable), and this will enable us to run the proper
45294507
// defer calls during panics.
45304508
func (s *state) openDeferRecord(n *ir.CallExpr) {
4531-
// Do any needed expression evaluation for the args (including the
4532-
// receiver, if any). This may be evaluating something like 'autotmp_3 =
4533-
// once.mutex'. Such a statement will create a mapping in s.vars[] from
4534-
// the autotmp name to the evaluated SSA arg value, but won't do any
4535-
// stores to the stack.
4536-
s.stmtList(n.Args)
4537-
45384509
var args []*ssa.Value
45394510
var argNodes []*ir.Name
45404511

@@ -4567,7 +4538,7 @@ func (s *state) openDeferRecord(n *ir.CallExpr) {
45674538
opendefer.closureNode = opendefer.closure.Aux.(*ir.Name)
45684539
opendefer.rcvrNode = opendefer.rcvr.Aux.(*ir.Name)
45694540
}
4570-
for _, argn := range n.Rargs {
4541+
for _, argn := range n.Args {
45714542
var v *ssa.Value
45724543
if TypeOK(argn.Type()) {
45734544
v = s.openDeferSave(nil, argn.Type(), s.expr(argn))
@@ -4853,11 +4824,6 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
48534824
types.CalcSize(fn.Type())
48544825
stksize := fn.Type().ArgWidth() // includes receiver, args, and results
48554826

4856-
// Run all assignments of temps.
4857-
// The temps are introduced to avoid overwriting argument
4858-
// slots when arguments themselves require function calls.
4859-
s.stmtList(n.Args)
4860-
48614827
var call *ssa.Value
48624828
if k == callDeferStack {
48634829
testLateExpansion = ssa.LateCallExpansionEnabledWithin(s.f)
@@ -4891,7 +4857,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
48914857
// Then, store all the arguments of the defer call.
48924858
ft := fn.Type()
48934859
off := t.FieldOff(12)
4894-
args := n.Rargs
4860+
args := n.Args
48954861

48964862
// Set receiver (for interface calls). Always a pointer.
48974863
if rcvr != nil {
@@ -4966,7 +4932,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
49664932

49674933
// Write args.
49684934
t := n.X.Type()
4969-
args := n.Rargs
4935+
args := n.Args
49704936
if n.Op() == ir.OCALLMETH {
49714937
base.Fatalf("OCALLMETH missed by walkCall")
49724938
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,15 +535,15 @@ func walkCall1(n *ir.CallExpr, init *ir.Nodes) {
535535
if mayCall(arg) {
536536
// assignment of arg to Temp
537537
tmp := typecheck.Temp(param.Type)
538-
a := convas(ir.NewAssignStmt(base.Pos, tmp, arg), init)
538+
a := convas(typecheck.Stmt(ir.NewAssignStmt(base.Pos, tmp, arg)).(*ir.AssignStmt), init)
539539
tempAssigns = append(tempAssigns, a)
540540
// replace arg with temp
541541
args[i] = tmp
542542
}
543543
}
544544

545-
n.Args = tempAssigns
546-
n.Rargs = args
545+
init.Append(tempAssigns...)
546+
n.Args = args
547547
}
548548

549549
// walkDivMod walks an ODIV or OMOD node.

0 commit comments

Comments
 (0)