Commit 27a70ea5 authored by Daniel Martí's avatar Daniel Martí

cmd/compile: simplify a few early var declarations

These were likely written in C or added by an automated tool. Either
way, they're unnecessary now. Clean up the code.

Change-Id: I56de2c7bb60ebab8c500803a8b6586bdf4bf75c7
Reviewed-on: https://go-review.googlesource.com/62951
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: default avatarDave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent fa3fe2e3
...@@ -113,15 +113,12 @@ func paramoutheap(fn *Node) bool { ...@@ -113,15 +113,12 @@ func paramoutheap(fn *Node) bool {
// adds "adjust" to all the argument locations for the call n. // adds "adjust" to all the argument locations for the call n.
// n must be a defer or go node that has already been walked. // n must be a defer or go node that has already been walked.
func adjustargs(n *Node, adjust int) { func adjustargs(n *Node, adjust int) {
var arg *Node
var lhs *Node
callfunc := n.Left callfunc := n.Left
for _, arg = range callfunc.List.Slice() { for _, arg := range callfunc.List.Slice() {
if arg.Op != OAS { if arg.Op != OAS {
Fatalf("call arg not assignment") Fatalf("call arg not assignment")
} }
lhs = arg.Left lhs := arg.Left
if lhs.Op == ONAME { if lhs.Op == ONAME {
// This is a temporary introduced by reorder1. // This is a temporary introduced by reorder1.
// The real store to the stack appears later in the arg list. // The real store to the stack appears later in the arg list.
...@@ -303,9 +300,8 @@ func walkstmt(n *Node) *Node { ...@@ -303,9 +300,8 @@ func walkstmt(n *Node) *Node {
// so that reorder3 can fix up conflicts // so that reorder3 can fix up conflicts
var rl []*Node var rl []*Node
var cl Class
for _, ln := range Curfn.Func.Dcl { for _, ln := range Curfn.Func.Dcl {
cl = ln.Class() cl := ln.Class()
if cl == PAUTO || cl == PAUTOHEAP { if cl == PAUTO || cl == PAUTOHEAP {
break break
} }
...@@ -2367,7 +2363,6 @@ func reorder1(all []*Node) []*Node { ...@@ -2367,7 +2363,6 @@ func reorder1(all []*Node) []*Node {
var f *Node // last fncall assigned to stack var f *Node // last fncall assigned to stack
var r []*Node // non fncalls and tempnames assigned to stack var r []*Node // non fncalls and tempnames assigned to stack
d := 0 d := 0
var a *Node
for _, n := range all { for _, n := range all {
if !n.HasCall() { if !n.HasCall() {
r = append(r, n) r = append(r, n)
...@@ -2381,7 +2376,7 @@ func reorder1(all []*Node) []*Node { ...@@ -2381,7 +2376,7 @@ func reorder1(all []*Node) []*Node {
} }
// make assignment of fncall to tempname // make assignment of fncall to tempname
a = temp(n.Right.Type) a := temp(n.Right.Type)
a = nod(OAS, a, n.Right) a = nod(OAS, a, n.Right)
g = append(g, a) g = append(g, a)
...@@ -2406,8 +2401,6 @@ func reorder1(all []*Node) []*Node { ...@@ -2406,8 +2401,6 @@ func reorder1(all []*Node) []*Node {
// //
// function calls have been removed. // function calls have been removed.
func reorder3(all []*Node) []*Node { func reorder3(all []*Node) []*Node {
var l *Node
// If a needed expression may be affected by an // If a needed expression may be affected by an
// earlier assignment, make an early copy of that // earlier assignment, make an early copy of that
// expression and use the copy instead. // expression and use the copy instead.
...@@ -2415,7 +2408,7 @@ func reorder3(all []*Node) []*Node { ...@@ -2415,7 +2408,7 @@ func reorder3(all []*Node) []*Node {
var mapinit Nodes var mapinit Nodes
for i, n := range all { for i, n := range all {
l = n.Left l := n.Left
// Save subexpressions needed on left side. // Save subexpressions needed on left side.
// Drill through non-dereferences. // Drill through non-dereferences.
...@@ -2522,9 +2515,8 @@ func aliased(n *Node, all []*Node, i int) bool { ...@@ -2522,9 +2515,8 @@ func aliased(n *Node, all []*Node, i int) bool {
memwrite := 0 memwrite := 0
varwrite := 0 varwrite := 0
var a *Node
for _, an := range all[:i] { for _, an := range all[:i] {
a = outervalue(an.Left) a := outervalue(an.Left)
for a.Op == ODOT { for a.Op == ODOT {
a = a.Left a = a.Left
...@@ -3915,12 +3907,10 @@ func walkprintfunc(n *Node, init *Nodes) *Node { ...@@ -3915,12 +3907,10 @@ func walkprintfunc(n *Node, init *Nodes) *Node {
t := nod(OTFUNC, nil, nil) t := nod(OTFUNC, nil, nil)
num := 0 num := 0
var printargs []*Node var printargs []*Node
var a *Node
var buf string
for _, n1 := range n.List.Slice() { for _, n1 := range n.List.Slice() {
buf = fmt.Sprintf("a%d", num) buf := fmt.Sprintf("a%d", num)
num++ num++
a = namedfield(buf, n1.Type) a := namedfield(buf, n1.Type)
t.List.Append(a) t.List.Append(a)
printargs = append(printargs, a.Left) printargs = append(printargs, a.Left)
} }
...@@ -3932,7 +3922,7 @@ func walkprintfunc(n *Node, init *Nodes) *Node { ...@@ -3932,7 +3922,7 @@ func walkprintfunc(n *Node, init *Nodes) *Node {
sym := lookupN("print·%d", walkprintfunc_prgen) sym := lookupN("print·%d", walkprintfunc_prgen)
fn := dclfunc(sym, t) fn := dclfunc(sym, t)
a = nod(n.Op, nil, nil) a := nod(n.Op, nil, nil)
a.List.Set(printargs) a.List.Set(printargs)
a = typecheck(a, Etop) a = typecheck(a, Etop)
a = walkstmt(a) a = walkstmt(a)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment