Skip to content

Commit

Permalink
cmd/compile: remove some unused parameters
Browse files Browse the repository at this point in the history
As reported by unparam.

Passes toolstash -cmp on std cmd.

Change-Id: I55473e1eed096ed1c3e431aed2cbf0b6b5444b91
Reviewed-on: https://go-review.googlesource.com/97895
Reviewed-by: Matthew Dempsky <[email protected]>
  • Loading branch information
mvdan committed Mar 13, 2018
1 parent 518e6f0 commit ca9abbb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/gc/dwinl.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type varPos struct {
// This is the main entry point for collection of raw material to
// drive generation of DWARF "inlined subroutine" DIEs. See proposal
// 22080 for more details and background info.
func assembleInlines(fnsym *obj.LSym, fn *Node, dwVars []*dwarf.Var) dwarf.InlCalls {
func assembleInlines(fnsym *obj.LSym, dwVars []*dwarf.Var) dwarf.InlCalls {
var inlcalls dwarf.InlCalls

if Debug_gendwarfinl != 0 {
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/gc/obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ func dsymptr(s *obj.LSym, off int, x *obj.LSym, xoff int) int {
return off
}

func dsymptrOff(s *obj.LSym, off int, x *obj.LSym, xoff int) int {
s.WriteOff(Ctxt, int64(off), x, int64(xoff))
func dsymptrOff(s *obj.LSym, off int, x *obj.LSym) int {
s.WriteOff(Ctxt, int64(off), x, 0)
off += 4
return off
}
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/compile/internal/gc/pgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func debuginfo(fnsym *obj.LSym, curfn interface{}) ([]dwarf.Scope, dwarf.InlCall
scopes := assembleScopes(fnsym, fn, dwarfVars, varScopes)
var inlcalls dwarf.InlCalls
if genDwarfInline > 0 {
inlcalls = assembleInlines(fnsym, fn, dwarfVars)
inlcalls = assembleInlines(fnsym, dwarfVars)
}
return scopes, inlcalls
}
Expand Down Expand Up @@ -457,7 +457,7 @@ func createSimpleVars(automDecls []*Node) ([]*Node, []*dwarf.Var, map[*Node]bool

// createComplexVars creates recomposed DWARF vars with location lists,
// suitable for describing optimized code.
func createComplexVars(fnsym *obj.LSym, fn *Func, automDecls []*Node) ([]*Node, []*dwarf.Var, map[*Node]bool) {
func createComplexVars(fn *Func) ([]*Node, []*dwarf.Var, map[*Node]bool) {
debugInfo := fn.DebugInfo

// Produce a DWARF variable entry for each user variable.
Expand Down Expand Up @@ -489,7 +489,7 @@ func createDwarfVars(fnsym *obj.LSym, fn *Func, automDecls []*Node) ([]*Node, []
var decls []*Node
var selected map[*Node]bool
if Ctxt.Flag_locationlists && Ctxt.Flag_optimize && fn.DebugInfo != nil {
decls, vars, selected = createComplexVars(fnsym, fn, automDecls)
decls, vars, selected = createComplexVars(fn)
} else {
decls, vars, selected = createSimpleVars(automDecls)
}
Expand Down
13 changes: 5 additions & 8 deletions src/cmd/compile/internal/gc/racewalk.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,14 @@ func isartificial(n *Node) bool {
return false
}

func callinstr(np **Node, init *Nodes, wr int, skip int) bool {
func callinstr(np **Node, init *Nodes, wr int, skip int) {
n := *np

//fmt.Printf("callinstr for %v [ %v ] etype=%v class=%v\n",
// n, n.Op, n.Type.Etype, n.Class)

if skip != 0 || n.Type == nil || n.Type.Etype >= TIDEAL {
return false
return
}
t := n.Type
// dowidth may not have been called for PEXTERN.
Expand All @@ -441,17 +441,17 @@ func callinstr(np **Node, init *Nodes, wr int, skip int) bool {
Fatalf("instrument: %v badwidth", t)
}
if w == 0 {
return false // can't race on zero-sized things
return // can't race on zero-sized things
}
if isartificial(n) {
return false
return
}

b := outervalue(n)

// it skips e.g. stores to ... parameter array
if isartificial(b) {
return false
return
}
class := b.Class()

Expand Down Expand Up @@ -502,10 +502,7 @@ func callinstr(np **Node, init *Nodes, wr int, skip int) bool {
}

init.Append(f)
return true
}

return false
}

// makeaddable returns a node whose memory location is the
Expand Down
45 changes: 21 additions & 24 deletions src/cmd/compile/internal/gc/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,11 @@ func dgopkgpathOff(s *obj.LSym, ot int, pkg *types.Pkg) int {
// Every package that imports this one directly defines the symbol.
// See also https://groups.google.com/forum/#!topic/golang-dev/myb9s53HxGQ.
ns := Ctxt.Lookup(`type..importpath."".`)
return dsymptrOff(s, ot, ns, 0)
return dsymptrOff(s, ot, ns)
}

dimportpath(pkg)
return dsymptrOff(s, ot, pkg.Pathsym, 0)
return dsymptrOff(s, ot, pkg.Pathsym)
}

// dnameField dumps a reflect.name for a struct field.
Expand Down Expand Up @@ -723,7 +723,7 @@ func dextratypeData(lsym *obj.LSym, ot int, t *types.Type) int {
}
nsym := dname(a.name, "", pkg, exported)

ot = dsymptrOff(lsym, ot, nsym, 0)
ot = dsymptrOff(lsym, ot, nsym)
ot = dmethodptrOff(lsym, ot, dtypesym(a.mtype))
ot = dmethodptrOff(lsym, ot, a.isym.Linksym())
ot = dmethodptrOff(lsym, ot, a.tsym.Linksym())
Expand Down Expand Up @@ -841,11 +841,7 @@ var (
)

// dcommontype dumps the contents of a reflect.rtype (runtime._type).
func dcommontype(lsym *obj.LSym, ot int, t *types.Type) int {
if ot != 0 {
Fatalf("dcommontype %d", ot)
}

func dcommontype(lsym *obj.LSym, t *types.Type) int {
sizeofAlg := 2 * Widthptr
if algarray == nil {
algarray = sysfunc("algarray")
Expand Down Expand Up @@ -884,6 +880,7 @@ func dcommontype(lsym *obj.LSym, ot int, t *types.Type) int {
// str nameOff
// ptrToThis typeOff
// }
ot := 0
ot = duintptr(lsym, ot, uint64(t.Width))
ot = duintptr(lsym, ot, uint64(ptrdata))
ot = duint32(lsym, ot, typehash(t))
Expand Down Expand Up @@ -948,14 +945,14 @@ func dcommontype(lsym *obj.LSym, ot int, t *types.Type) int {
ot = dsymptr(lsym, ot, gcsym, 0) // gcdata

nsym := dname(p, "", nil, exported)
ot = dsymptrOff(lsym, ot, nsym, 0) // str
ot = dsymptrOff(lsym, ot, nsym) // str
// ptrToThis
if sptr == nil {
ot = duint32(lsym, ot, 0)
} else if sptrWeak {
ot = dsymptrWeakOff(lsym, ot, sptr)
} else {
ot = dsymptrOff(lsym, ot, sptr, 0)
ot = dsymptrOff(lsym, ot, sptr)
}

return ot
Expand Down Expand Up @@ -1186,15 +1183,15 @@ func dtypesym(t *types.Type) *obj.LSym {
ot := 0
switch t.Etype {
default:
ot = dcommontype(lsym, ot, t)
ot = dcommontype(lsym, t)
ot = dextratype(lsym, ot, t, 0)

case TARRAY:
// ../../../../runtime/type.go:/arrayType
s1 := dtypesym(t.Elem())
t2 := types.NewSlice(t.Elem())
s2 := dtypesym(t2)
ot = dcommontype(lsym, ot, t)
ot = dcommontype(lsym, t)
ot = dsymptr(lsym, ot, s1, 0)
ot = dsymptr(lsym, ot, s2, 0)
ot = duintptr(lsym, ot, uint64(t.NumElem()))
Expand All @@ -1203,14 +1200,14 @@ func dtypesym(t *types.Type) *obj.LSym {
case TSLICE:
// ../../../../runtime/type.go:/sliceType
s1 := dtypesym(t.Elem())
ot = dcommontype(lsym, ot, t)
ot = dcommontype(lsym, t)
ot = dsymptr(lsym, ot, s1, 0)
ot = dextratype(lsym, ot, t, 0)

case TCHAN:
// ../../../../runtime/type.go:/chanType
s1 := dtypesym(t.Elem())
ot = dcommontype(lsym, ot, t)
ot = dcommontype(lsym, t)
ot = dsymptr(lsym, ot, s1, 0)
ot = duintptr(lsym, ot, uint64(t.ChanDir()))
ot = dextratype(lsym, ot, t, 0)
Expand All @@ -1228,7 +1225,7 @@ func dtypesym(t *types.Type) *obj.LSym {
dtypesym(t1.Type)
}

ot = dcommontype(lsym, ot, t)
ot = dcommontype(lsym, t)
inCount := t.NumRecvs() + t.NumParams()
outCount := t.NumResults()
if isddd {
Expand Down Expand Up @@ -1262,7 +1259,7 @@ func dtypesym(t *types.Type) *obj.LSym {
}

// ../../../../runtime/type.go:/interfaceType
ot = dcommontype(lsym, ot, t)
ot = dcommontype(lsym, t)

var tpkg *types.Pkg
if t.Sym != nil && t != types.Types[t.Etype] && t != types.Errortype {
Expand All @@ -1285,8 +1282,8 @@ func dtypesym(t *types.Type) *obj.LSym {
}
nsym := dname(a.name, "", pkg, exported)

ot = dsymptrOff(lsym, ot, nsym, 0)
ot = dsymptrOff(lsym, ot, dtypesym(a.type_), 0)
ot = dsymptrOff(lsym, ot, nsym)
ot = dsymptrOff(lsym, ot, dtypesym(a.type_))
}

// ../../../../runtime/type.go:/mapType
Expand All @@ -1295,7 +1292,7 @@ func dtypesym(t *types.Type) *obj.LSym {
s2 := dtypesym(t.Val())
s3 := dtypesym(bmap(t))
s4 := dtypesym(hmap(t))
ot = dcommontype(lsym, ot, t)
ot = dcommontype(lsym, t)
ot = dsymptr(lsym, ot, s1, 0)
ot = dsymptr(lsym, ot, s2, 0)
ot = dsymptr(lsym, ot, s3, 0)
Expand Down Expand Up @@ -1324,7 +1321,7 @@ func dtypesym(t *types.Type) *obj.LSym {
case TPTR32, TPTR64:
if t.Elem().Etype == TANY {
// ../../../../runtime/type.go:/UnsafePointerType
ot = dcommontype(lsym, ot, t)
ot = dcommontype(lsym, t)
ot = dextratype(lsym, ot, t, 0)

break
Expand All @@ -1333,7 +1330,7 @@ func dtypesym(t *types.Type) *obj.LSym {
// ../../../../runtime/type.go:/ptrType
s1 := dtypesym(t.Elem())

ot = dcommontype(lsym, ot, t)
ot = dcommontype(lsym, t)
ot = dsymptr(lsym, ot, s1, 0)
ot = dextratype(lsym, ot, t, 0)

Expand All @@ -1358,7 +1355,7 @@ func dtypesym(t *types.Type) *obj.LSym {
}
}

ot = dcommontype(lsym, ot, t)
ot = dcommontype(lsym, t)
ot = dgopkgpath(lsym, ot, spkg)
ot = dsymptr(lsym, ot, lsym, ot+3*Widthptr+uncommonSize(t))
ot = duintptr(lsym, ot, uint64(len(fields)))
Expand Down Expand Up @@ -1554,8 +1551,8 @@ func dumptabs() {
// typ typeOff // pointer to symbol
// }
nsym := dname(p.s.Name, "", nil, true)
ot = dsymptrOff(s, ot, nsym, 0)
ot = dsymptrOff(s, ot, dtypesym(p.t), 0)
ot = dsymptrOff(s, ot, nsym)
ot = dsymptrOff(s, ot, dtypesym(p.t))
}
ggloblsym(s, int32(ot), int16(obj.RODATA))

Expand Down

0 comments on commit ca9abbb

Please sign in to comment.