From: Cuong Manh Le Date: Thu, 21 Jan 2021 05:08:46 +0000 (+0700) Subject: [dev.regabi] cmd/compile: remove tempAssigns in walkCall1 X-Git-Tag: go1.17beta1~1539^2~63 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=68a46644752b6bc8de8d2b82b7f2354f3b52b50a;p=gostls13.git [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 Trust: Cuong Manh Le Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/walk/expr.go b/src/cmd/compile/internal/walk/expr.go index bc4ae23759..d7a20206c8 100644 --- a/src/cmd/compile/internal/walk/expr.go +++ b/src/cmd/compile/internal/walk/expr.go @@ -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 }