]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: remove a few more unused parameters
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 3 Apr 2018 14:52:30 +0000 (15:52 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 9 Apr 2018 17:10:25 +0000 (17:10 +0000)
ssa's pos parameter on the Const* funcs is unused, so remove it.

ld's alloc parameter on elfnote is always true, so remove the arguments
and simplify the code.

Finally, arm's addpltreloc never has its return parameter used, so
remove it.

Change-Id: I63387ecf6ab7b5f7c20df36be823322bb98427b8
Reviewed-on: https://go-review.googlesource.com/104456
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/func.go
src/cmd/compile/internal/ssa/func_test.go
src/cmd/compile/internal/ssa/shortcircuit.go
src/cmd/compile/internal/ssa/writebarrier.go
src/cmd/link/internal/arm/asm.go
src/cmd/link/internal/ld/elf.go

index c6a6c275bb3eee5c40ef28d0822dcf040ca31ecf..47bfb05b9cd1311aa375eefc1a684b60734e4a0a 100644 (file)
@@ -505,35 +505,35 @@ func (s *state) entryNewValue2(op ssa.Op, t *types.Type, arg0, arg1 *ssa.Value)
 
 // const* routines add a new const value to the entry block.
 func (s *state) constSlice(t *types.Type) *ssa.Value {
-       return s.f.ConstSlice(s.peekPos(), t)
+       return s.f.ConstSlice(t)
 }
 func (s *state) constInterface(t *types.Type) *ssa.Value {
-       return s.f.ConstInterface(s.peekPos(), t)
+       return s.f.ConstInterface(t)
 }
-func (s *state) constNil(t *types.Type) *ssa.Value { return s.f.ConstNil(s.peekPos(), t) }
+func (s *state) constNil(t *types.Type) *ssa.Value { return s.f.ConstNil(t) }
 func (s *state) constEmptyString(t *types.Type) *ssa.Value {
-       return s.f.ConstEmptyString(s.peekPos(), t)
+       return s.f.ConstEmptyString(t)
 }
 func (s *state) constBool(c bool) *ssa.Value {
-       return s.f.ConstBool(s.peekPos(), types.Types[TBOOL], c)
+       return s.f.ConstBool(types.Types[TBOOL], c)
 }
 func (s *state) constInt8(t *types.Type, c int8) *ssa.Value {
-       return s.f.ConstInt8(s.peekPos(), t, c)
+       return s.f.ConstInt8(t, c)
 }
 func (s *state) constInt16(t *types.Type, c int16) *ssa.Value {
-       return s.f.ConstInt16(s.peekPos(), t, c)
+       return s.f.ConstInt16(t, c)
 }
 func (s *state) constInt32(t *types.Type, c int32) *ssa.Value {
-       return s.f.ConstInt32(s.peekPos(), t, c)
+       return s.f.ConstInt32(t, c)
 }
 func (s *state) constInt64(t *types.Type, c int64) *ssa.Value {
-       return s.f.ConstInt64(s.peekPos(), t, c)
+       return s.f.ConstInt64(t, c)
 }
 func (s *state) constFloat32(t *types.Type, c float64) *ssa.Value {
-       return s.f.ConstFloat32(s.peekPos(), t, c)
+       return s.f.ConstFloat32(t, c)
 }
 func (s *state) constFloat64(t *types.Type, c float64) *ssa.Value {
-       return s.f.ConstFloat64(s.peekPos(), t, c)
+       return s.f.ConstFloat64(t, c)
 }
 func (s *state) constInt(t *types.Type, c int64) *ssa.Value {
        if s.config.PtrSize == 8 {
@@ -545,7 +545,7 @@ func (s *state) constInt(t *types.Type, c int64) *ssa.Value {
        return s.constInt32(t, int32(c))
 }
 func (s *state) constOffPtrSP(t *types.Type, c int64) *ssa.Value {
-       return s.f.ConstOffPtrSP(s.peekPos(), t, c, s.sp)
+       return s.f.ConstOffPtrSP(t, c, s.sp)
 }
 
 // newValueOrSfCall* are wrappers around newValue*, which may create a call to a
index bde36a5b3f0f4f89d31c154509f5dbf5a8b39a32..0a74e6ef86c0a44641460fc01269f01b5cc307e2 100644 (file)
@@ -444,8 +444,7 @@ func (b *Block) NewValue4(pos src.XPos, op Op, t *types.Type, arg0, arg1, arg2,
 }
 
 // constVal returns a constant value for c.
-func (f *Func) constVal(pos src.XPos, op Op, t *types.Type, c int64, setAuxInt bool) *Value {
-       // TODO remove unused pos parameter, both here and in *func.ConstXXX callers.
+func (f *Func) constVal(op Op, t *types.Type, c int64, setAuxInt bool) *Value {
        if f.constants == nil {
                f.constants = make(map[int64][]*Value)
        }
@@ -480,48 +479,48 @@ const (
 )
 
 // ConstInt returns an int constant representing its argument.
-func (f *Func) ConstBool(pos src.XPos, t *types.Type, c bool) *Value {
+func (f *Func) ConstBool(t *types.Type, c bool) *Value {
        i := int64(0)
        if c {
                i = 1
        }
-       return f.constVal(pos, OpConstBool, t, i, true)
+       return f.constVal(OpConstBool, t, i, true)
 }
-func (f *Func) ConstInt8(pos src.XPos, t *types.Type, c int8) *Value {
-       return f.constVal(pos, OpConst8, t, int64(c), true)
+func (f *Func) ConstInt8(t *types.Type, c int8) *Value {
+       return f.constVal(OpConst8, t, int64(c), true)
 }
-func (f *Func) ConstInt16(pos src.XPos, t *types.Type, c int16) *Value {
-       return f.constVal(pos, OpConst16, t, int64(c), true)
+func (f *Func) ConstInt16(t *types.Type, c int16) *Value {
+       return f.constVal(OpConst16, t, int64(c), true)
 }
-func (f *Func) ConstInt32(pos src.XPos, t *types.Type, c int32) *Value {
-       return f.constVal(pos, OpConst32, t, int64(c), true)
+func (f *Func) ConstInt32(t *types.Type, c int32) *Value {
+       return f.constVal(OpConst32, t, int64(c), true)
 }
-func (f *Func) ConstInt64(pos src.XPos, t *types.Type, c int64) *Value {
-       return f.constVal(pos, OpConst64, t, c, true)
+func (f *Func) ConstInt64(t *types.Type, c int64) *Value {
+       return f.constVal(OpConst64, t, c, true)
 }
-func (f *Func) ConstFloat32(pos src.XPos, t *types.Type, c float64) *Value {
-       return f.constVal(pos, OpConst32F, t, int64(math.Float64bits(float64(float32(c)))), true)
+func (f *Func) ConstFloat32(t *types.Type, c float64) *Value {
+       return f.constVal(OpConst32F, t, int64(math.Float64bits(float64(float32(c)))), true)
 }
-func (f *Func) ConstFloat64(pos src.XPos, t *types.Type, c float64) *Value {
-       return f.constVal(pos, OpConst64F, t, int64(math.Float64bits(c)), true)
+func (f *Func) ConstFloat64(t *types.Type, c float64) *Value {
+       return f.constVal(OpConst64F, t, int64(math.Float64bits(c)), true)
 }
 
-func (f *Func) ConstSlice(pos src.XPos, t *types.Type) *Value {
-       return f.constVal(pos, OpConstSlice, t, constSliceMagic, false)
+func (f *Func) ConstSlice(t *types.Type) *Value {
+       return f.constVal(OpConstSlice, t, constSliceMagic, false)
 }
-func (f *Func) ConstInterface(pos src.XPos, t *types.Type) *Value {
-       return f.constVal(pos, OpConstInterface, t, constInterfaceMagic, false)
+func (f *Func) ConstInterface(t *types.Type) *Value {
+       return f.constVal(OpConstInterface, t, constInterfaceMagic, false)
 }
-func (f *Func) ConstNil(pos src.XPos, t *types.Type) *Value {
-       return f.constVal(pos, OpConstNil, t, constNilMagic, false)
+func (f *Func) ConstNil(t *types.Type) *Value {
+       return f.constVal(OpConstNil, t, constNilMagic, false)
 }
-func (f *Func) ConstEmptyString(pos src.XPos, t *types.Type) *Value {
-       v := f.constVal(pos, OpConstString, t, constEmptyStringMagic, false)
+func (f *Func) ConstEmptyString(t *types.Type) *Value {
+       v := f.constVal(OpConstString, t, constEmptyStringMagic, false)
        v.Aux = ""
        return v
 }
-func (f *Func) ConstOffPtrSP(pos src.XPos, t *types.Type, c int64, sp *Value) *Value {
-       v := f.constVal(pos, OpOffPtr, t, c, true)
+func (f *Func) ConstOffPtrSP(t *types.Type, c int64, sp *Value) *Value {
+       v := f.constVal(OpOffPtr, t, c, true)
        if len(v.Args) == 0 {
                v.AddArg(sp)
        }
index 94ff27e9f58e9332554933b468405665af216dc7..79d26c7ea274b8454d0bfff922aec7394e762503 100644 (file)
@@ -437,12 +437,12 @@ func TestConstCache(t *testing.T) {
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
                        Exit("mem")))
-       v1 := f.f.ConstBool(src.NoXPos, c.config.Types.Bool, false)
-       v2 := f.f.ConstBool(src.NoXPos, c.config.Types.Bool, true)
+       v1 := f.f.ConstBool(c.config.Types.Bool, false)
+       v2 := f.f.ConstBool(c.config.Types.Bool, true)
        f.f.freeValue(v1)
        f.f.freeValue(v2)
-       v3 := f.f.ConstBool(src.NoXPos, c.config.Types.Bool, false)
-       v4 := f.f.ConstBool(src.NoXPos, c.config.Types.Bool, true)
+       v3 := f.f.ConstBool(c.config.Types.Bool, false)
+       v4 := f.f.ConstBool(c.config.Types.Bool, true)
        if v3.AuxInt != 0 {
                t.Errorf("expected %s to have auxint of 0\n", v3.LongString())
        }
index 506be4e7a0752c3d142ca1b967033131389c67ea..5be1ec98f9948d3b9d53916c6becc9ac243fb206 100644 (file)
@@ -37,12 +37,12 @@ func shortcircuit(f *Func) {
                                }
                                if e.i == 0 {
                                        if ct == nil {
-                                               ct = f.ConstBool(f.Entry.Pos, f.Config.Types.Bool, true)
+                                               ct = f.ConstBool(f.Config.Types.Bool, true)
                                        }
                                        v.SetArg(i, ct)
                                } else {
                                        if cf == nil {
-                                               cf = f.ConstBool(f.Entry.Pos, f.Config.Types.Bool, false)
+                                               cf = f.ConstBool(f.Config.Types.Bool, false)
                                        }
                                        v.SetArg(i, cf)
                                }
index c41a6771598c5bb78d8ec36d1afd29539d12e3d7..b11b87de23c8daab5bb720dc2d63744dd2707d9c 100644 (file)
@@ -99,7 +99,7 @@ func writebarrier(f *Func) {
                        gcWriteBarrier = f.fe.Syslook("gcWriteBarrier")
                        typedmemmove = f.fe.Syslook("typedmemmove")
                        typedmemclr = f.fe.Syslook("typedmemclr")
-                       const0 = f.ConstInt32(initpos, f.Config.Types.UInt32, 0)
+                       const0 = f.ConstInt32(f.Config.Types.UInt32, 0)
 
                        // allocate auxiliary data structures for computing store order
                        sset = f.newSparseSet(f.NumValues())
index d0bebce4bb57787a8da2828b2c009caab4d311b6..9932d56e1a55172563c18c4ef18eff2bd1381d0a 100644 (file)
@@ -649,7 +649,7 @@ func archrelocvariant(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, t int64) int64
        return t
 }
 
-func addpltreloc(ctxt *ld.Link, plt *sym.Symbol, got *sym.Symbol, s *sym.Symbol, typ objabi.RelocType) *sym.Reloc {
+func addpltreloc(ctxt *ld.Link, plt *sym.Symbol, got *sym.Symbol, s *sym.Symbol, typ objabi.RelocType) {
        r := plt.AddRel()
        r.Sym = got
        r.Off = int32(plt.Size)
@@ -660,8 +660,6 @@ func addpltreloc(ctxt *ld.Link, plt *sym.Symbol, got *sym.Symbol, s *sym.Symbol,
        plt.Attr |= sym.AttrReachable
        plt.Size += 4
        plt.Grow(plt.Size)
-
-       return r
 }
 
 func addpltsym(ctxt *ld.Link, s *sym.Symbol) {
index 817ba4693b539f6c1b0f0148e1e0dd2242dd48e7..231c00d3c1592fd0360e8b907a14abfc2d77f546 100644 (file)
@@ -791,13 +791,11 @@ func elfwriteinterp(out *OutBuf) int {
        return int(sh.size)
 }
 
-func elfnote(sh *ElfShdr, startva uint64, resoff uint64, sz int, alloc bool) int {
+func elfnote(sh *ElfShdr, startva uint64, resoff uint64, sz int) int {
        n := 3*4 + uint64(sz) + resoff%4
 
        sh.type_ = SHT_NOTE
-       if alloc {
-               sh.flags = SHF_ALLOC
-       }
+       sh.flags = SHF_ALLOC
        sh.addralign = 4
        sh.addr = startva + resoff - n
        sh.off = resoff - n
@@ -831,7 +829,7 @@ var ELF_NOTE_NETBSD_NAME = []byte("NetBSD\x00")
 
 func elfnetbsdsig(sh *ElfShdr, startva uint64, resoff uint64) int {
        n := int(Rnd(ELF_NOTE_NETBSD_NAMESZ, 4) + Rnd(ELF_NOTE_NETBSD_DESCSZ, 4))
-       return elfnote(sh, startva, resoff, n, true)
+       return elfnote(sh, startva, resoff, n)
 }
 
 func elfwritenetbsdsig(out *OutBuf) int {
@@ -862,7 +860,7 @@ var ELF_NOTE_OPENBSD_NAME = []byte("OpenBSD\x00")
 
 func elfopenbsdsig(sh *ElfShdr, startva uint64, resoff uint64) int {
        n := ELF_NOTE_OPENBSD_NAMESZ + ELF_NOTE_OPENBSD_DESCSZ
-       return elfnote(sh, startva, resoff, n, true)
+       return elfnote(sh, startva, resoff, n)
 }
 
 func elfwriteopenbsdsig(out *OutBuf) int {
@@ -918,12 +916,12 @@ var ELF_NOTE_BUILDINFO_NAME = []byte("GNU\x00")
 
 func elfbuildinfo(sh *ElfShdr, startva uint64, resoff uint64) int {
        n := int(ELF_NOTE_BUILDINFO_NAMESZ + Rnd(int64(len(buildinfo)), 4))
-       return elfnote(sh, startva, resoff, n, true)
+       return elfnote(sh, startva, resoff, n)
 }
 
 func elfgobuildid(sh *ElfShdr, startva uint64, resoff uint64) int {
        n := len(ELF_NOTE_GO_NAME) + int(Rnd(int64(len(*flagBuildid)), 4))
-       return elfnote(sh, startva, resoff, n, true)
+       return elfnote(sh, startva, resoff, n)
 }
 
 func elfwritebuildinfo(out *OutBuf) int {