]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/gc: remove dead code
authorHÃ¥vard Haugen <havard.haugen@gmail.com>
Sun, 13 Sep 2015 21:57:28 +0000 (23:57 +0200)
committerIan Lance Taylor <iant@golang.org>
Wed, 16 Sep 2015 00:25:04 +0000 (00:25 +0000)
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 <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/esc.go
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/obj.go
src/cmd/compile/internal/gc/plive.go
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/swt.go
src/cmd/compile/internal/gc/walk.go

index 06092742fa95bc00b6f7ea136068729113802b5d..92b09e62b3cd59fcb01e26bc9670a70a69c2f6a0 100644 (file)
@@ -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
index 585b327c9adde5119b67bd3c097dc999cdcd83c7..d07f4733c02e98cd65a960ac67ca390ded04897a 100644 (file)
@@ -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<<bitsPerOutputInTag) - 1         // The bit mask to extract a single tag.
-       outputsPerTag      = (16 - EscReturnBits) / bitsPerOutputInTag // The number of outputs that can be tagged.
-       maxEncodedLevel    = int(bitsMaskForTag - 1)                   // The largest level that can be stored in a tag.
+       bitsPerOutputInTag = 3                                 // For each output, the number of bits for a tag
+       bitsMaskForTag     = uint16(1<<bitsPerOutputInTag) - 1 // The bit mask to extract a single tag.
+       maxEncodedLevel    = int(bitsMaskForTag - 1)           // The largest level that can be stored in a tag.
 )
 
 type EscState struct {
index f3cf17306b61bdd34496a3e81745828d54c0397c..91c2d7695826e83f8d4c663f058a124fe4bb32cd 100644 (file)
@@ -630,12 +630,6 @@ var typesw *Node
 
 var nblank *Node
 
-var hunk string
-
-var nhunk int32
-
-var thunk int32
-
 var Funcdepth int32
 
 var typecheckok bool
index ec7400968130f707568198176dc5ef2a61946747..484c776b550491bfc84b5054f92e02b1c6048cd1 100644 (file)
@@ -187,10 +187,6 @@ func duint32(s *Sym, off int, v uint32) int {
        return duintxx(s, off, uint64(v), 4)
 }
 
-func duint64(s *Sym, off int, v uint64) int {
-       return duintxx(s, off, v, 8)
-}
-
 func duintptr(s *Sym, off int, v uint64) int {
        return duintxx(s, off, v, Widthptr)
 }
@@ -284,25 +280,6 @@ func slicebytes(nam *Node, s string, len int) {
        duintxx(nam.Sym, off, uint64(len), Widthint)
 }
 
-func dstringptr(s *Sym, off int, str string) int {
-       off = int(Rnd(int64(off), int64(Widthptr)))
-       p := Thearch.Gins(obj.ADATA, nil, nil)
-       p.From.Type = obj.TYPE_MEM
-       p.From.Name = obj.NAME_EXTERN
-       p.From.Sym = Linksym(s)
-       p.From.Offset = int64(off)
-       p.From3 = new(obj.Addr)
-       p.From3.Type = obj.TYPE_CONST
-       p.From3.Offset = int64(Widthptr)
-
-       Datastring(str+"\x00", &p.To) // TODO(rsc): Remove NUL
-       p.To.Type = obj.TYPE_ADDR
-       p.To.Etype = Simtype[TINT]
-       off += Widthptr
-
-       return off
-}
-
 func Datastring(s string, a *obj.Addr) {
        _, symdata := stringsym(s)
        a.Type = obj.TYPE_MEM
index fa8bc20f14ef869a61b42b887c8b6fa2dc201036..4d7f0f72a907579fb22e513c04cb04ced368ad17 100644 (file)
@@ -92,14 +92,6 @@ type Liveness struct {
        livepointers     []Bvec
 }
 
-func xmalloc(size uint32) interface{} {
-       result := (interface{})(make([]byte, size))
-       if result == nil {
-               Fatalf("malloc failed")
-       }
-       return result
-}
-
 // Constructs a new basic block containing a single instruction.
 func newblock(prog *obj.Prog) *BasicBlock {
        if prog == nil {
@@ -115,13 +107,6 @@ func newblock(prog *obj.Prog) *BasicBlock {
        return result
 }
 
-// Frees a basic block and all of its leaf data structures.
-func freeblock(bb *BasicBlock) {
-       if bb == nil {
-               Fatalf("freeblock: cannot free nil")
-       }
-}
-
 // Adds an edge between two basic blocks by making from a predecessor of to and
 // to a successor of from.
 func addedge(from *BasicBlock, to *BasicBlock) {
index 312c95f825c84ca22da7e9082e6e79cfc4124b1e..b056023c0e060be33ff95ad55d07c943ccdf58e6 100644 (file)
@@ -347,23 +347,6 @@ func importdot(opkg *Pkg, pack *Node) {
        }
 }
 
-func gethunk() {
-       nh := int32(NHUNK)
-       if thunk >= 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
index a0e0c4158d5585442752fba2ab0386e708042150..f5952fc3dc458bd0f84c74ca2ecc3af995f9971d 100644 (file)
@@ -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")
-}
index ae19e6fda58e98fca52ec6ce339e52eb5061058c..4ce1db6241488227176827f11de0ab8cc2bc6ff9 100644 (file)
@@ -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 {