From 7c61d24f9738204688b1f4b880b0a8415d0833e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?H=C3=A5vard=20Haugen?= Date: Sun, 13 Sep 2015 23:57:28 +0200 Subject: [PATCH] cmd/compile/internal/gc: remove dead code Found with https://github.com/remyoudompheng/go-misc/deadcode: deadcode: walk.go:2228:1: applywritebarrier_bv is unused deadcode: subr.go:355:1: gethunk is unused deadcode: subr.go:1991:1: localexpr is unused deadcode: dcl.go:82:1: poptodcl is unused deadcode: swt.go:810:1: dumpcase is unused deadcode: esc.go:251:1: satAdd8 is unused deadcode: esc.go:387:1: outputsPerTag is unused deadcode: obj.go:190:1: duint64 is unused deadcode: obj.go:287:1: dstringptr is unused deadcode: plive.go:95:1: xmalloc is unused deadcode: plive.go:119:1: freeblock is unused followed by deadcode: go.go:633:1: hunk is unused deadcode: go.go:635:1: nhunk is unused deadcode: go.go:637:1: thunk is unused after 'gethunk' was removed. Some dead code in bv.go, mparith3.go, and dcl.go was left as is. Passes go build -a -toolexec 'toolstash -cmp' std cmd. Change-Id: Ia63519adedc8650d7095572ddd454fd923d3204d Reviewed-on: https://go-review.googlesource.com/14610 Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/dcl.go | 10 ------- src/cmd/compile/internal/gc/esc.go | 18 ++---------- src/cmd/compile/internal/gc/go.go | 6 ---- src/cmd/compile/internal/gc/obj.go | 23 ---------------- src/cmd/compile/internal/gc/plive.go | 15 ---------- src/cmd/compile/internal/gc/subr.go | 30 -------------------- src/cmd/compile/internal/gc/swt.go | 41 ---------------------------- src/cmd/compile/internal/gc/walk.go | 2 -- 8 files changed, 3 insertions(+), 142 deletions(-) diff --git a/src/cmd/compile/internal/gc/dcl.go b/src/cmd/compile/internal/gc/dcl.go index 06092742fa..92b09e62b3 100644 --- a/src/cmd/compile/internal/gc/dcl.go +++ b/src/cmd/compile/internal/gc/dcl.go @@ -79,16 +79,6 @@ func popdcl() { block = d.Block } -func poptodcl() { - // pop the old marker and push a new one - // (cannot reuse the existing one) - // because we use the markers to identify blocks - // for the goto restriction checks. - popdcl() - - markdcl() -} - func markdcl() { d := push() d.Name = "" // used as a mark in fifo diff --git a/src/cmd/compile/internal/gc/esc.go b/src/cmd/compile/internal/gc/esc.go index 585b327c9a..d07f4733c0 100644 --- a/src/cmd/compile/internal/gc/esc.go +++ b/src/cmd/compile/internal/gc/esc.go @@ -248,17 +248,6 @@ func satInc8(x int8) int8 { return x + 1 } -func satAdd8(x, y int8) int8 { - z := x + y - if x^y < 0 || x^z >= 0 { - return z - } - if x < 0 { - return -128 - } - return 127 -} - func min8(a, b int8) int8 { if a < b { return a @@ -385,10 +374,9 @@ func escMax(e, etype uint16) uint16 { // something whose address is returned -- but that implies stored into the heap, // hence EscHeap, which means that the details are not currently relevant. ) const ( - bitsPerOutputInTag = 3 // For each output, the number of bits for a tag - bitsMaskForTag = uint16(1<= 10*NHUNK { - nh = 10 * NHUNK - } - h := string(make([]byte, nh)) - if h == "" { - Flusherrors() - Yyerror("out of memory") - errorexit() - } - - hunk = h - nhunk = nh - thunk += nh -} - func Nod(op int, nleft *Node, nright *Node) *Node { n := new(Node) n.Op = uint8(op) @@ -1966,19 +1949,6 @@ func cheapexpr(n *Node, init **NodeList) *Node { return copyexpr(n, n.Type, init) } -/* - * return n in a local variable of type t if it is not already. - * the value is guaranteed not to change except by direct - * assignment to it. - */ -func localexpr(n *Node, t *Type, init **NodeList) *Node { - if n.Op == ONAME && (!n.Addrtaken || strings.HasPrefix(n.Sym.Name, "autotmp_")) && (n.Class == PAUTO || n.Class == PPARAM || n.Class == PPARAMOUT) && convertop(n.Type, t, nil) == OCONVNOP { - return n - } - - return copyexpr(n, t, init) -} - func Setmaxarg(t *Type, extra int32) { dowidth(t) w := t.Argwid diff --git a/src/cmd/compile/internal/gc/swt.go b/src/cmd/compile/internal/gc/swt.go index a0e0c4158d..f5952fc3dc 100644 --- a/src/cmd/compile/internal/gc/swt.go +++ b/src/cmd/compile/internal/gc/swt.go @@ -6,7 +6,6 @@ package gc import ( "cmd/internal/obj" - "fmt" "sort" "strconv" ) @@ -806,43 +805,3 @@ func (x caseClauseByType) Less(i, j int) bool { // sort by ordinal return c1.ordinal < c2.ordinal } - -func dumpcase(cc []*caseClause) { - for _, c := range cc { - switch c.typ { - case caseKindDefault: - fmt.Printf("case-default\n") - fmt.Printf("\tord=%d\n", c.ordinal) - - case caseKindExprConst: - fmt.Printf("case-exprconst\n") - fmt.Printf("\tord=%d\n", c.ordinal) - - case caseKindExprVar: - fmt.Printf("case-exprvar\n") - fmt.Printf("\tord=%d\n", c.ordinal) - fmt.Printf("\top=%v\n", Oconv(int(c.node.Left.Op), 0)) - - case caseKindTypeNil: - fmt.Printf("case-typenil\n") - fmt.Printf("\tord=%d\n", c.ordinal) - - case caseKindTypeConst: - fmt.Printf("case-typeconst\n") - fmt.Printf("\tord=%d\n", c.ordinal) - fmt.Printf("\thash=%x\n", c.hash) - - case caseKindTypeVar: - fmt.Printf("case-typevar\n") - fmt.Printf("\tord=%d\n", c.ordinal) - - default: - fmt.Printf("case-???\n") - fmt.Printf("\tord=%d\n", c.ordinal) - fmt.Printf("\top=%v\n", Oconv(int(c.node.Left.Op), 0)) - fmt.Printf("\thash=%x\n", c.hash) - } - } - - fmt.Printf("\n") -} diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go index ae19e6fda5..4ce1db6241 100644 --- a/src/cmd/compile/internal/gc/walk.go +++ b/src/cmd/compile/internal/gc/walk.go @@ -2225,8 +2225,6 @@ func needwritebarrier(l *Node, r *Node) bool { // TODO(rsc): Perhaps componentgen should run before this. -var applywritebarrier_bv Bvec - func applywritebarrier(n *Node, init **NodeList) *Node { if n.Left != nil && n.Right != nil && needwritebarrier(n.Left, n.Right) { if Debug_wb > 1 { -- 2.48.1