Commit 9238cbd5 authored by Håvard Haugen's avatar Håvard Haugen Committed by Robert Griesemer

cmd/compile/internal/gc: remove "goto ret" in walkexpr

Passes go build -a -toolexec 'toolstash -cmp' std cmd.

Change-Id: Ib3d2c50601546495e7f1ab153d2978b1e3774101
Reviewed-on: https://go-review.googlesource.com/14800
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent b7e4de4b
...@@ -428,6 +428,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -428,6 +428,7 @@ func walkexpr(np **Node, init **NodeList) {
Fatalf("missed typecheck: %v\n", Nconv(n, obj.FmtSign)) Fatalf("missed typecheck: %v\n", Nconv(n, obj.FmtSign))
} }
opswitch:
switch n.Op { switch n.Op {
default: default:
Dump("walk", n) Dump("walk", n)
...@@ -439,7 +440,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -439,7 +440,6 @@ func walkexpr(np **Node, init **NodeList) {
OEMPTY, OEMPTY,
OPARAM, OPARAM,
OGETG: OGETG:
goto ret
case ONOT, case ONOT,
OMINUS, OMINUS,
...@@ -450,16 +450,13 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -450,16 +450,13 @@ func walkexpr(np **Node, init **NodeList) {
ODOTMETH, ODOTMETH,
ODOTINTER: ODOTINTER:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
goto ret
case OIND: case OIND:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
goto ret
case ODOT: case ODOT:
usefield(n) usefield(n)
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
goto ret
case ODOTPTR: case ODOTPTR:
usefield(n) usefield(n)
...@@ -471,16 +468,13 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -471,16 +468,13 @@ func walkexpr(np **Node, init **NodeList) {
} }
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
goto ret
case OEFACE: case OEFACE:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
goto ret
case OSPTR, OITAB: case OSPTR, OITAB:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
goto ret
case OLEN, OCAP: case OLEN, OCAP:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
...@@ -498,8 +492,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -498,8 +492,6 @@ func walkexpr(np **Node, init **NodeList) {
n.Typecheck = 1 n.Typecheck = 1
} }
goto ret
case OLSH, ORSH: case OLSH, ORSH:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
...@@ -508,7 +500,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -508,7 +500,6 @@ func walkexpr(np **Node, init **NodeList) {
if Debug['m'] != 0 && n.Etype != 0 && !Isconst(n.Right, CTINT) { if Debug['m'] != 0 && n.Etype != 0 && !Isconst(n.Right, CTINT) {
Warn("shift bounds check elided") Warn("shift bounds check elided")
} }
goto ret
// Use results from call expression as arguments for complex. // Use results from call expression as arguments for complex.
case OAND, case OAND,
...@@ -528,13 +519,11 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -528,13 +519,11 @@ func walkexpr(np **Node, init **NodeList) {
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
goto ret
case OOR, OXOR: case OOR, OXOR:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
walkrotate(&n) walkrotate(&n)
goto ret
case OEQ, ONE: case OEQ, ONE:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
...@@ -550,7 +539,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -550,7 +539,6 @@ func walkexpr(np **Node, init **NodeList) {
safemode = 0 safemode = 0
walkcompare(&n, init) walkcompare(&n, init)
safemode = old_safemode safemode = old_safemode
goto ret
case OANDAND, OOROR: case OANDAND, OOROR:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
...@@ -562,45 +550,37 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -562,45 +550,37 @@ func walkexpr(np **Node, init **NodeList) {
walkexpr(&n.Right, &ll) walkexpr(&n.Right, &ll)
addinit(&n.Right, ll) addinit(&n.Right, ll)
goto ret
case OPRINT, OPRINTN: case OPRINT, OPRINTN:
walkexprlist(n.List, init) walkexprlist(n.List, init)
n = walkprint(n, init) n = walkprint(n, init)
goto ret
case OPANIC: case OPANIC:
n = mkcall("gopanic", nil, init, n.Left) n = mkcall("gopanic", nil, init, n.Left)
goto ret
case ORECOVER: case ORECOVER:
n = mkcall("gorecover", n.Type, init, Nod(OADDR, nodfp, nil)) n = mkcall("gorecover", n.Type, init, Nod(OADDR, nodfp, nil))
goto ret
case OLITERAL: case OLITERAL:
n.Addable = true n.Addable = true
goto ret
case OCLOSUREVAR, OCFUNC: case OCLOSUREVAR, OCFUNC:
n.Addable = true n.Addable = true
goto ret
case ONAME: case ONAME:
if n.Class&PHEAP == 0 && n.Class != PPARAMREF { if n.Class&PHEAP == 0 && n.Class != PPARAMREF {
n.Addable = true n.Addable = true
} }
goto ret
case OCALLINTER: case OCALLINTER:
t := n.Left.Type t := n.Left.Type
if n.List != nil && n.List.N.Op == OAS { if n.List != nil && n.List.N.Op == OAS {
goto ret break
} }
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexprlist(n.List, init) walkexprlist(n.List, init)
ll := ascompatte(int(n.Op), n, n.Isddd, getinarg(t), n.List, 0, init) ll := ascompatte(int(n.Op), n, n.Isddd, getinarg(t), n.List, 0, init)
n.List = reorder1(ll) n.List = reorder1(ll)
goto ret
case OCALLFUNC: case OCALLFUNC:
if n.Left.Op == OCLOSURE { if n.Left.Op == OCLOSURE {
...@@ -630,7 +610,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -630,7 +610,7 @@ func walkexpr(np **Node, init **NodeList) {
t := n.Left.Type t := n.Left.Type
if n.List != nil && n.List.N.Op == OAS { if n.List != nil && n.List.N.Op == OAS {
goto ret break
} }
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
...@@ -642,18 +622,17 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -642,18 +622,17 @@ func walkexpr(np **Node, init **NodeList) {
n.Op = OSQRT n.Op = OSQRT
n.Left = n.List.N n.Left = n.List.N
n.List = nil n.List = nil
goto ret break opswitch
} }
} }
ll := ascompatte(int(n.Op), n, n.Isddd, getinarg(t), n.List, 0, init) ll := ascompatte(int(n.Op), n, n.Isddd, getinarg(t), n.List, 0, init)
n.List = reorder1(ll) n.List = reorder1(ll)
goto ret
case OCALLMETH: case OCALLMETH:
t := n.Left.Type t := n.Left.Type
if n.List != nil && n.List.N.Op == OAS { if n.List != nil && n.List.N.Op == OAS {
goto ret break
} }
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexprlist(n.List, init) walkexprlist(n.List, init)
...@@ -663,7 +642,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -663,7 +642,6 @@ func walkexpr(np **Node, init **NodeList) {
n.Left.Left = nil n.Left.Left = nil
ullmancalc(n.Left) ullmancalc(n.Left)
n.List = reorder1(ll) n.List = reorder1(ll)
goto ret
case OAS: case OAS:
*init = concat(*init, n.Ninit) *init = concat(*init, n.Ninit)
...@@ -673,11 +651,11 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -673,11 +651,11 @@ func walkexpr(np **Node, init **NodeList) {
n.Left = safeexpr(n.Left, init) n.Left = safeexpr(n.Left, init)
if oaslit(n, init) { if oaslit(n, init) {
goto ret break
} }
if n.Right == nil || iszero(n.Right) && !instrumenting { if n.Right == nil || iszero(n.Right) && !instrumenting {
goto ret break
} }
switch n.Right.Op { switch n.Right.Op {
...@@ -711,7 +689,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -711,7 +689,7 @@ func walkexpr(np **Node, init **NodeList) {
n = mkcall1(fn, nil, init, typename(r.Type), r.Left, n1) n = mkcall1(fn, nil, init, typename(r.Type), r.Left, n1)
walkexpr(&n, init) walkexpr(&n, init)
goto ret break opswitch
case ORECV: case ORECV:
// x = <-c; n.Left is x, n.Right.Left is c. // x = <-c; n.Left is x, n.Right.Left is c.
...@@ -722,7 +700,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -722,7 +700,7 @@ func walkexpr(np **Node, init **NodeList) {
r := n.Right.Left // the channel r := n.Right.Left // the channel
n = mkcall1(chanfn("chanrecv1", 2, r.Type), nil, init, typename(r.Type), r, n1) n = mkcall1(chanfn("chanrecv1", 2, r.Type), nil, init, typename(r.Type), r, n1)
walkexpr(&n, init) walkexpr(&n, init)
goto ret break opswitch
case OAPPEND: case OAPPEND:
// x = append(...) // x = append(...)
...@@ -736,7 +714,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -736,7 +714,7 @@ func walkexpr(np **Node, init **NodeList) {
if r.Op == OAPPEND { if r.Op == OAPPEND {
// Left in place for back end. // Left in place for back end.
// Do not add a new write barrier. // Do not add a new write barrier.
goto ret break opswitch
} }
// Otherwise, lowered for race detector. // Otherwise, lowered for race detector.
// Treat as ordinary assignment. // Treat as ordinary assignment.
...@@ -749,8 +727,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -749,8 +727,6 @@ func walkexpr(np **Node, init **NodeList) {
n = applywritebarrier(n, init) n = applywritebarrier(n, init)
} }
goto ret
case OAS2: case OAS2:
*init = concat(*init, n.Ninit) *init = concat(*init, n.Ninit)
n.Ninit = nil n.Ninit = nil
...@@ -762,7 +738,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -762,7 +738,6 @@ func walkexpr(np **Node, init **NodeList) {
lr.N = applywritebarrier(lr.N, init) lr.N = applywritebarrier(lr.N, init)
} }
n = liststmt(ll) n = liststmt(ll)
goto ret
// a,b,... = fn() // a,b,... = fn()
case OAS2FUNC: case OAS2FUNC:
...@@ -778,7 +753,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -778,7 +753,6 @@ func walkexpr(np **Node, init **NodeList) {
lr.N = applywritebarrier(lr.N, init) lr.N = applywritebarrier(lr.N, init)
} }
n = liststmt(concat(list1(r), ll)) n = liststmt(concat(list1(r), ll))
goto ret
// x, y = <-c // x, y = <-c
// orderstmt made sure x is addressable. // orderstmt made sure x is addressable.
...@@ -800,7 +774,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -800,7 +774,6 @@ func walkexpr(np **Node, init **NodeList) {
r = mkcall1(fn, n.List.Next.N.Type, init, typename(r.Left.Type), r.Left, n1) r = mkcall1(fn, n.List.Next.N.Type, init, typename(r.Left.Type), r.Left, n1)
n = Nod(OAS, n.List.Next.N, r) n = Nod(OAS, n.List.Next.N, r)
typecheck(&n, Etop) typecheck(&n, Etop)
goto ret
// a,b = m[i]; // a,b = m[i];
case OAS2MAPR: case OAS2MAPR:
...@@ -871,7 +844,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -871,7 +844,6 @@ func walkexpr(np **Node, init **NodeList) {
walkexpr(&n, init) walkexpr(&n, init)
// TODO: ptr is always non-nil, so disable nil check for this OIND op. // TODO: ptr is always non-nil, so disable nil check for this OIND op.
goto ret
case ODELETE: case ODELETE:
*init = concat(*init, n.Ninit) *init = concat(*init, n.Ninit)
...@@ -886,7 +858,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -886,7 +858,6 @@ func walkexpr(np **Node, init **NodeList) {
t := map_.Type t := map_.Type
n = mkcall1(mapfndel("mapdelete", t), nil, init, typename(t), map_, key) n = mkcall1(mapfndel("mapdelete", t), nil, init, typename(t), map_, key)
goto ret
case OAS2DOTTYPE: case OAS2DOTTYPE:
e := n.Rlist.N // i.(T) e := n.Rlist.N // i.(T)
...@@ -897,7 +868,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -897,7 +868,7 @@ func walkexpr(np **Node, init **NodeList) {
// handled directly during gen. // handled directly during gen.
walkexprlistsafe(n.List, init) walkexprlistsafe(n.List, init)
walkexpr(&e.Left, init) walkexpr(&e.Left, init)
goto ret break
} }
// res, ok = i.(T) // res, ok = i.(T)
...@@ -941,7 +912,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -941,7 +912,7 @@ func walkexpr(np **Node, init **NodeList) {
} }
n = Nod(OAS, ok, fast) n = Nod(OAS, ok, fast)
typecheck(&n, Etop) typecheck(&n, Etop)
goto ret break
} }
} }
...@@ -962,14 +933,12 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -962,14 +933,12 @@ func walkexpr(np **Node, init **NodeList) {
call := mkcall1(fn, oktype, init, typename(t), from, resptr) call := mkcall1(fn, oktype, init, typename(t), from, resptr)
n = Nod(OAS, ok, call) n = Nod(OAS, ok, call)
typecheck(&n, Etop) typecheck(&n, Etop)
goto ret
case ODOTTYPE, ODOTTYPE2: case ODOTTYPE, ODOTTYPE2:
if !isdirectiface(n.Type) || Isfat(n.Type) { if !isdirectiface(n.Type) || Isfat(n.Type) {
Fatalf("walkexpr ODOTTYPE") // should see inside OAS only Fatalf("walkexpr ODOTTYPE") // should see inside OAS only
} }
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
goto ret
case OCONVIFACE: case OCONVIFACE:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
...@@ -980,7 +949,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -980,7 +949,7 @@ func walkexpr(np **Node, init **NodeList) {
l.Type = n.Type l.Type = n.Type
l.Typecheck = n.Typecheck l.Typecheck = n.Typecheck
n = l n = l
goto ret break
} }
// Build name of function: convI2E etc. // Build name of function: convI2E etc.
...@@ -1045,7 +1014,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1045,7 +1014,7 @@ func walkexpr(np **Node, init **NodeList) {
l.Typecheck = n.Typecheck l.Typecheck = n.Typecheck
l.Type = n.Type l.Type = n.Type
n = l n = l
goto ret break
} }
} }
...@@ -1087,37 +1056,35 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1087,37 +1056,35 @@ func walkexpr(np **Node, init **NodeList) {
n.List = ll n.List = ll
typecheck(&n, Erv) typecheck(&n, Erv)
walkexpr(&n, init) walkexpr(&n, init)
goto ret
case OCONV, OCONVNOP: case OCONV, OCONVNOP:
if Thearch.Thechar == '5' { if Thearch.Thechar == '5' {
if Isfloat[n.Left.Type.Etype] { if Isfloat[n.Left.Type.Etype] {
if n.Type.Etype == TINT64 { if n.Type.Etype == TINT64 {
n = mkcall("float64toint64", n.Type, init, conv(n.Left, Types[TFLOAT64])) n = mkcall("float64toint64", n.Type, init, conv(n.Left, Types[TFLOAT64]))
goto ret break
} }
if n.Type.Etype == TUINT64 { if n.Type.Etype == TUINT64 {
n = mkcall("float64touint64", n.Type, init, conv(n.Left, Types[TFLOAT64])) n = mkcall("float64touint64", n.Type, init, conv(n.Left, Types[TFLOAT64]))
goto ret break
} }
} }
if Isfloat[n.Type.Etype] { if Isfloat[n.Type.Etype] {
if n.Left.Type.Etype == TINT64 { if n.Left.Type.Etype == TINT64 {
n = mkcall("int64tofloat64", n.Type, init, conv(n.Left, Types[TINT64])) n = mkcall("int64tofloat64", n.Type, init, conv(n.Left, Types[TINT64]))
goto ret break
} }
if n.Left.Type.Etype == TUINT64 { if n.Left.Type.Etype == TUINT64 {
n = mkcall("uint64tofloat64", n.Type, init, conv(n.Left, Types[TUINT64])) n = mkcall("uint64tofloat64", n.Type, init, conv(n.Left, Types[TUINT64]))
goto ret break
} }
} }
} }
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
goto ret
case OANDNOT: case OANDNOT:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
...@@ -1125,13 +1092,11 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1125,13 +1092,11 @@ func walkexpr(np **Node, init **NodeList) {
n.Right = Nod(OCOM, n.Right, nil) n.Right = Nod(OCOM, n.Right, nil)
typecheck(&n.Right, Erv) typecheck(&n.Right, Erv)
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
goto ret
case OMUL: case OMUL:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
walkmul(&n, init) walkmul(&n, init)
goto ret
case ODIV, OMOD: case ODIV, OMOD:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
...@@ -1144,12 +1109,12 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1144,12 +1109,12 @@ func walkexpr(np **Node, init **NodeList) {
t := n.Type t := n.Type
n = mkcall("complex128div", Types[TCOMPLEX128], init, conv(n.Left, Types[TCOMPLEX128]), conv(n.Right, Types[TCOMPLEX128])) n = mkcall("complex128div", Types[TCOMPLEX128], init, conv(n.Left, Types[TCOMPLEX128]), conv(n.Right, Types[TCOMPLEX128]))
n = conv(n, t) n = conv(n, t)
goto ret break
} }
// Nothing to do for float divisions. // Nothing to do for float divisions.
if Isfloat[et] { if Isfloat[et] {
goto ret break
} }
// Try rewriting as shifts or magic multiplies. // Try rewriting as shifts or magic multiplies.
...@@ -1160,7 +1125,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1160,7 +1125,7 @@ func walkexpr(np **Node, init **NodeList) {
switch n.Op { switch n.Op {
case OMOD, ODIV: case OMOD, ODIV:
if Widthreg >= 8 || (et != TUINT64 && et != TINT64) { if Widthreg >= 8 || (et != TUINT64 && et != TINT64) {
goto ret break opswitch
} }
var fn string var fn string
if et == TINT64 { if et == TINT64 {
...@@ -1174,13 +1139,8 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1174,13 +1139,8 @@ func walkexpr(np **Node, init **NodeList) {
fn += "mod" fn += "mod"
} }
n = mkcall(fn, n.Type, init, conv(n.Left, Types[et]), conv(n.Right, Types[et])) n = mkcall(fn, n.Type, init, conv(n.Left, Types[et]), conv(n.Right, Types[et]))
default:
break
} }
goto ret
case OINDEX: case OINDEX:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
...@@ -1193,7 +1153,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1193,7 +1153,7 @@ func walkexpr(np **Node, init **NodeList) {
// if range of type cannot exceed static array bound, // if range of type cannot exceed static array bound,
// disable bounds check. // disable bounds check.
if n.Bounded { if n.Bounded {
goto ret break
} }
t := n.Left.Type t := n.Left.Type
if t != nil && Isptr[t.Etype] { if t != nil && Isptr[t.Etype] {
...@@ -1232,11 +1192,10 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1232,11 +1192,10 @@ func walkexpr(np **Node, init **NodeList) {
Yyerror("index out of bounds") Yyerror("index out of bounds")
} }
} }
goto ret
case OINDEXMAP: case OINDEXMAP:
if n.Etype == 1 { if n.Etype == 1 {
goto ret break
} }
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
...@@ -1273,8 +1232,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1273,8 +1232,6 @@ func walkexpr(np **Node, init **NodeList) {
n.Type = t.Type n.Type = t.Type
n.Typecheck = 1 n.Typecheck = 1
goto ret
case ORECV: case ORECV:
Fatalf("walkexpr ORECV") // should see inside OAS only Fatalf("walkexpr ORECV") // should see inside OAS only
...@@ -1287,7 +1244,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1287,7 +1244,6 @@ func walkexpr(np **Node, init **NodeList) {
} }
walkexpr(&n.Right.Right, init) walkexpr(&n.Right.Right, init)
n = reduceSlice(n) n = reduceSlice(n)
goto ret
case OSLICE3, OSLICE3ARR: case OSLICE3, OSLICE3ARR:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
...@@ -1309,13 +1265,10 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1309,13 +1265,10 @@ func walkexpr(np **Node, init **NodeList) {
n.Op = OSLICEARR n.Op = OSLICEARR
} }
n = reduceSlice(n) n = reduceSlice(n)
goto ret
} }
goto ret
case OADDR: case OADDR:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
goto ret
case ONEW: case ONEW:
if n.Esc == EscNone { if n.Esc == EscNone {
...@@ -1333,8 +1286,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1333,8 +1286,6 @@ func walkexpr(np **Node, init **NodeList) {
n = callnew(n.Type.Type) n = callnew(n.Type.Type)
} }
goto ret
// If one argument to the comparison is an empty string, // If one argument to the comparison is an empty string,
// comparing the lengths instead will yield the same result // comparing the lengths instead will yield the same result
// without the function call. // without the function call.
...@@ -1345,7 +1296,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1345,7 +1296,7 @@ func walkexpr(np **Node, init **NodeList) {
walkexpr(&r, init) walkexpr(&r, init)
r.Type = n.Type r.Type = n.Type
n = r n = r
goto ret break
} }
// s + "badgerbadgerbadger" == "badgerbadgerbadger" // s + "badgerbadgerbadger" == "badgerbadgerbadger"
...@@ -1355,7 +1306,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1355,7 +1306,7 @@ func walkexpr(np **Node, init **NodeList) {
walkexpr(&r, init) walkexpr(&r, init)
r.Type = n.Type r.Type = n.Type
n = r n = r
goto ret break
} }
var r *Node var r *Node
...@@ -1394,11 +1345,9 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1394,11 +1345,9 @@ func walkexpr(np **Node, init **NodeList) {
} }
r.Type = n.Type r.Type = n.Type
n = r n = r
goto ret
case OADDSTR: case OADDSTR:
n = addstr(n, init) n = addstr(n, init)
goto ret
case OAPPEND: case OAPPEND:
// order should make sure we only see OAS(node, OAPPEND), which we handle above. // order should make sure we only see OAS(node, OAPPEND), which we handle above.
...@@ -1406,7 +1355,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1406,7 +1355,6 @@ func walkexpr(np **Node, init **NodeList) {
case OCOPY: case OCOPY:
n = copyany(n, init, instrumenting) n = copyany(n, init, instrumenting)
goto ret
// cannot use chanfn - closechan takes any, not chan any // cannot use chanfn - closechan takes any, not chan any
case OCLOSE: case OCLOSE:
...@@ -1414,11 +1362,9 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1414,11 +1362,9 @@ func walkexpr(np **Node, init **NodeList) {
substArgTypes(fn, n.Left.Type) substArgTypes(fn, n.Left.Type)
n = mkcall1(fn, nil, init, n.Left) n = mkcall1(fn, nil, init, n.Left)
goto ret
case OMAKECHAN: case OMAKECHAN:
n = mkcall1(chanfn("makechan", 1, n.Type), n.Type, init, typename(n.Type), conv(n.Left, Types[TINT64])) n = mkcall1(chanfn("makechan", 1, n.Type), n.Type, init, typename(n.Type), conv(n.Left, Types[TINT64]))
goto ret
case OMAKEMAP: case OMAKEMAP:
t := n.Type t := n.Type
...@@ -1449,7 +1395,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1449,7 +1395,6 @@ func walkexpr(np **Node, init **NodeList) {
substArgTypes(fn, hmap(t), mapbucket(t), t.Down, t.Type) substArgTypes(fn, hmap(t), mapbucket(t), t.Down, t.Type)
n = mkcall1(fn, n.Type, init, typename(n.Type), conv(n.Left, Types[TINT64]), a, r) n = mkcall1(fn, n.Type, init, typename(n.Type), conv(n.Left, Types[TINT64]), a, r)
goto ret
case OMAKESLICE: case OMAKESLICE:
l := n.Left l := n.Left
...@@ -1483,8 +1428,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1483,8 +1428,6 @@ func walkexpr(np **Node, init **NodeList) {
n = mkcall1(fn, n.Type, init, typename(n.Type), conv(l, Types[TINT64]), conv(r, Types[TINT64])) n = mkcall1(fn, n.Type, init, typename(n.Type), conv(l, Types[TINT64]), conv(r, Types[TINT64]))
} }
goto ret
case ORUNESTR: case ORUNESTR:
a := nodnil() a := nodnil()
if n.Esc == EscNone { if n.Esc == EscNone {
...@@ -1496,8 +1439,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1496,8 +1439,6 @@ func walkexpr(np **Node, init **NodeList) {
// intstring(*[4]byte, rune) // intstring(*[4]byte, rune)
n = mkcall("intstring", n.Type, init, a, conv(n.Left, Types[TINT64])) n = mkcall("intstring", n.Type, init, a, conv(n.Left, Types[TINT64]))
goto ret
case OARRAYBYTESTR: case OARRAYBYTESTR:
a := nodnil() a := nodnil()
if n.Esc == EscNone { if n.Esc == EscNone {
...@@ -1510,14 +1451,10 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1510,14 +1451,10 @@ func walkexpr(np **Node, init **NodeList) {
// slicebytetostring(*[32]byte, []byte) string; // slicebytetostring(*[32]byte, []byte) string;
n = mkcall("slicebytetostring", n.Type, init, a, n.Left) n = mkcall("slicebytetostring", n.Type, init, a, n.Left)
goto ret
// slicebytetostringtmp([]byte) string; // slicebytetostringtmp([]byte) string;
case OARRAYBYTESTRTMP: case OARRAYBYTESTRTMP:
n = mkcall("slicebytetostringtmp", n.Type, init, n.Left) n = mkcall("slicebytetostringtmp", n.Type, init, n.Left)
goto ret
// slicerunetostring(*[32]byte, []rune) string; // slicerunetostring(*[32]byte, []rune) string;
case OARRAYRUNESTR: case OARRAYRUNESTR:
a := nodnil() a := nodnil()
...@@ -1530,7 +1467,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1530,7 +1467,6 @@ func walkexpr(np **Node, init **NodeList) {
} }
n = mkcall("slicerunetostring", n.Type, init, a, n.Left) n = mkcall("slicerunetostring", n.Type, init, a, n.Left)
goto ret
// stringtoslicebyte(*32[byte], string) []byte; // stringtoslicebyte(*32[byte], string) []byte;
case OSTRARRAYBYTE: case OSTRARRAYBYTE:
...@@ -1544,14 +1480,11 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1544,14 +1480,11 @@ func walkexpr(np **Node, init **NodeList) {
} }
n = mkcall("stringtoslicebyte", n.Type, init, a, conv(n.Left, Types[TSTRING])) n = mkcall("stringtoslicebyte", n.Type, init, a, conv(n.Left, Types[TSTRING]))
goto ret
// stringtoslicebytetmp(string) []byte; // stringtoslicebytetmp(string) []byte;
case OSTRARRAYBYTETMP: case OSTRARRAYBYTETMP:
n = mkcall("stringtoslicebytetmp", n.Type, init, conv(n.Left, Types[TSTRING])) n = mkcall("stringtoslicebytetmp", n.Type, init, conv(n.Left, Types[TSTRING]))
goto ret
// stringtoslicerune(*[32]rune, string) []rune // stringtoslicerune(*[32]rune, string) []rune
case OSTRARRAYRUNE: case OSTRARRAYRUNE:
a := nodnil() a := nodnil()
...@@ -1564,7 +1497,6 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1564,7 +1497,6 @@ func walkexpr(np **Node, init **NodeList) {
} }
n = mkcall("stringtoslicerune", n.Type, init, a, n.Left) n = mkcall("stringtoslicerune", n.Type, init, a, n.Left)
goto ret
// ifaceeq(i1 any-1, i2 any-2) (ret bool); // ifaceeq(i1 any-1, i2 any-2) (ret bool);
case OCMPIFACE: case OCMPIFACE:
...@@ -1596,13 +1528,11 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1596,13 +1528,11 @@ func walkexpr(np **Node, init **NodeList) {
walkexpr(&r, init) walkexpr(&r, init)
r.Type = n.Type r.Type = n.Type
n = r n = r
goto ret
case OARRAYLIT, OMAPLIT, OSTRUCTLIT, OPTRLIT: case OARRAYLIT, OMAPLIT, OSTRUCTLIT, OPTRLIT:
var_ := temp(n.Type) var_ := temp(n.Type)
anylit(0, n, var_, init) anylit(0, n, var_, init)
n = var_ n = var_
goto ret
case OSEND: case OSEND:
n1 := n.Right n1 := n.Right
...@@ -1610,25 +1540,19 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1610,25 +1540,19 @@ func walkexpr(np **Node, init **NodeList) {
walkexpr(&n1, init) walkexpr(&n1, init)
n1 = Nod(OADDR, n1, nil) n1 = Nod(OADDR, n1, nil)
n = mkcall1(chanfn("chansend1", 2, n.Left.Type), nil, init, typename(n.Left.Type), n.Left, n1) n = mkcall1(chanfn("chansend1", 2, n.Left.Type), nil, init, typename(n.Left.Type), n.Left, n1)
goto ret
case OCLOSURE: case OCLOSURE:
n = walkclosure(n, init) n = walkclosure(n, init)
goto ret
case OCALLPART: case OCALLPART:
n = walkpartialcall(n, init) n = walkpartialcall(n, init)
goto ret
} }
Fatalf("missing switch %v", Oconv(int(n.Op), 0))
// Expressions that are constant at run time but not // Expressions that are constant at run time but not
// considered const by the language spec are not turned into // considered const by the language spec are not turned into
// constants until walk. For example, if n is y%1 == 0, the // constants until walk. For example, if n is y%1 == 0, the
// walk of y%1 may have replaced it by 0. // walk of y%1 may have replaced it by 0.
// Check whether n with its updated args is itself now a constant. // Check whether n with its updated args is itself now a constant.
ret:
t := n.Type t := n.Type
evconst(n) evconst(n)
......
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