1
0
mirror of https://github.com/golang/go synced 2024-11-22 14:54:46 -07:00

[dev.regabi] cmd/compile: remove tempAssigns in walkCall1

Passes toolstash -cmp.

Change-Id: I588c663324443e02b901cda461b999ff192e150c
Reviewed-on: https://go-review.googlesource.com/c/go/+/284896
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Cuong Manh Le 2021-01-21 12:08:46 +07:00
parent fd9a391cdd
commit 68a4664475

View File

@ -521,10 +521,6 @@ func walkCall1(n *ir.CallExpr, init *ir.Nodes) {
n.X = walkExpr(n.X, init)
walkExprList(args, init)
// For any argument whose evaluation might require a function call,
// store that argument into a temporary variable,
// to prevent that calls from clobbering arguments already on the stack.
var tempAssigns []ir.Node
for i, arg := range args {
// Validate argument and parameter types match.
param := params.Field(i)
@ -532,17 +528,18 @@ func walkCall1(n *ir.CallExpr, init *ir.Nodes) {
base.FatalfAt(n.Pos(), "assigning %L to parameter %v (type %v)", arg, param.Sym, param.Type)
}
// For any argument whose evaluation might require a function call,
// store that argument into a temporary variable,
// to prevent that calls from clobbering arguments already on the stack.
if mayCall(arg) {
// assignment of arg to Temp
tmp := typecheck.Temp(param.Type)
a := convas(typecheck.Stmt(ir.NewAssignStmt(base.Pos, tmp, arg)).(*ir.AssignStmt), init)
tempAssigns = append(tempAssigns, a)
init.Append(convas(typecheck.Stmt(ir.NewAssignStmt(base.Pos, tmp, arg)).(*ir.AssignStmt), init))
// replace arg with temp
args[i] = tmp
}
}
init.Append(tempAssigns...)
n.Args = args
}