]> Cypherpunks repositories - gostls13.git/commitdiff
all: eliminate unnecessary type conversions
authorJes Cok <xigua67damn@gmail.com>
Sun, 19 Oct 2025 19:53:27 +0000 (19:53 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 21 Oct 2025 15:13:08 +0000 (08:13 -0700)
Found by github.com/mdempsky/unconvert

Change-Id: I88ce10390a49ba768a4deaa0df9057c93c1164de
GitHub-Last-Rev: 3b0f7e8f74f58340637f33287c238765856b2483
GitHub-Pull-Request: golang/go#75974
Reviewed-on: https://go-review.googlesource.com/c/go/+/712940
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
61 files changed:
src/cmd/asm/internal/asm/asm.go
src/cmd/cgo/gcc.go
src/cmd/cgo/internal/swig/swig_test.go
src/cmd/cgo/internal/testcarchive/carchive_test.go
src/cmd/cgo/internal/testcshared/cshared_test.go
src/cmd/cgo/internal/testerrors/badsym_test.go
src/cmd/compile/internal/coverage/cover.go
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/ir/bitset.go
src/cmd/compile/internal/loong64/ssa.go
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/ppc64/ssa.go
src/cmd/compile/internal/ssa/biasedsparsemap.go
src/cmd/compile/internal/ssa/debug.go
src/cmd/compile/internal/ssa/magic_test.go
src/cmd/compile/internal/ssa/memcombine.go
src/cmd/compile/internal/ssa/rewrite.go
src/cmd/compile/internal/ssa/sccp.go
src/cmd/compile/internal/test/divconst_test.go
src/cmd/go/internal/modindex/build.go
src/cmd/go/internal/vcs/vcs.go
src/cmd/go/internal/vet/vet.go
src/cmd/internal/buildid/rewrite.go
src/cmd/internal/goobj/objfile.go
src/cmd/internal/obj/arm/a.out.go
src/cmd/internal/obj/arm64/asm7.go
src/cmd/internal/obj/dwarf.go
src/cmd/internal/obj/link.go
src/cmd/internal/obj/loong64/a.out.go
src/cmd/internal/obj/mips/a.out.go
src/cmd/internal/obj/objfile.go
src/cmd/internal/obj/ppc64/a.out.go
src/cmd/internal/obj/ppc64/asm9.go
src/cmd/internal/obj/riscv/obj.go
src/cmd/internal/obj/s390x/a.out.go
src/cmd/internal/obj/s390x/asmz.go
src/cmd/internal/obj/s390x/rotate.go
src/cmd/internal/obj/x86/asm6.go
src/cmd/internal/obj/x86/asm_test.go
src/cmd/internal/objfile/goobj.go
src/cmd/internal/objfile/xcoff.go
src/cmd/link/internal/amd64/asm.go
src/cmd/link/internal/arm/asm.go
src/cmd/link/internal/arm64/asm.go
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/ld/elf.go
src/cmd/link/internal/ld/macho.go
src/cmd/link/internal/ld/pcln.go
src/cmd/link/internal/ld/pe.go
src/cmd/link/internal/ld/xcoff.go
src/cmd/link/internal/loadelf/ldelf.go
src/cmd/link/internal/loader/loader.go
src/cmd/link/internal/loong64/asm.go
src/cmd/link/internal/mips64/asm.go
src/cmd/link/internal/ppc64/asm.go
src/cmd/link/internal/riscv64/asm.go
src/cmd/link/internal/wasm/asm.go
src/cmd/trace/gstate.go
src/net/cgo_unix_syscall.go
src/runtime/metrics.go

index 389307af29ea533c5ed7ba18072693226c1cafe6..0f75edf4e5d2541d1819f73f01be36b69f637f89 100644 (file)
@@ -248,7 +248,7 @@ func (p *Parser) asmData(operands [][]lex.Token) {
        case obj.TYPE_CONST:
                switch sz {
                case 1, 2, 4, 8:
-                       nameAddr.Sym.WriteInt(p.ctxt, nameAddr.Offset, int(sz), valueAddr.Offset)
+                       nameAddr.Sym.WriteInt(p.ctxt, nameAddr.Offset, sz, valueAddr.Offset)
                default:
                        p.errorf("bad int size for DATA argument: %d", sz)
                }
@@ -262,10 +262,10 @@ func (p *Parser) asmData(operands [][]lex.Token) {
                        p.errorf("bad float size for DATA argument: %d", sz)
                }
        case obj.TYPE_SCONST:
-               nameAddr.Sym.WriteString(p.ctxt, nameAddr.Offset, int(sz), valueAddr.Val.(string))
+               nameAddr.Sym.WriteString(p.ctxt, nameAddr.Offset, sz, valueAddr.Val.(string))
        case obj.TYPE_ADDR:
                if sz == p.arch.PtrSize {
-                       nameAddr.Sym.WriteAddr(p.ctxt, nameAddr.Offset, int(sz), valueAddr.Sym, valueAddr.Offset)
+                       nameAddr.Sym.WriteAddr(p.ctxt, nameAddr.Offset, sz, valueAddr.Sym, valueAddr.Offset)
                } else {
                        p.errorf("bad addr size for DATA argument: %d", sz)
                }
index 6c1695bdb0a6133400d719c44b6cbfd4e04ba3ed..886ddf2d461b6508e4aba10dd340c585a4108689 100644 (file)
@@ -2154,7 +2154,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
                for _, s := range f.Symbols {
                        switch {
                        case isDebugInts(s.Name):
-                               if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
+                               if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
                                        sect := f.Sections[i]
                                        if s.Value < sect.Size {
                                                if sdat, err := sect.Data(); err == nil {
@@ -2167,7 +2167,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
                                        }
                                }
                        case isDebugFloats(s.Name):
-                               if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
+                               if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
                                        sect := f.Sections[i]
                                        if s.Value < sect.Size {
                                                if sdat, err := sect.Data(); err == nil {
@@ -2181,7 +2181,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
                                }
                        default:
                                if n := indexOfDebugStr(s.Name); n != -1 {
-                                       if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
+                                       if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
                                                sect := f.Sections[i]
                                                if s.Value < sect.Size {
                                                        if sdat, err := sect.Data(); err == nil {
@@ -2193,7 +2193,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
                                        break
                                }
                                if n := indexOfDebugStrlen(s.Name); n != -1 {
-                                       if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
+                                       if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
                                                sect := f.Sections[i]
                                                if s.Value < sect.Size {
                                                        if sdat, err := sect.Data(); err == nil {
index 603dab4917c263cbf80f5dbad5d1ed6f3f84ce9d..9d5ea0051ac62cb16e5621ab4f0c78323178af84 100644 (file)
@@ -80,7 +80,7 @@ func mustHaveCxx(t *testing.T) {
        if len(args) == 0 {
                t.Skip("no C++ compiler")
        }
-       testenv.MustHaveExecPath(t, string(args[0]))
+       testenv.MustHaveExecPath(t, args[0])
 }
 
 var (
index c0ad79f23144a7d89ce45356de77e8cdba17ebcf..7c6e2b1d848defe85ae514ad9965485d816c0b00 100644 (file)
@@ -102,14 +102,14 @@ func testMain(m *testing.M) int {
        bin = cmdToRun("./testp")
 
        ccOut := goEnv("CC")
-       cc = []string{string(ccOut)}
+       cc = []string{ccOut}
 
        out := goEnv("GOGCCFLAGS")
        quote := '\000'
        start := 0
        lastSpace := true
        backslash := false
-       s := string(out)
+       s := out
        for i, c := range s {
                if quote == '\000' && unicode.IsSpace(c) {
                        if !lastSpace {
index 2ce705adba44f387eb385fbc6d85f2e602802f03..c01f5cf2cfbe7aa93a21b059c8cb2dfff5520442 100644 (file)
@@ -76,7 +76,7 @@ func testMain(m *testing.M) int {
        start := 0
        lastSpace := true
        backslash := false
-       s := string(out)
+       s := out
        for i, c := range s {
                if quote == '\000' && unicode.IsSpace(c) {
                        if !lastSpace {
index 4fd5c44505aa7834be240ccfd4556a68751216e5..756ffdb1fc787e6ff7a5c577ffe4161179230b39 100644 (file)
@@ -186,7 +186,7 @@ func cCompilerCmd(t *testing.T) []string {
        start := 0
        lastSpace := true
        backslash := false
-       s := string(out)
+       s := out
        for i, c := range s {
                if quote == '\000' && unicode.IsSpace(c) {
                        if !lastSpace {
index 51f934f060099fe4e6523ae21cc535f35c2ff89a..5ecd5271f617e2aa7fe28644eb3cc025e3ad5046 100644 (file)
@@ -131,7 +131,7 @@ func metaHashAndLen() ([16]byte, int) {
        }
        var hv [16]byte
        for i := 0; i < 16; i++ {
-               nib := string(mhash[i*2 : i*2+2])
+               nib := mhash[i*2 : i*2+2]
                x, err := strconv.ParseInt(nib, 16, 32)
                if err != nil {
                        base.Fatalf("metahash bad byte %q", nib)
index 9f03f6404a5f69f4b5d4e4a7e52987e69671e66d..3a9243e0291f5ebf59c20a617cc2aebb55541f40 100644 (file)
@@ -289,7 +289,7 @@ func CanInline(fn *ir.Func, profile *pgoir.Profile) {
 // function is inlinable.
 func noteInlinableFunc(n *ir.Name, fn *ir.Func, cost int32) {
        if base.Flag.LowerM > 1 {
-               fmt.Printf("%v: can inline %v with cost %d as: %v { %v }\n", ir.Line(fn), n, cost, fn.Type(), ir.Nodes(fn.Body))
+               fmt.Printf("%v: can inline %v with cost %d as: %v { %v }\n", ir.Line(fn), n, cost, fn.Type(), fn.Body)
        } else if base.Flag.LowerM != 0 {
                fmt.Printf("%v: can inline %v\n", ir.Line(fn), n)
        }
index bae400586695b78605643db4dd23e71811bb976f..339e4e524f1df91b5330093f2a01ee6288b62ead 100644 (file)
@@ -23,7 +23,7 @@ func (f *bitset8) set2(shift uint8, b uint8) {
        // Clear old bits.
        *(*uint8)(f) &^= 3 << shift
        // Set new bits.
-       *(*uint8)(f) |= uint8(b&3) << shift
+       *(*uint8)(f) |= (b & 3) << shift
 }
 
 type bitset16 uint16
index bd0d96a6954957ec0cf403b3ff7bf9be7bb1cfe9..5e554282839d2e41b9f71ffef7d4bad3f71df375 100644 (file)
@@ -1175,8 +1175,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
                p.From.Type = obj.TYPE_MEM
                p.From.Reg = v.Args[0].Reg()
                p.AddRestSourceArgs([]obj.Addr{
-                       {Type: obj.TYPE_CONST, Offset: int64((v.AuxInt >> 5) & 0x1fffffffff)},
-                       {Type: obj.TYPE_CONST, Offset: int64((v.AuxInt >> 0) & 0x1f)},
+                       {Type: obj.TYPE_CONST, Offset: (v.AuxInt >> 5) & 0x1fffffffff},
+                       {Type: obj.TYPE_CONST, Offset: (v.AuxInt >> 0) & 0x1f},
                })
 
        case ssa.OpLOONG64ADDshiftLLV:
index a8a45b026970798a94a050dc76f6df59bd348e2a..d7dd58d8caafe8beddda21690f4e30622811853f 100644 (file)
@@ -3577,7 +3577,7 @@ func unifiedInlineCall(callerfn *ir.Func, call *ir.CallExpr, fn *ir.Func, inlInd
                edit(r.curfn)
        })
 
-       body := ir.Nodes(r.curfn.Body)
+       body := r.curfn.Body
 
        // Reparent any declarations into the caller function.
        for _, name := range r.curfn.Dcl {
index ace3024480e25371835edfba0faf259b7db61df9..f0d228559f3a876040b59e6dc8f0f3209f72063a 100644 (file)
@@ -631,7 +631,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
                p := s.Prog(v.Op.Asm())
                p.To = obj.Addr{Type: obj.TYPE_REG, Reg: v.Reg()}
                p.Reg = v.Args[0].Reg()
-               p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: int64(sh)}
+               p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: sh}
                p.AddRestSourceArgs([]obj.Addr{{Type: obj.TYPE_CONST, Offset: mb}, {Type: obj.TYPE_CONST, Offset: me}})
                // Auxint holds mask
 
index 25fbaf6862575336dc669df15c15745e7f163aea..a8bda831b1f73b2da524e21a1d55936112c96f05 100644 (file)
@@ -31,7 +31,7 @@ func (s *biasedSparseMap) cap() int {
        if s == nil || s.s == nil {
                return 0
        }
-       return s.s.cap() + int(s.first)
+       return s.s.cap() + s.first
 }
 
 // size returns the number of entries stored in s
index c9a3e4291cc1a6ce89337c37d217cc0082c97c21..7edc414bda7eb7ec5d3301ca03b21c6162257b3f 100644 (file)
@@ -1553,11 +1553,11 @@ func (debugInfo *FuncDebug) PutLocationListDwarf4(list []byte, ctxt *obj.Link, l
                }
 
                if ctxt.UseBASEntries {
-                       listSym.WriteInt(ctxt, listSym.Size, ctxt.Arch.PtrSize, int64(begin))
-                       listSym.WriteInt(ctxt, listSym.Size, ctxt.Arch.PtrSize, int64(end))
+                       listSym.WriteInt(ctxt, listSym.Size, ctxt.Arch.PtrSize, begin)
+                       listSym.WriteInt(ctxt, listSym.Size, ctxt.Arch.PtrSize, end)
                } else {
-                       listSym.WriteCURelativeAddr(ctxt, listSym.Size, startPC, int64(begin))
-                       listSym.WriteCURelativeAddr(ctxt, listSym.Size, startPC, int64(end))
+                       listSym.WriteCURelativeAddr(ctxt, listSym.Size, startPC, begin)
+                       listSym.WriteCURelativeAddr(ctxt, listSym.Size, startPC, end)
                }
 
                i += 2 * ctxt.Arch.PtrSize
index 7c6009dea6c83b9e0daeedf30b13a89b36d84844..44177d679e7e8ea84e1fbaa261bd3df058086f2c 100644 (file)
@@ -33,7 +33,7 @@ func testMagicExhaustive(t *testing.T, n uint) {
        min := -int64(1) << (n - 1)
        max := int64(1) << (n - 1)
        for c := int64(1); c < max; c++ {
-               if !smagicOK(n, int64(c)) {
+               if !smagicOK(n, c) {
                        continue
                }
                m := int64(smagic(n, c).m)
@@ -164,11 +164,11 @@ func TestMagicSigned(t *testing.T) {
                        if c>>(n-1) != 0 {
                                continue // not appropriate for the given n.
                        }
-                       if !smagicOK(n, int64(c)) {
+                       if !smagicOK(n, c) {
                                t.Errorf("expected n=%d c=%d to pass\n", n, c)
                        }
-                       m := smagic(n, int64(c)).m
-                       s := smagic(n, int64(c)).s
+                       m := smagic(n, c).m
+                       s := smagic(n, c).s
 
                        C := new(big.Int).SetInt64(c)
                        M := new(big.Int).SetUint64(m)
@@ -308,13 +308,13 @@ func testDivisibleExhaustive(t *testing.T, n uint) {
        minI := -int64(1) << (n - 1)
        maxI := int64(1) << (n - 1)
        for c := int64(1); c < maxI; c++ {
-               if !sdivisibleOK(n, int64(c)) {
+               if !sdivisibleOK(n, c) {
                        continue
                }
-               k := sdivisible(n, int64(c)).k
-               m := sdivisible(n, int64(c)).m
-               a := sdivisible(n, int64(c)).a
-               max := sdivisible(n, int64(c)).max
+               k := sdivisible(n, c).k
+               m := sdivisible(n, c).m
+               a := sdivisible(n, c).a
+               max := sdivisible(n, c).max
                mask := ^uint64(0) >> (64 - n)
                for i := minI; i < maxI; i++ {
                        want := i%c == 0
@@ -369,13 +369,13 @@ func TestDivisibleSigned(t *testing.T) {
                        if c>>(n-1) != 0 {
                                continue // not appropriate for the given n.
                        }
-                       if !sdivisibleOK(n, int64(c)) {
+                       if !sdivisibleOK(n, c) {
                                t.Errorf("expected n=%d c=%d to pass\n", n, c)
                        }
-                       k := sdivisible(n, int64(c)).k
-                       m := sdivisible(n, int64(c)).m
-                       a := sdivisible(n, int64(c)).a
-                       max := sdivisible(n, int64(c)).max
+                       k := sdivisible(n, c).k
+                       m := sdivisible(n, c).m
+                       a := sdivisible(n, c).a
+                       max := sdivisible(n, c).max
                        mask := ^uint64(0) >> (64 - n)
 
                        C := new(big.Int).SetInt64(c)
index b8fcd3949595cd1403c9717590e48e0323963833..6b1df7dc099e73aab8bcafd7713be4e0045bcdf5 100644 (file)
@@ -728,7 +728,7 @@ func combineStores(root *Value) {
        if isLittleEndian && shift0 != 0 {
                sv = rightShift(root.Block, root.Pos, sv, shift0)
        }
-       shiftedSize = int64(aTotalSize - a[0].size)
+       shiftedSize = aTotalSize - a[0].size
        if isBigEndian && shift0-shiftedSize*8 != 0 {
                sv = rightShift(root.Block, root.Pos, sv, shift0-shiftedSize*8)
        }
index f02019df384f5f72c90eab5d4be8a82613f4bd2c..9ea735a67d4b7f09f79fb87880a32a18d23878c7 100644 (file)
@@ -726,7 +726,7 @@ func int32ToAuxInt(i int32) int64 {
        return int64(i)
 }
 func int64ToAuxInt(i int64) int64 {
-       return int64(i)
+       return i
 }
 func uint8ToAuxInt(i uint8) int64 {
        return int64(int8(i))
@@ -1603,7 +1603,7 @@ func encodePPC64RotateMask(rotate, mask, nbits int64) int64 {
                mb, me = men, mbn
        }
 
-       return int64(me) | int64(mb<<8) | int64(rotate<<16) | int64(nbits<<24)
+       return int64(me) | int64(mb<<8) | rotate<<16 | nbits<<24
 }
 
 // Merge (RLDICL [encoded] (SRDconst [s] x)) into (RLDICL [new_encoded] x)
@@ -1712,7 +1712,7 @@ func mergePPC64AndSldi(m, s int64) int64 {
 func mergePPC64ClrlsldiSrw(sld, srw int64) int64 {
        mask_1 := uint64(0xFFFFFFFF >> uint(srw))
        // for CLRLSLDI, it's more convenient to think of it as a mask left bits then rotate left.
-       mask_2 := uint64(0xFFFFFFFFFFFFFFFF) >> uint(GetPPC64Shiftmb(int64(sld)))
+       mask_2 := uint64(0xFFFFFFFFFFFFFFFF) >> uint(GetPPC64Shiftmb(sld))
 
        // Rewrite mask to apply after the final left shift.
        mask_3 := (mask_1 & mask_2) << uint(GetPPC64Shiftsh(sld))
@@ -1724,7 +1724,7 @@ func mergePPC64ClrlsldiSrw(sld, srw int64) int64 {
        if uint64(uint32(mask_3)) != mask_3 || mask_3 == 0 {
                return 0
        }
-       return encodePPC64RotateMask(int64(r_3), int64(mask_3), 32)
+       return encodePPC64RotateMask(r_3, int64(mask_3), 32)
 }
 
 // Test if a doubleword shift right feeding into a CLRLSLDI can be merged into RLWINM.
@@ -1732,7 +1732,7 @@ func mergePPC64ClrlsldiSrw(sld, srw int64) int64 {
 func mergePPC64ClrlsldiSrd(sld, srd int64) int64 {
        mask_1 := uint64(0xFFFFFFFFFFFFFFFF) >> uint(srd)
        // for CLRLSLDI, it's more convenient to think of it as a mask left bits then rotate left.
-       mask_2 := uint64(0xFFFFFFFFFFFFFFFF) >> uint(GetPPC64Shiftmb(int64(sld)))
+       mask_2 := uint64(0xFFFFFFFFFFFFFFFF) >> uint(GetPPC64Shiftmb(sld))
 
        // Rewrite mask to apply after the final left shift.
        mask_3 := (mask_1 & mask_2) << uint(GetPPC64Shiftsh(sld))
@@ -1749,7 +1749,7 @@ func mergePPC64ClrlsldiSrd(sld, srd int64) int64 {
        if v1&mask_3 != 0 {
                return 0
        }
-       return encodePPC64RotateMask(int64(r_3&31), int64(mask_3), 32)
+       return encodePPC64RotateMask(r_3&31, int64(mask_3), 32)
 }
 
 // Test if a RLWINM feeding into a CLRLSLDI can be merged into RLWINM.  Return
@@ -2155,11 +2155,11 @@ func rewriteFixedLoad(v *Value, sym Sym, sb *Value, off int64) *Value {
                                switch f.Sym.Name {
                                case "Size_":
                                        v.reset(ptrSizedOpConst)
-                                       v.AuxInt = int64(t.Size())
+                                       v.AuxInt = t.Size()
                                        return v
                                case "PtrBytes":
                                        v.reset(ptrSizedOpConst)
-                                       v.AuxInt = int64(types.PtrDataSize(t))
+                                       v.AuxInt = types.PtrDataSize(t)
                                        return v
                                case "Hash":
                                        v.reset(OpConst32)
index ecc0f94e5b96b674550b2672fa7ac2d10a2602bc..107db23ed4af08b84a1499a6b7e3abe7a17f7e70 100644 (file)
@@ -377,7 +377,7 @@ func (t *worklist) visitValue(val *Value) {
                // re-visit all uses of value if its lattice is changed
                newLt := t.getLatticeCell(val)
                if !equals(newLt, oldLt) {
-                       if int8(oldLt.tag) > int8(newLt.tag) {
+                       if oldLt.tag > newLt.tag {
                                t.f.Fatalf("Must lower lattice\n")
                        }
                        t.addUses(val)
index 9358a60374996aa29b0cf694ca002914f62c1457..5e89ce9a3d30b8f0b94791a04cd3bd003fa8dc2d 100644 (file)
@@ -99,28 +99,28 @@ func BenchmarkDivconstU64(b *testing.B) {
                x := uint64(123456789123456789)
                for i := 0; i < b.N; i++ {
                        x += x << 4
-                       u64res = uint64(x) / 3
+                       u64res = x / 3
                }
        })
        b.Run("5", func(b *testing.B) {
                x := uint64(123456789123456789)
                for i := 0; i < b.N; i++ {
                        x += x << 4
-                       u64res = uint64(x) / 5
+                       u64res = x / 5
                }
        })
        b.Run("37", func(b *testing.B) {
                x := uint64(123456789123456789)
                for i := 0; i < b.N; i++ {
                        x += x << 4
-                       u64res = uint64(x) / 37
+                       u64res = x / 37
                }
        })
        b.Run("1234567", func(b *testing.B) {
                x := uint64(123456789123456789)
                for i := 0; i < b.N; i++ {
                        x += x << 4
-                       u64res = uint64(x) / 1234567
+                       u64res = x / 1234567
                }
        })
 }
index 0fa78afe2c08ef92b0ad006e8c539ffc656209e0..053e04dfe599e9bfcddb8cb368d77f3af9f8e114 100644 (file)
@@ -296,9 +296,9 @@ func cleanDecls(m map[string][]token.Position) ([]string, map[string][]token.Pos
 }
 
 var (
-       bSlashSlash = []byte(slashSlash)
-       bStarSlash  = []byte(starSlash)
-       bSlashStar  = []byte(slashStar)
+       bSlashSlash = slashSlash
+       bStarSlash  = starSlash
+       bSlashStar  = slashStar
        bPlusBuild  = []byte("+build")
 
        goBuildComment = []byte("//go:build")
index edbc5734401737be258ebc72cd238b1f97f883b5..7c198c5f2b442abcff5b4b9110f5e91b50e0623f 100644 (file)
@@ -237,7 +237,7 @@ func parseRevTime(out []byte) (string, time.Time, error) {
        }
        rev := buf[:i]
 
-       secs, err := strconv.ParseInt(string(buf[i+1:]), 10, 64)
+       secs, err := strconv.ParseInt(buf[i+1:], 10, 64)
        if err != nil {
                return "", time.Time{}, fmt.Errorf("unrecognized VCS tool output: %v", err)
        }
index 4de71bcdb9b948c40eac9c2bc0054abcd07a0fa4..c5ba3ae110d8c3005f555bc62f3c54c284130a6e 100644 (file)
@@ -281,7 +281,7 @@ func printJSONDiagnostics(r io.Reader) error {
                // unitchecker emits a JSON map of the form:
                // output maps Package ID -> Analyzer.Name -> (error | []Diagnostic);
                var tree jsonTree
-               if err := json.Unmarshal([]byte(stdout), &tree); err != nil {
+               if err := json.Unmarshal(stdout, &tree); err != nil {
                        return fmt.Errorf("parsing JSON: %v", err)
                }
                for _, units := range tree {
index 5300f7f9b883caba05d95f2db82186fd07ad2c0c..cee40b0116d01aac215aaaedb7d80e5061cab254 100644 (file)
@@ -213,7 +213,7 @@ func findHostBuildID(r io.Reader) (offset int64, size int64, ok bool) {
                if cmd.Cmd == imacho.LC_UUID {
                        // The UUID is the data in the LC_UUID load command,
                        // skipping over the 8-byte command header.
-                       return int64(reader.Offset() + 8), int64(cmd.Len - 8), true
+                       return reader.Offset() + 8, int64(cmd.Len - 8), true
                }
        }
        return 0, 0, false
index 38da67076d5bb26e1dc8f6a6b98a2f04dd1f061b..cca3c840e0e9dc10ee5e7a0f21fbfb86501c6072 100644 (file)
@@ -727,7 +727,7 @@ func (r *Reader) NNonpkgref() int {
 
 // SymOff returns the offset of the i-th symbol.
 func (r *Reader) SymOff(i uint32) uint32 {
-       return r.h.Offsets[BlkSymdef] + uint32(i*SymSize)
+       return r.h.Offsets[BlkSymdef] + i*SymSize
 }
 
 // Sym returns a pointer to the i-th symbol.
@@ -752,7 +752,7 @@ func (r *Reader) RefFlags(i int) *RefFlags {
 // Note: here i is the index of short hashed symbols, not all symbols
 // (unlike other accessors).
 func (r *Reader) Hash64(i uint32) uint64 {
-       off := r.h.Offsets[BlkHash64] + uint32(i*Hash64Size)
+       off := r.h.Offsets[BlkHash64] + i*Hash64Size
        return r.uint64At(off)
 }
 
@@ -760,19 +760,19 @@ func (r *Reader) Hash64(i uint32) uint64 {
 // Note: here i is the index of hashed symbols, not all symbols
 // (unlike other accessors).
 func (r *Reader) Hash(i uint32) *HashType {
-       off := r.h.Offsets[BlkHash] + uint32(i*HashSize)
+       off := r.h.Offsets[BlkHash] + i*HashSize
        return (*HashType)(unsafe.Pointer(&r.b[off]))
 }
 
 // NReloc returns the number of relocations of the i-th symbol.
 func (r *Reader) NReloc(i uint32) int {
-       relocIdxOff := r.h.Offsets[BlkRelocIdx] + uint32(i*4)
+       relocIdxOff := r.h.Offsets[BlkRelocIdx] + i*4
        return int(r.uint32At(relocIdxOff+4) - r.uint32At(relocIdxOff))
 }
 
 // RelocOff returns the offset of the j-th relocation of the i-th symbol.
 func (r *Reader) RelocOff(i uint32, j int) uint32 {
-       relocIdxOff := r.h.Offsets[BlkRelocIdx] + uint32(i*4)
+       relocIdxOff := r.h.Offsets[BlkRelocIdx] + i*4
        relocIdx := r.uint32At(relocIdxOff)
        return r.h.Offsets[BlkReloc] + (relocIdx+uint32(j))*uint32(RelocSize)
 }
index fabd0cb50f43be5564f94eb3534bdd5b9486bc84..d33b75120d2fc5abfd81a5c9365c42bec31eb1f8 100644 (file)
@@ -115,7 +115,7 @@ var ARMDWARFRegisters = map[int16]int16{}
 func init() {
        // f assigns dwarfregisters[from:to] = (base):(step*(to-from)+base)
        f := func(from, to, base, step int16) {
-               for r := int16(from); r <= to; r++ {
+               for r := from; r <= to; r++ {
                        ARMDWARFRegisters[r] = step*(r-from) + base
                }
        }
index 3cb4be436b9b7f91b9b230bae2bb0ff6defb74c8..befd1bee13d66f32c15d93f495e962de822f7eef 100644 (file)
@@ -1163,7 +1163,7 @@ func span7(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                switch p.As {
                case obj.APCALIGN, obj.APCALIGNMAX:
                        v := obj.AlignmentPaddingLength(int32(p.Pc), p, c.ctxt)
-                       for i := 0; i < int(v/4); i++ {
+                       for i := 0; i < v/4; i++ {
                                // emit ANOOP instruction by the padding size
                                buf.emit(OP_NOOP)
                        }
@@ -4017,7 +4017,7 @@ func (c *ctxt7) asmout(p *obj.Prog, out []uint32) (count int) {
 
                // Handle smaller unaligned and negative offsets via addition or subtraction.
                if v >= -4095 && v <= 4095 {
-                       o1 = c.oaddi12(p, v, REGTMP, int16(rt))
+                       o1 = c.oaddi12(p, v, REGTMP, rt)
                        o2 = c.olsr12u(p, c.opstr(p, p.As), 0, REGTMP, rf)
                        break
                }
@@ -4073,7 +4073,7 @@ func (c *ctxt7) asmout(p *obj.Prog, out []uint32) (count int) {
 
                // Handle smaller unaligned and negative offsets via addition or subtraction.
                if v >= -4095 && v <= 4095 {
-                       o1 = c.oaddi12(p, v, REGTMP, int16(rf))
+                       o1 = c.oaddi12(p, v, REGTMP, rf)
                        o2 = c.olsr12u(p, c.opldr(p, p.As), 0, REGTMP, rt)
                        break
                }
@@ -4852,7 +4852,7 @@ func (c *ctxt7) asmout(p *obj.Prog, out []uint32) (count int) {
                if p.Pool != nil {
                        c.ctxt.Diag("%v: unused constant in pool (%v)\n", p, v)
                }
-               o1 = c.oaddi(p, AADD, lo, REGTMP, int16(rf))
+               o1 = c.oaddi(p, AADD, lo, REGTMP, rf)
                o2 = c.oaddi(p, AADD, hi, REGTMP, REGTMP)
                o3 = c.opldpstp(p, o, 0, REGTMP, rt1, rt2, 1)
                break
@@ -4917,7 +4917,7 @@ func (c *ctxt7) asmout(p *obj.Prog, out []uint32) (count int) {
                if p.Pool != nil {
                        c.ctxt.Diag("%v: unused constant in pool (%v)\n", p, v)
                }
-               o1 = c.oaddi(p, AADD, lo, REGTMP, int16(rt))
+               o1 = c.oaddi(p, AADD, lo, REGTMP, rt)
                o2 = c.oaddi(p, AADD, hi, REGTMP, REGTMP)
                o3 = c.opldpstp(p, o, 0, REGTMP, rf1, rf2, 0)
                break
@@ -5293,7 +5293,7 @@ func (c *ctxt7) asmout(p *obj.Prog, out []uint32) (count int) {
                }
 
                o1 = c.opirr(p, p.As)
-               o1 |= (uint32(r&31) << 5) | (uint32((imm>>3)&0xfff) << 10) | (uint32(v & 31))
+               o1 |= (uint32(r&31) << 5) | ((imm >> 3) & 0xfff << 10) | (v & 31)
 
        case 92: /* vmov Vn.<T>[index], Vd.<T>[index] */
                rf := int(p.From.Reg)
@@ -5846,7 +5846,7 @@ func (c *ctxt7) asmout(p *obj.Prog, out []uint32) (count int) {
        out[3] = o4
        out[4] = o5
 
-       return int(o.size(c.ctxt, p) / 4)
+       return o.size(c.ctxt, p) / 4
 }
 
 func (c *ctxt7) addrRelocType(p *obj.Prog) objabi.RelocType {
@@ -7854,12 +7854,12 @@ func (c *ctxt7) encRegShiftOrExt(p *obj.Prog, a *obj.Addr, r int16) uint32 {
 
 // pack returns the encoding of the "Q" field and two arrangement specifiers.
 func pack(q uint32, arngA, arngB uint8) uint32 {
-       return uint32(q)<<16 | uint32(arngA)<<8 | uint32(arngB)
+       return q<<16 | uint32(arngA)<<8 | uint32(arngB)
 }
 
 // ARM64RegisterExtension constructs an ARM64 register with extension or arrangement.
 func ARM64RegisterExtension(a *obj.Addr, ext string, reg, num int16, isAmount, isIndex bool) error {
-       Rnum := (reg & 31) + int16(num<<5)
+       Rnum := (reg & 31) + num<<5
        if isAmount {
                if num < 0 || num > 7 {
                        return errors.New("index shift amount is out of range")
index c6f321e3e53153e8592616d2f67da1fcf981d2d2..670b0f3510f8c257ae012dd3a6dc760499e83471 100644 (file)
@@ -219,7 +219,7 @@ func (c dwCtxt) AddUint16(s dwarf.Sym, i uint16) {
        c.AddInt(s, 2, int64(i))
 }
 func (c dwCtxt) AddUint8(s dwarf.Sym, i uint8) {
-       b := []byte{byte(i)}
+       b := []byte{i}
        c.AddBytes(s, b)
 }
 func (c dwCtxt) AddBytes(s dwarf.Sym, b []byte) {
index b7e116bae39dc42a9f4175eae664fc2344279ef4..9f3814e748aa5fec79909659cf5996c376f0c37d 100644 (file)
@@ -753,12 +753,12 @@ func (ft *WasmFuncType) Read(b []byte) {
        ft.Params = make([]WasmField, readUint32())
        for i := range ft.Params {
                ft.Params[i].Type = WasmFieldType(readByte())
-               ft.Params[i].Offset = int64(readInt64())
+               ft.Params[i].Offset = readInt64()
        }
        ft.Results = make([]WasmField, readUint32())
        for i := range ft.Results {
                ft.Results[i].Type = WasmFieldType(readByte())
-               ft.Results[i].Offset = int64(readInt64())
+               ft.Results[i].Offset = readInt64()
        }
 }
 
index 100e99b1c4faa4000047c203801a8988b85cde2c..3cdbeb12a37395cbf16231d1052b445a3d79bc07 100644 (file)
@@ -236,7 +236,7 @@ var LOONG64DWARFRegisters = map[int16]int16{}
 func init() {
        // f assigns dwarfregisters[from:to] = (base):(to-from+base)
        f := func(from, to, base int16) {
-               for r := int16(from); r <= to; r++ {
+               for r := from; r <= to; r++ {
                        LOONG64DWARFRegisters[r] = (r - from) + base
                }
        }
index 5439f0e4aaf1f456bf68234fbbfd96a78a8dd5f5..b7e82c50f402abfbe9986d22b281593781b3958d 100644 (file)
@@ -245,7 +245,7 @@ var MIPSDWARFRegisters = map[int16]int16{}
 func init() {
        // f assigns dwarfregisters[from:to] = (base):(to-from+base)
        f := func(from, to, base int16) {
-               for r := int16(from); r <= to; r++ {
+               for r := from; r <= to; r++ {
                        MIPSDWARFRegisters[r] = (r - from) + base
                }
        }
index 3299fbf4e6e1b0484b79dfed763f9d77ff588788..4401f1bb74e0a9ed358d9754905b0d4f11804665 100644 (file)
@@ -166,7 +166,7 @@ func WriteObjFile(ctxt *Link, b *bio.Writer) {
                        w.Uint32(uint32(dataOff))
                        dataOff += int64(len(s.P))
                        if file := s.File(); file != nil {
-                               dataOff += int64(file.Size)
+                               dataOff += file.Size
                        }
                }
        }
index aa7bcd30681acd3013c9bd50f1583e94741f2e0b..d103ebcfc35c9c7fb771b66f78b51e18c113589d 100644 (file)
@@ -311,7 +311,7 @@ var PPC64DWARFRegisters = map[int16]int16{}
 func init() {
        // f assigns dwarfregister[from:to] = (base):(to-from+base)
        f := func(from, to, base int16) {
-               for r := int16(from); r <= to; r++ {
+               for r := from; r <= to; r++ {
                        PPC64DWARFRegisters[r] = r - from + base
                }
        }
index dcd3aa59a4690a255bb01dc6ff5c23d8b3207db5..a39c206c22da9e687b41efaeb8f186afc399f380 100644 (file)
@@ -2655,7 +2655,7 @@ func asmout(c *ctxt9, p *obj.Prog, o *Optab, out *[5]uint32) {
        case 9: /* RLDC Ra, $sh, $mb, Rb */
                sh := uint32(p.RestArgs[0].Addr.Offset) & 0x3F
                mb := uint32(p.RestArgs[1].Addr.Offset) & 0x3F
-               o1 = AOP_RRR(c.opirr(p.As), uint32(p.From.Reg), uint32(p.To.Reg), (uint32(sh) & 0x1F))
+               o1 = AOP_RRR(c.opirr(p.As), uint32(p.From.Reg), uint32(p.To.Reg), (sh & 0x1F))
                o1 |= (sh & 0x20) >> 4 // sh[5] is placed in bit 1.
                o1 |= (mb & 0x1F) << 6 // mb[0:4] is placed in bits 6-10.
                o1 |= (mb & 0x20)      // mb[5] is placed in bit 5
@@ -2784,7 +2784,7 @@ func asmout(c *ctxt9, p *obj.Prog, o *Optab, out *[5]uint32) {
                        if n > b || b > 63 {
                                c.ctxt.Diag("Invalid n or b for CLRLSLDI: %x %x\n%v", n, b, p)
                        }
-                       o1 = AOP_MD(OP_RLDIC, uint32(p.To.Reg), uint32(r), uint32(n), uint32(b)-uint32(n))
+                       o1 = AOP_MD(OP_RLDIC, uint32(p.To.Reg), r, uint32(n), uint32(b)-uint32(n))
 
                default:
                        c.ctxt.Diag("unexpected op in rldc case\n%v", p)
@@ -2967,7 +2967,7 @@ func asmout(c *ctxt9, p *obj.Prog, o *Optab, out *[5]uint32) {
                        c.ctxt.Diag("%v is not supported", p)
                }
                if o.ispfx {
-                       o1, o2 = pfxadd(int16(p.To.Reg), int16(r), PFX_R_ABS, d)
+                       o1, o2 = pfxadd(p.To.Reg, int16(r), PFX_R_ABS, d)
                } else if o.size == 8 {
                        o1 = LOP_IRR(OP_ORI, REGTMP, REGZERO, uint32(int32(d)))          // tmp = uint16(d)
                        o2 = AOP_RRR(c.oprrr(p.As), uint32(p.To.Reg), REGTMP, uint32(r)) // to = tmp + from
@@ -2979,7 +2979,7 @@ func asmout(c *ctxt9, p *obj.Prog, o *Optab, out *[5]uint32) {
                } else {
                        // For backwards compatibility with GOPPC64 < 10, generate 34b constants in register.
                        o1 = LOP_IRR(OP_ADDIS, REGZERO, REGTMP, uint32(d>>32)) // tmp = sign_extend((d>>32)&0xFFFF0000)
-                       o2 = loadl16(REGTMP, int64(d>>16))                     // tmp |= (d>>16)&0xFFFF
+                       o2 = loadl16(REGTMP, d>>16)                            // tmp |= (d>>16)&0xFFFF
                        o3 = AOP_MD(OP_RLDICR, REGTMP, REGTMP, 16, 63-16)      // tmp <<= 16
                        o4 = loadl16(REGTMP, int64(uint16(d)))                 // tmp |= d&0xFFFF
                        o5 = AOP_RRR(c.oprrr(p.As), uint32(p.To.Reg), REGTMP, uint32(r))
@@ -3080,9 +3080,9 @@ func asmout(c *ctxt9, p *obj.Prog, o *Optab, out *[5]uint32) {
 
                if o.ispfx {
                        if rel == nil {
-                               o1, o2 = pfxadd(int16(p.To.Reg), int16(r), PFX_R_ABS, v)
+                               o1, o2 = pfxadd(p.To.Reg, int16(r), PFX_R_ABS, v)
                        } else {
-                               o1, o2 = pfxadd(int16(p.To.Reg), REG_R0, PFX_R_PCREL, 0)
+                               o1, o2 = pfxadd(p.To.Reg, REG_R0, PFX_R_PCREL, 0)
                                rel.Type = objabi.R_ADDRPOWER_PCREL34
                        }
                }
@@ -3519,7 +3519,7 @@ func asmout(c *ctxt9, p *obj.Prog, o *Optab, out *[5]uint32) {
                        v |= 1 << 8
                }
 
-               o1 = AOP_RRR(OP_MTCRF, uint32(p.From.Reg), 0, 0) | uint32(v)<<12
+               o1 = AOP_RRR(OP_MTCRF, uint32(p.From.Reg), 0, 0) | v<<12
 
        case 70: /* cmp* r,r,cr or cmp*i r,i,cr or fcmp f,f,cr or cmpeqb r,r */
                r := uint32(p.Reg&7) << 2
index 74699cc398534e3a5688705aa5e5489e7b2094ba..8c4140ec5c64526cd138ead84eb949f8d410fd0d 100644 (file)
@@ -905,7 +905,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, cursym *obj.LSym, newprog obj.ProgA
                to_done = p
        } else {
                // large stack: SP-framesize < stackguard-StackSmall
-               offset := int64(framesize) - abi.StackSmall
+               offset := framesize - abi.StackSmall
                if framesize > abi.StackBig {
                        // Such a large stack we need to protect against underflow.
                        // The runtime guarantees SP > objabi.StackBig, but
@@ -3837,7 +3837,7 @@ func instructionsForProg(p *obj.Prog) []*instruction {
                if err != nil {
                        p.Ctxt.Diag("%v: %v", p, err)
                }
-               ins.imm = int64(vtype)
+               ins.imm = vtype
                if ins.as == AVSETIVLI {
                        if p.From.Type != obj.TYPE_CONST {
                                p.Ctxt.Diag("%v: expected immediate value", p)
index dc715182f5cf81b86e164c6172c7db3970c634f0..caf5ec09358a033c84d139440da1c34d3516f69f 100644 (file)
@@ -156,7 +156,7 @@ var S390XDWARFRegisters = map[int16]int16{}
 func init() {
        // f assigns dwarfregisters[from:to by step] = (base):((to-from)/step+base)
        f := func(from, step, to, base int16) {
-               for r := int16(from); r <= to; r += step {
+               for r := from; r <= to; r += step {
                        S390XDWARFRegisters[r] = (r-from)/step + base
                }
        }
index 97de5a4a0896d53c5861412c91542d9aaa728fd8..3706bb1b74e0cd18b5808ee00506a67f65ac5b75 100644 (file)
@@ -3130,7 +3130,7 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
                case ARISBLG, ARISBLGZ:
                        opcode = op_RISBLG
                }
-               zRIE(_f, uint32(opcode), uint32(r1), uint32(r2), 0, uint32(i3), uint32(i4), 0, uint32(i5), asm)
+               zRIE(_f, opcode, uint32(r1), uint32(r2), 0, uint32(i3), uint32(i4), 0, uint32(i5), asm)
 
        case 15: // br/bl (reg)
                r := p.To.Reg
@@ -3183,8 +3183,8 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
                }
                switch p.As {
                case ASUB:
-                       zRIL(_a, op_LGFI, uint32(regtmp(p)), uint32(v), asm)
-                       zRRF(op_SLGRK, uint32(regtmp(p)), 0, uint32(p.To.Reg), uint32(r), asm)
+                       zRIL(_a, op_LGFI, regtmp(p), uint32(v), asm)
+                       zRRF(op_SLGRK, regtmp(p), 0, uint32(p.To.Reg), uint32(r), asm)
                case ASUBC:
                        if r != p.To.Reg {
                                zRRE(op_LGR, uint32(p.To.Reg), uint32(r), asm)
@@ -3603,7 +3603,7 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
                                if opcode == op_MVI {
                                        opcode = op_MVIY
                                } else {
-                                       zRXY(op_LAY, uint32(regtmp(p)), 0, uint32(r), uint32(d), asm)
+                                       zRXY(op_LAY, regtmp(p), 0, uint32(r), uint32(d), asm)
                                        r = int16(regtmp(p))
                                        d = 0
                                }
index 5407c8df1109993f2b86f32323b2f288036b108a..d3cb44cabff036dfe19cfa6ee54fa98352f22e43 100644 (file)
@@ -67,7 +67,7 @@ func (r RotateParams) RotateLeft(amount uint8) RotateParams {
 // OutMask provides a mask representing the selected bits.
 func (r RotateParams) OutMask() uint64 {
        // Note: z must be unsigned for bootstrap compiler
-       z := uint8(63-r.End+r.Start) & 63 // number of zero bits in mask
+       z := (63 - r.End + r.Start) & 63 // number of zero bits in mask
        return bits.RotateLeft64(^uint64(0)<<z, -int(r.Start))
 }
 
index 03718fbb31c8f554b643bec38279eaa90dbf361a..4110fd7d8a7425357e2884408494e5964e589d96 100644 (file)
@@ -2156,7 +2156,7 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
                                v := obj.AlignmentPadding(c, p, ctxt, s)
                                if v > 0 {
                                        s.Grow(int64(c) + int64(v))
-                                       fillnop(s.P[c:], int(v))
+                                       fillnop(s.P[c:], v)
                                }
                                p.Pc = int64(c)
                                c += int32(v)
@@ -3277,7 +3277,7 @@ func (ab *AsmBuf) Put(b []byte) {
 // Literal Z cases usually have "Zlit" in their name (Zlit, Zlitr_m, Zlitm_r).
 func (ab *AsmBuf) PutOpBytesLit(offset int, op *opBytes) {
        for int(op[offset]) != 0 {
-               ab.Put1(byte(op[offset]))
+               ab.Put1(op[offset])
                offset++
        }
 }
index 458a91258a35b002b946da61d9709286e735a549..11655829838f0c4f7e2632938fe01e9f4d391400 100644 (file)
@@ -286,7 +286,7 @@ func TestRegIndex(t *testing.T) {
                        have := regIndex(int16(reg))
                        want := index
                        if have != want {
-                               regName := rconv(int(reg))
+                               regName := rconv(reg)
                                t.Errorf("regIndex(%s):\nhave: %d\nwant: %d",
                                        regName, have, want)
                        }
index c428e29c9b19a438db354f218d10124f3e172881..7d564a2661d9515801be4f3f690701e6fb6c1a74 100644 (file)
@@ -240,7 +240,7 @@ func (f *goobjFile) PCToLine(pc uint64) (string, int, *gosym.Func) {
                        // We don't need the data for non-hashed symbols, yet.
                        panic("not supported")
                }
-               i := uint32(s.SymIdx + uint32(r.NSym()+r.NHashed64def()))
+               i := s.SymIdx + uint32(r.NSym()+r.NHashed64def())
                return r.BytesAt(r.DataOff(i), r.DataSize(i))
        }
 
@@ -325,7 +325,7 @@ func readvarint(p *[]byte) uint32 {
 // We treat the whole object file as the text section.
 func (f *goobjFile) text() (textStart uint64, text []byte, err error) {
        text = make([]byte, f.goobj.Size)
-       _, err = f.f.ReadAt(text, int64(f.goobj.Offset))
+       _, err = f.f.ReadAt(text, f.goobj.Offset)
        return
 }
 
index d6df4db8f01d0615abc9df6d814bede5507591e0..24f42760c9dd601cb69c4e447a7099d288be6a46 100644 (file)
@@ -44,7 +44,7 @@ func (f *xcoffFile) symbols() ([]Sym, error) {
                case N_DEBUG:
                        sym.Code = '?'
                default:
-                       if s.SectionNumber < 0 || len(f.xcoff.Sections) < int(s.SectionNumber) {
+                       if s.SectionNumber < 0 || len(f.xcoff.Sections) < s.SectionNumber {
                                return nil, fmt.Errorf("invalid section number in symbol table")
                        }
                        sect := f.xcoff.Sections[s.SectionNumber-1]
@@ -116,7 +116,7 @@ func findXCOFFSymbol(f *xcoff.File, name string) (*xcoff.Symbol, error) {
                if s.SectionNumber <= 0 {
                        return nil, fmt.Errorf("symbol %s: invalid section number %d", name, s.SectionNumber)
                }
-               if len(f.Sections) < int(s.SectionNumber) {
+               if len(f.Sections) < s.SectionNumber {
                        return nil, fmt.Errorf("symbol %s: section number %d is larger than max %d", name, s.SectionNumber, len(f.Sections))
                }
                return s, nil
index 5424de800cac9fc12efb2e0f074e3edb825a98ca..d27342f23fb5fba730fef2876ffcb84ec4fb62ec 100644 (file)
@@ -407,7 +407,7 @@ func adddynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loade
                        } else {
                                ldr.Errorf(s, "unexpected relocation for dynamic symbol %s", ldr.SymName(targ))
                        }
-                       rela.AddAddrPlus(target.Arch, targ, int64(r.Add()))
+                       rela.AddAddrPlus(target.Arch, targ, r.Add())
                        // Not mark r done here. So we still apply it statically,
                        // so in the file content we'll also have the right offset
                        // to the relocation target. So it can be examined statically
index a113196d10c10d22aae74c097fc982e9c03d7801..248ec648bcc81f46f1fa0180b7806c1ee0b49fdc 100644 (file)
@@ -400,7 +400,7 @@ func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) {
                        for i := 0; ; i++ {
                                oName := ldr.SymName(rs)
                                name := oName + fmt.Sprintf("%+d-tramp%d", offset, i)
-                               tramp = ldr.LookupOrCreateSym(name, int(ldr.SymVersion(rs)))
+                               tramp = ldr.LookupOrCreateSym(name, ldr.SymVersion(rs))
                                ldr.SetAttrReachable(tramp, true)
                                if ldr.SymType(tramp) == sym.SDYNIMPORT {
                                        // don't reuse trampoline defined in other module
index 8d8ea8ac542c5095e92a268384039a502a980465..1f4282adecc747fbf2487c8853e673a709b44e52 100644 (file)
@@ -457,7 +457,7 @@ func adddynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loade
                        } else {
                                ldr.Errorf(s, "unexpected relocation for dynamic symbol %s", ldr.SymName(targ))
                        }
-                       rela.AddAddrPlus(target.Arch, targ, int64(r.Add()))
+                       rela.AddAddrPlus(target.Arch, targ, r.Add())
                        // Not mark r done here. So we still apply it statically,
                        // so in the file content we'll also have the right offset
                        // to the relocation target. So it can be examined statically
@@ -876,7 +876,7 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
                                if r.Siz() == 8 {
                                        val = r.Add()
                                } else if target.IsBigEndian() {
-                                       val = int64(uint32(val)) | int64(r.Add())<<32
+                                       val = int64(uint32(val)) | r.Add()<<32
                                } else {
                                        val = val>>32<<32 | int64(uint32(r.Add()))
                                }
@@ -972,13 +972,13 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
 
                        // R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21
                        // turn ADRP to MOVZ
-                       o0 = 0xd2a00000 | uint32(o0&0x1f) | (uint32((v>>16)&0xffff) << 5)
+                       o0 = 0xd2a00000 | o0&0x1f | (uint32((v>>16)&0xffff) << 5)
                        // R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC
                        // turn LD64 to MOVK
                        if v&3 != 0 {
                                ldr.Errorf(s, "invalid address: %x for relocation type: R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC", v)
                        }
-                       o1 = 0xf2800000 | uint32(o1&0x1f) | (uint32(v&0xffff) << 5)
+                       o1 = 0xf2800000 | o1&0x1f | (uint32(v&0xffff) << 5)
 
                        // when laid out, the instruction order must always be o0, o1.
                        if target.IsBigEndian() {
@@ -1372,7 +1372,7 @@ func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) {
                        for i := 0; ; i++ {
                                oName := ldr.SymName(rs)
                                name := oName + fmt.Sprintf("%+x-tramp%d", r.Add(), i)
-                               tramp = ldr.LookupOrCreateSym(name, int(ldr.SymVersion(rs)))
+                               tramp = ldr.LookupOrCreateSym(name, ldr.SymVersion(rs))
                                ldr.SetAttrReachable(tramp, true)
                                if ldr.SymType(tramp) == sym.SDYNIMPORT {
                                        // don't reuse trampoline defined in other module
index a49cae0d9527ca4331a500af695a82a2ac5b3a73..dfb1d7bafbd51d8d9864efc80cac494469dd8e3e 100644 (file)
@@ -427,7 +427,7 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
                        }
                case objabi.R_DWTXTADDR_U1, objabi.R_DWTXTADDR_U2, objabi.R_DWTXTADDR_U3, objabi.R_DWTXTADDR_U4:
                        unit := ldr.SymUnit(rs)
-                       if idx, ok := unit.Addrs[sym.LoaderSym(rs)]; ok {
+                       if idx, ok := unit.Addrs[rs]; ok {
                                o = int64(idx)
                        } else {
                                st.err.Errorf(s, "missing .debug_addr index relocation target %s", ldr.SymName(rs))
@@ -512,7 +512,7 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
                case objabi.R_ADDRCUOFF:
                        // debug_range and debug_loc elements use this relocation type to get an
                        // offset from the start of the compile unit.
-                       o = ldr.SymValue(rs) + r.Add() - ldr.SymValue(loader.Sym(ldr.SymUnit(rs).Textp[0]))
+                       o = ldr.SymValue(rs) + r.Add() - ldr.SymValue(ldr.SymUnit(rs).Textp[0])
 
                // r.Sym() can be 0 when CALL $(constant) is transformed from absolute PC to relative PC call.
                case objabi.R_GOTPCREL:
@@ -560,7 +560,7 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
                                                        if rst != sym.SHOSTOBJ {
                                                                o += int64(uint64(ldr.SymValue(rs)) - ldr.SymSect(rs).Vaddr)
                                                        }
-                                                       o -= int64(off) // relative to section offset, not symbol
+                                                       o -= off // relative to section offset, not symbol
                                                }
                                        } else {
                                                o += int64(siz)
@@ -698,7 +698,7 @@ func extreloc(ctxt *Link, ldr *loader.Loader, s loader.Sym, r loader.Reloc) (loa
                        return rr, false
                }
                rs := r.Sym()
-               rr.Xsym = loader.Sym(ldr.SymSect(rs).Sym)
+               rr.Xsym = ldr.SymSect(rs).Sym
                rr.Xadd = r.Add() + ldr.SymValue(rs) - int64(ldr.SymSect(rs).Vaddr)
 
        // r.Sym() can be 0 when CALL $(constant) is transformed from absolute PC to relative PC call.
@@ -2268,7 +2268,7 @@ func (state *dodataState) allocateDwarfSections(ctxt *Link) {
                s := dwarfp[i].secSym()
                sect := state.allocateNamedDataSection(&Segdwarf, ldr.SymName(s), []sym.SymKind{}, 04)
                ldr.SetSymSect(s, sect)
-               sect.Sym = sym.LoaderSym(s)
+               sect.Sym = s
                curType := ldr.SymType(s)
                state.setSymType(s, sym.SRODATA)
                ldr.SetSymValue(s, int64(uint64(state.datsize)-sect.Vaddr))
index 0003938ef2e03665e0f9e22b8524351d9b00c2a9..222e712edeb608e758b8794e3c7ed30bda6f185b 100644 (file)
@@ -1011,7 +1011,7 @@ func (d *dwctxt) addDwarfAddrRef(sb *loader.SymbolBuilder, t loader.Sym) {
 func (d *dwctxt) calcCompUnitRanges() {
        var prevUnit *sym.CompilationUnit
        for _, s := range d.linkctxt.Textp {
-               sym := loader.Sym(s)
+               sym := s
 
                fi := d.ldr.FuncInfo(sym)
                if !fi.Valid() {
@@ -1033,7 +1033,7 @@ func (d *dwctxt) calcCompUnitRanges() {
                // only create boundaries between symbols from
                // different units.
                sval := d.ldr.SymValue(sym)
-               u0val := d.ldr.SymValue(loader.Sym(unit.Textp[0]))
+               u0val := d.ldr.SymValue(unit.Textp[0])
                if prevUnit != unit {
                        unit.PCs = append(unit.PCs, dwarf.Range{Start: sval - u0val})
                        prevUnit = unit
@@ -1339,7 +1339,7 @@ func (d *dwctxt) writelines(unit *sym.CompilationUnit, lineProlog loader.Sym) []
 
        // Output the state machine for each function remaining.
        for _, s := range unit.Textp {
-               fnSym := loader.Sym(s)
+               fnSym := s
                _, _, _, lines := d.ldr.GetFuncDwarfAuxSyms(fnSym)
 
                // Chain the line symbol onto the list.
@@ -1399,7 +1399,7 @@ func (d *dwctxt) writepcranges(unit *sym.CompilationUnit, base loader.Sym, pcs [
        // Collect up the ranges for functions in the unit.
        rsize := uint64(rsu.Size())
        for _, ls := range unit.RangeSyms {
-               s := loader.Sym(ls)
+               s := ls
                syms = append(syms, s)
                rsize += uint64(d.ldr.SymSize(s))
        }
@@ -1501,7 +1501,7 @@ func (d *dwctxt) writeframes(fs loader.Sym) dwarfSecInfo {
        var deltaBuf []byte
        pcsp := obj.NewPCIter(uint32(d.arch.MinLC))
        for _, s := range d.linkctxt.Textp {
-               fn := loader.Sym(s)
+               fn := s
                fi := d.ldr.FuncInfo(fn)
                if !fi.Valid() {
                        continue
@@ -1646,7 +1646,7 @@ func (d *dwctxt) writeUnitInfo(u *sym.CompilationUnit, abbrevsym loader.Sym, add
        cu = append(cu, u.AbsFnDIEs...)
        cu = append(cu, u.FuncDIEs...)
        if u.Consts != 0 {
-               cu = append(cu, loader.Sym(u.Consts))
+               cu = append(cu, u.Consts)
        }
        cu = append(cu, u.VarDIEs...)
        var cusize int64
@@ -1772,7 +1772,7 @@ func (d *dwctxt) assignDebugAddrSlot(unit *sym.CompilationUnit, fnsym loader.Sym
        if unit.Addrs == nil {
                unit.Addrs = make(map[sym.LoaderSym]uint32)
        }
-       if _, ok := unit.Addrs[sym.LoaderSym(rsym)]; ok {
+       if _, ok := unit.Addrs[rsym]; ok {
                // already present, no work needed
        } else {
                sl := len(unit.Addrs)
@@ -1781,7 +1781,7 @@ func (d *dwctxt) assignDebugAddrSlot(unit *sym.CompilationUnit, fnsym loader.Sym
                if sl > lim {
                        log.Fatalf("internal error: %s relocation overflow on infosym for %s", rt.String(), d.ldr.SymName(fnsym))
                }
-               unit.Addrs[sym.LoaderSym(rsym)] = uint32(sl)
+               unit.Addrs[rsym] = uint32(sl)
                sb.AddAddrPlus(d.arch, rsym, 0)
                data := sb.Data()
                if d.arch.PtrSize == 4 {
@@ -1805,11 +1805,11 @@ func (d *dwctxt) dwarfVisitFunction(fnSym loader.Sym, unit *sym.CompilationUnit)
        }
        d.ldr.SetAttrNotInSymbolTable(infosym, true)
        d.ldr.SetAttrReachable(infosym, true)
-       unit.FuncDIEs = append(unit.FuncDIEs, sym.LoaderSym(infosym))
+       unit.FuncDIEs = append(unit.FuncDIEs, infosym)
        if rangesym != 0 {
                d.ldr.SetAttrNotInSymbolTable(rangesym, true)
                d.ldr.SetAttrReachable(rangesym, true)
-               unit.RangeSyms = append(unit.RangeSyms, sym.LoaderSym(rangesym))
+               unit.RangeSyms = append(unit.RangeSyms, rangesym)
        }
 
        // Walk the relocations of the subprogram DIE symbol to discover
@@ -1836,7 +1836,7 @@ func (d *dwctxt) dwarfVisitFunction(fnSym loader.Sym, unit *sym.CompilationUnit)
                        if !d.ldr.AttrOnList(rsym) {
                                // abstract function
                                d.ldr.SetAttrOnList(rsym, true)
-                               unit.AbsFnDIEs = append(unit.AbsFnDIEs, sym.LoaderSym(rsym))
+                               unit.AbsFnDIEs = append(unit.AbsFnDIEs, rsym)
                                d.importInfoSymbol(rsym)
                        }
                        continue
@@ -1942,7 +1942,7 @@ func dwarfGenerateDebugInfo(ctxt *Link) {
                for _, unit := range lib.Units {
                        // We drop the constants into the first CU.
                        if consts != 0 {
-                               unit.Consts = sym.LoaderSym(consts)
+                               unit.Consts = consts
                                d.importInfoSymbol(consts)
                                consts = 0
                        }
@@ -2008,7 +2008,7 @@ func dwarfGenerateDebugInfo(ctxt *Link) {
                        // abstract functions, visit range symbols. Note that
                        // Textp has been dead-code-eliminated already.
                        for _, s := range unit.Textp {
-                               d.dwarfVisitFunction(loader.Sym(s), unit)
+                               d.dwarfVisitFunction(s, unit)
                        }
                }
        }
@@ -2073,7 +2073,7 @@ func dwarfGenerateDebugInfo(ctxt *Link) {
                if varDIE != 0 {
                        unit := d.ldr.SymUnit(idx)
                        d.defgotype(gt)
-                       unit.VarDIEs = append(unit.VarDIEs, sym.LoaderSym(varDIE))
+                       unit.VarDIEs = append(unit.VarDIEs, varDIE)
                }
        }
 
@@ -2125,7 +2125,7 @@ type dwUnitSyms struct {
 func (d *dwctxt) dwUnitPortion(u *sym.CompilationUnit, abbrevsym loader.Sym, us *dwUnitSyms) {
        if u.DWInfo.Abbrev != dwarf.DW_ABRV_COMPUNIT_TEXTLESS {
                us.linesyms = d.writelines(u, us.lineProlog)
-               base := loader.Sym(u.Textp[0])
+               base := u.Textp[0]
                if buildcfg.Experiment.Dwarf5 {
                        d.writedebugaddr(u, us.addrsym)
                }
@@ -2145,7 +2145,7 @@ func (d *dwctxt) writedebugaddr(unit *sym.CompilationUnit, debugaddr loader.Sym)
 
        var dsyms []loader.Sym
        for _, s := range unit.Textp {
-               fnSym := loader.Sym(s)
+               fnSym := s
                // NB: this looks at SDWARFFCN; it will need to also look
                // at range and loc when they get there.
                infosym, locsym, rangessym, _ := d.ldr.GetFuncDwarfAuxSyms(fnSym)
@@ -2305,8 +2305,8 @@ func (d *dwctxt) dwarfGenerateDebugSyms() {
                len += uint64(d.ldr.SymSize(hdrsym))
                su := d.ldr.MakeSymbolUpdater(hdrsym)
                if isDwarf64(d.linkctxt) {
-                       len -= 12                          // sub size of length field
-                       su.SetUint(d.arch, 4, uint64(len)) // 4 because of 0XFFFFFFFF
+                       len -= 12                  // sub size of length field
+                       su.SetUint(d.arch, 4, len) // 4 because of 0XFFFFFFFF
                } else {
                        len -= 4 // subtract size of length field
                        su.SetUint32(d.arch, 0, uint32(len))
@@ -2377,7 +2377,7 @@ func (d *dwctxt) dwarfGenerateDebugSyms() {
 func (d *dwctxt) collectUnitLocs(u *sym.CompilationUnit) []loader.Sym {
        syms := []loader.Sym{}
        for _, fn := range u.FuncDIEs {
-               relocs := d.ldr.Relocs(loader.Sym(fn))
+               relocs := d.ldr.Relocs(fn)
                for i := 0; i < relocs.Count(); i++ {
                        reloc := relocs.At(i)
                        if reloc.Type() != objabi.R_DWARFSECREF {
@@ -2510,7 +2510,7 @@ func dwarfcompress(ctxt *Link) {
                        ldr.SetSymValue(s, int64(pos))
                        sect := ldr.SymSect(s)
                        if sect != prevSect {
-                               sect.Vaddr = uint64(pos)
+                               sect.Vaddr = pos
                                prevSect = sect
                        }
                        if ldr.SubSym(s) != 0 {
index 6ff1d9438337836c166d2ee8faa8e234ffa4b225..ed215d7fe50128a5384c7a6b1868e5b583e391a6 100644 (file)
@@ -343,8 +343,8 @@ func elf32phdr(out *OutBuf, e *ElfPhdr) {
 
 func elf64shdr(out *OutBuf, e *ElfShdr) {
        out.Write32(e.Name)
-       out.Write32(uint32(e.Type))
-       out.Write64(uint64(e.Flags))
+       out.Write32(e.Type)
+       out.Write64(e.Flags)
        out.Write64(e.Addr)
        out.Write64(e.Off)
        out.Write64(e.Size)
@@ -356,7 +356,7 @@ func elf64shdr(out *OutBuf, e *ElfShdr) {
 
 func elf32shdr(out *OutBuf, e *ElfShdr) {
        out.Write32(e.Name)
-       out.Write32(uint32(e.Type))
+       out.Write32(e.Type)
        out.Write32(uint32(e.Flags))
        out.Write32(uint32(e.Addr))
        out.Write32(uint32(e.Off))
@@ -442,9 +442,9 @@ func getElfEhdr() *ElfEhdr {
 
 func elf64writehdr(out *OutBuf) uint32 {
        out.Write(ehdr.Ident[:])
-       out.Write16(uint16(ehdr.Type))
-       out.Write16(uint16(ehdr.Machine))
-       out.Write32(uint32(ehdr.Version))
+       out.Write16(ehdr.Type)
+       out.Write16(ehdr.Machine)
+       out.Write32(ehdr.Version)
        out.Write64(ehdr.Entry)
        out.Write64(ehdr.Phoff)
        out.Write64(ehdr.Shoff)
@@ -460,9 +460,9 @@ func elf64writehdr(out *OutBuf) uint32 {
 
 func elf32writehdr(out *OutBuf) uint32 {
        out.Write(ehdr.Ident[:])
-       out.Write16(uint16(ehdr.Type))
-       out.Write16(uint16(ehdr.Machine))
-       out.Write32(uint32(ehdr.Version))
+       out.Write16(ehdr.Type)
+       out.Write16(ehdr.Machine)
+       out.Write32(ehdr.Version)
        out.Write32(uint32(ehdr.Entry))
        out.Write32(uint32(ehdr.Phoff))
        out.Write32(uint32(ehdr.Shoff))
@@ -1379,7 +1379,7 @@ func elfEmitReloc(ctxt *Link) {
        for i := 0; i < len(Segdwarf.Sections); i++ {
                sect := Segdwarf.Sections[i]
                si := dwarfp[i]
-               if si.secSym() != loader.Sym(sect.Sym) ||
+               if si.secSym() != sect.Sym ||
                        ctxt.loader.SymSect(si.secSym()) != sect {
                        panic("inconsistency between dwarfp and Segdwarf")
                }
@@ -1426,7 +1426,7 @@ func (ctxt *Link) doelf() {
 
        shstrtabAddstring := func(s string) {
                off := addshstr(s)
-               elfsetstring(ctxt, 0, s, int(off))
+               elfsetstring(ctxt, 0, s, off)
        }
 
        shstrtabAddstring("")
index c26263466616f5c99164e8433b6bc572efb942a7..8e059f299ffa7317537da4fa960cebc3cb2febd0 100644 (file)
@@ -1254,7 +1254,7 @@ func machoEmitReloc(ctxt *Link) {
        for i := 0; i < len(Segdwarf.Sections); i++ {
                sect := Segdwarf.Sections[i]
                si := dwarfp[i]
-               if si.secSym() != loader.Sym(sect.Sym) ||
+               if si.secSym() != sect.Sym ||
                        ctxt.loader.SymSect(si.secSym()) != sect {
                        panic("inconsistency between dwarfp and Segdwarf")
                }
@@ -1535,11 +1535,11 @@ func machoCodeSign(ctxt *Link, fname string) error {
                // Uodate the __LINKEDIT segment.
                segSz := sigOff + sz - int64(linkeditSeg.Offset)
                mf.ByteOrder.PutUint64(tmp[:8], uint64(segSz))
-               _, err = f.WriteAt(tmp[:8], int64(linkeditOff)+int64(unsafe.Offsetof(macho.Segment64{}.Memsz)))
+               _, err = f.WriteAt(tmp[:8], linkeditOff+int64(unsafe.Offsetof(macho.Segment64{}.Memsz)))
                if err != nil {
                        return err
                }
-               _, err = f.WriteAt(tmp[:8], int64(linkeditOff)+int64(unsafe.Offsetof(macho.Segment64{}.Filesz)))
+               _, err = f.WriteAt(tmp[:8], linkeditOff+int64(unsafe.Offsetof(macho.Segment64{}.Filesz)))
                if err != nil {
                        return err
                }
index 9532b33a9bc1ccd1434636c9573b0cc25f9ad0b1..2b3687c37e4a6a8a930276608a96c051f13613dd 100644 (file)
@@ -216,7 +216,7 @@ func genInlTreeSym(ctxt *Link, cu *sym.CompilationUnit, fi loader.FuncInfo, arch
                const size = 16
                inlTreeSym.SetUint8(arch, int64(i*size+0), uint8(funcID))
                // Bytes 1-3 are unused.
-               inlTreeSym.SetUint32(arch, int64(i*size+4), uint32(nameOff))
+               inlTreeSym.SetUint32(arch, int64(i*size+4), nameOff)
                inlTreeSym.SetUint32(arch, int64(i*size+8), uint32(call.ParentPC))
                inlTreeSym.SetUint32(arch, int64(i*size+12), uint32(startLine))
        }
@@ -683,14 +683,14 @@ func writeFuncs(ctxt *Link, sb *loader.SymbolBuilder, funcs []loader.Sym, inlSym
                off := int64(startLocations[i])
                // entryOff uint32 (offset of func entry PC from textStart)
                entryOff := textOff(ctxt, s, textStart)
-               off = sb.SetUint32(ctxt.Arch, off, uint32(entryOff))
+               off = sb.SetUint32(ctxt.Arch, off, entryOff)
 
                // nameOff int32
                nameOff, ok := nameOffsets[s]
                if !ok {
                        panic("couldn't find function name offset")
                }
-               off = sb.SetUint32(ctxt.Arch, off, uint32(nameOff))
+               off = sb.SetUint32(ctxt.Arch, off, nameOff)
 
                // args int32
                // TODO: Move into funcinfo.
@@ -712,7 +712,7 @@ func writeFuncs(ctxt *Link, sb *loader.SymbolBuilder, funcs []loader.Sym, inlSym
                } else {
                        off += 12
                }
-               off = sb.SetUint32(ctxt.Arch, off, uint32(numPCData(ldr, s, fi)))
+               off = sb.SetUint32(ctxt.Arch, off, numPCData(ldr, s, fi))
 
                // Store the offset to compilation unit's file table.
                cuIdx := ^uint32(0)
index e0186f46b035d933004045145983b2267d0c5707..f5b7580fda33070b7da657511b9cc203ec79f143 100644 (file)
@@ -653,7 +653,7 @@ dwarfLoop:
        for i := 0; i < len(Segdwarf.Sections); i++ {
                sect := Segdwarf.Sections[i]
                si := dwarfp[i]
-               if si.secSym() != loader.Sym(sect.Sym) ||
+               if si.secSym() != sect.Sym ||
                        ldr.SymSect(si.secSym()) != sect {
                        panic("inconsistency between dwarfp and Segdwarf")
                }
@@ -1506,7 +1506,7 @@ func (rt *peBaseRelocTable) addentry(ldr *loader.Loader, s loader.Sym, r *loader
        const pageSize = 0x1000
        const pageMask = pageSize - 1
 
-       addr := ldr.SymValue(s) + int64(r.Off()) - int64(PEBASE)
+       addr := ldr.SymValue(s) + int64(r.Off()) - PEBASE
        page := uint32(addr &^ pageMask)
        off := uint32(addr & pageMask)
 
index da728e2545561845ea80a4def26e6910e1121ac0..fdc16ac48f9d2b4b94bbb80fae0511706d8b5340 100644 (file)
@@ -677,7 +677,7 @@ func (f *xcoffFile) writeSymbolNewFile(ctxt *Link, name string, firstEntry uint6
                        dwsize = getDwsectCUSize(sect.Name, name)
                        // .debug_abbrev is common to all packages and not found with the previous function
                        if sect.Name == ".debug_abbrev" {
-                               dwsize = uint64(ldr.SymSize(loader.Sym(sect.Sym)))
+                               dwsize = uint64(ldr.SymSize(sect.Sym))
 
                        }
                } else {
@@ -699,7 +699,7 @@ func (f *xcoffFile) writeSymbolNewFile(ctxt *Link, name string, firstEntry uint6
                        // Dwarf relocations need the symbol number of .dw* symbols.
                        // It doesn't need to know it for each package, one is enough.
                        // currSymSrcFile.csectAux == nil means first package.
-                       ldr.SetSymDynid(loader.Sym(sect.Sym), int32(f.symbolCount))
+                       ldr.SetSymDynid(sect.Sym, int32(f.symbolCount))
 
                        if sect.Name == ".debug_frame" && ctxt.LinkMode != LinkExternal {
                                // CIE size must be added to the first package.
@@ -865,7 +865,7 @@ func (f *xcoffFile) writeSymbolFunc(ctxt *Link, x loader.Sym) []xcoffSym {
                Xsmtyp:    XTY_LD, // label definition (based on C)
                Xauxtype:  _AUX_CSECT,
        }
-       a4.Xsmtyp |= uint8(xcoffAlign(ldr, x, TextSym) << 3)
+       a4.Xsmtyp |= xcoffAlign(ldr, x, TextSym) << 3
 
        syms = append(syms, a4)
        return syms
@@ -915,7 +915,7 @@ func putaixsym(ctxt *Link, x loader.Sym, t SymbolType) {
                                Xsmclas:   XMC_PR,
                                Xsmtyp:    XTY_SD,
                        }
-                       a4.Xsmtyp |= uint8(xcoffAlign(ldr, x, TextSym) << 3)
+                       a4.Xsmtyp |= xcoffAlign(ldr, x, TextSym) << 3
                        syms = append(syms, a4)
                }
 
@@ -976,7 +976,7 @@ func putaixsym(ctxt *Link, x loader.Sym, t SymbolType) {
                        a4.Xsmtyp |= XTY_CM
                }
 
-               a4.Xsmtyp |= uint8(xcoffAlign(ldr, x, t) << 3)
+               a4.Xsmtyp |= xcoffAlign(ldr, x, t) << 3
 
                syms = append(syms, a4)
 
@@ -1375,7 +1375,7 @@ func (f *xcoffFile) writeLdrScn(ctxt *Link, globalOff uint64) {
        /* Symbol table */
        for _, s := range f.loaderSymbols {
                lds := &XcoffLdSym64{
-                       Loffset: uint32(stlen + 2),
+                       Loffset: stlen + 2,
                        Lsmtype: s.smtype,
                        Lsmclas: s.smclas,
                }
@@ -1580,7 +1580,7 @@ func xcoffwrite(ctxt *Link) {
 func asmbXcoff(ctxt *Link) {
        ctxt.Out.SeekSet(0)
        fileoff := int64(Segdwarf.Fileoff + Segdwarf.Filelen)
-       fileoff = int64(Rnd(int64(fileoff), *FlagRound))
+       fileoff = Rnd(fileoff, *FlagRound)
 
        xfile.sectNameToScnum = make(map[string]int16)
 
@@ -1693,7 +1693,7 @@ func (f *xcoffFile) emitRelocations(ctxt *Link, fileoff int64) {
                        if !ldr.AttrReachable(s) {
                                continue
                        }
-                       if ldr.SymValue(s) >= int64(eaddr) {
+                       if ldr.SymValue(s) >= eaddr {
                                break
                        }
 
@@ -1755,7 +1755,7 @@ dwarfLoop:
        for i := 0; i < len(Segdwarf.Sections); i++ {
                sect := Segdwarf.Sections[i]
                si := dwarfp[i]
-               if si.secSym() != loader.Sym(sect.Sym) ||
+               if si.secSym() != sect.Sym ||
                        ldr.SymSect(si.secSym()) != sect {
                        panic("inconsistency between dwarfp and Segdwarf")
                }
index bb0c22da7ef0acaaab3b27aabb1167bd857d8ef5..9434704be4dc994354731af7da52fba2808db037 100644 (file)
@@ -785,12 +785,12 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
                                rSym = 0
                        } else {
                                var elfsym ElfSym
-                               if err := readelfsym(l, arch, elfobj, int(symIdx), &elfsym, 0, 0); err != nil {
+                               if err := readelfsym(l, arch, elfobj, symIdx, &elfsym, 0, 0); err != nil {
                                        return errorf("malformed elf file: %v", err)
                                }
                                elfsym.sym = symbols[symIdx]
                                if elfsym.sym == 0 {
-                                       return errorf("malformed elf file: %s#%d: reloc of invalid sym #%d %s shndx=%d type=%d", l.SymName(sect.sym), j, int(symIdx), elfsym.name, elfsym.shndx, elfsym.type_)
+                                       return errorf("malformed elf file: %s#%d: reloc of invalid sym #%d %s shndx=%d type=%d", l.SymName(sect.sym), j, symIdx, elfsym.name, elfsym.shndx, elfsym.type_)
                                }
 
                                rSym = elfsym.sym
@@ -854,7 +854,7 @@ func elfmap(elfobj *ElfObj, sect *ElfSect) (err error) {
        }
 
        elfobj.f.MustSeek(int64(uint64(elfobj.base)+sect.off), 0)
-       sect.base, sect.readOnlyMem, err = elfobj.f.Slice(uint64(sect.size))
+       sect.base, sect.readOnlyMem, err = elfobj.f.Slice(sect.size)
        if err != nil {
                return fmt.Errorf("short read: %v", err)
        }
index 0ed20d1becbb03122aad621a300c15751f74a093..cef17fae7817987a73cdec1e8374969277578c92 100644 (file)
@@ -806,7 +806,7 @@ func (l *Loader) SymVersion(i Sym) int {
                return pp.ver
        }
        r, li := l.toLocal(i)
-       return int(abiToVer(r.Sym(li).ABI(), r.version))
+       return abiToVer(r.Sym(li).ABI(), r.version)
 }
 
 func (l *Loader) IsFileLocal(i Sym) bool {
@@ -2748,15 +2748,15 @@ func (l *Loader) AssignTextSymbolOrder(libs []*sym.Library, intlibs []bool, exts
                                // We still need to record its presence in the current
                                // package, as the trampoline pass expects packages
                                // are laid out in dependency order.
-                               lib.DupTextSyms = append(lib.DupTextSyms, sym.LoaderSym(gi))
+                               lib.DupTextSyms = append(lib.DupTextSyms, gi)
                                continue // symbol in different object
                        }
                        if dupok {
-                               lib.DupTextSyms = append(lib.DupTextSyms, sym.LoaderSym(gi))
+                               lib.DupTextSyms = append(lib.DupTextSyms, gi)
                                continue
                        }
 
-                       lib.Textp = append(lib.Textp, sym.LoaderSym(gi))
+                       lib.Textp = append(lib.Textp, gi)
                }
        }
 
@@ -2769,7 +2769,7 @@ func (l *Loader) AssignTextSymbolOrder(libs []*sym.Library, intlibs []bool, exts
                        lists := [2][]sym.LoaderSym{lib.Textp, lib.DupTextSyms}
                        for i, list := range lists {
                                for _, s := range list {
-                                       sym := Sym(s)
+                                       sym := s
                                        if !assignedToUnit.Has(sym) {
                                                textp = append(textp, sym)
                                                unit := l.SymUnit(sym)
index 6adafd38fc5466f06a4db17b302b667970073cd8..e7f3fd1d9817ad3184322e19dc00021085ae02fe 100644 (file)
@@ -273,7 +273,7 @@ func adddynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loade
                        } else {
                                ldr.Errorf(s, "unexpected relocation for dynamic symbol %s", ldr.SymName(targ))
                        }
-                       rela.AddAddrPlus(target.Arch, targ, int64(r.Add()))
+                       rela.AddAddrPlus(target.Arch, targ, r.Add())
                        return true
                }
 
@@ -496,30 +496,30 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
                pc := ldr.SymValue(s) + int64(r.Off())
                t := calculatePCAlignedReloc(r.Type(), ldr.SymAddr(rs)+r.Add(), pc)
                if r.Type() == objabi.R_LOONG64_ADDR_LO {
-                       return int64(val&0xffc003ff | (t << 10)), noExtReloc, isOk
+                       return val&0xffc003ff | (t << 10), noExtReloc, isOk
                }
-               return int64(val&0xfe00001f | (t << 5)), noExtReloc, isOk
+               return val&0xfe00001f | (t << 5), noExtReloc, isOk
        case objabi.R_LOONG64_TLS_LE_HI,
                objabi.R_LOONG64_TLS_LE_LO:
                t := ldr.SymAddr(rs) + r.Add()
                if r.Type() == objabi.R_LOONG64_TLS_LE_LO {
-                       return int64(val&0xffc003ff | ((t & 0xfff) << 10)), noExtReloc, isOk
+                       return val&0xffc003ff | ((t & 0xfff) << 10), noExtReloc, isOk
                }
-               return int64(val&0xfe00001f | (((t) >> 12 << 5) & 0x1ffffe0)), noExtReloc, isOk
+               return val&0xfe00001f | (((t) >> 12 << 5) & 0x1ffffe0), noExtReloc, isOk
        case objabi.R_CALLLOONG64,
                objabi.R_JMPLOONG64:
                pc := ldr.SymValue(s) + int64(r.Off())
                t := ldr.SymAddr(rs) + r.Add() - pc
-               return int64(val&0xfc000000 | (((t >> 2) & 0xffff) << 10) | (((t >> 2) & 0x3ff0000) >> 16)), noExtReloc, isOk
+               return val&0xfc000000 | (((t >> 2) & 0xffff) << 10) | (((t >> 2) & 0x3ff0000) >> 16), noExtReloc, isOk
 
        case objabi.R_JMP16LOONG64,
                objabi.R_JMP21LOONG64:
                pc := ldr.SymValue(s) + int64(r.Off())
                t := ldr.SymAddr(rs) + r.Add() - pc
                if r.Type() == objabi.R_JMP16LOONG64 {
-                       return int64(val&0xfc0003ff | (((t >> 2) & 0xffff) << 10)), noExtReloc, isOk
+                       return val&0xfc0003ff | (((t >> 2) & 0xffff) << 10), noExtReloc, isOk
                }
-               return int64(val&0xfc0003e0 | (((t >> 2) & 0xffff) << 10) | (((t >> 2) & 0x1f0000) >> 16)), noExtReloc, isOk
+               return val&0xfc0003e0 | (((t >> 2) & 0xffff) << 10) | (((t >> 2) & 0x1f0000) >> 16), noExtReloc, isOk
 
        case objabi.R_LOONG64_TLS_IE_HI,
                objabi.R_LOONG64_TLS_IE_LO:
@@ -540,9 +540,9 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
 
        case objabi.R_LOONG64_ADD64, objabi.R_LOONG64_SUB64:
                if r.Type() == objabi.R_LOONG64_ADD64 {
-                       return int64(val + ldr.SymAddr(rs) + r.Add()), noExtReloc, isOk
+                       return val + ldr.SymAddr(rs) + r.Add(), noExtReloc, isOk
                }
-               return int64(val - (ldr.SymAddr(rs) + r.Add())), noExtReloc, isOk
+               return val - (ldr.SymAddr(rs) + r.Add()), noExtReloc, isOk
        }
 
        return val, 0, false
@@ -628,7 +628,7 @@ func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) {
                        for i := 0; ; i++ {
                                oName := ldr.SymName(rs)
                                name := oName + fmt.Sprintf("%+x-tramp%d", r.Add(), i)
-                               tramp = ldr.LookupOrCreateSym(name, int(ldr.SymVersion(rs)))
+                               tramp = ldr.LookupOrCreateSym(name, ldr.SymVersion(rs))
                                ldr.SetAttrReachable(tramp, true)
                                if ldr.SymType(tramp) == sym.SDYNIMPORT {
                                        // don't reuse trampoline defined in other module
index e82d986184110955d0015691d88177a8cf7258a0..a86ded65f289fc9930e6ddb38485047d41d79c4e 100644 (file)
@@ -298,9 +298,9 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
                objabi.R_ADDRMIPSU:
                t := ldr.SymValue(rs) + r.Add()
                if r.Type() == objabi.R_ADDRMIPS {
-                       return int64(val&0xffff0000 | t&0xffff), noExtReloc, isOk
+                       return val&0xffff0000 | t&0xffff, noExtReloc, isOk
                }
-               return int64(val&0xffff0000 | ((t+1<<15)>>16)&0xffff), noExtReloc, isOk
+               return val&0xffff0000 | ((t+1<<15)>>16)&0xffff, noExtReloc, isOk
        case objabi.R_ADDRMIPSTLS:
                // thread pointer is at 0x7000 offset from the start of TLS data area
                t := ldr.SymValue(rs) + r.Add() - 0x7000
@@ -312,12 +312,12 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
                if t < -32768 || t >= 32678 {
                        ldr.Errorf(s, "TLS offset out of range %d", t)
                }
-               return int64(val&0xffff0000 | t&0xffff), noExtReloc, isOk
+               return val&0xffff0000 | t&0xffff, noExtReloc, isOk
        case objabi.R_CALLMIPS,
                objabi.R_JMPMIPS:
                // Low 26 bits = (S + A) >> 2
                t := ldr.SymValue(rs) + r.Add()
-               return int64(val&0xfc000000 | (t>>2)&^0xfc000000), noExtReloc, isOk
+               return val&0xfc000000 | (t>>2)&^0xfc000000, noExtReloc, isOk
        }
 
        return val, 0, false
index af7cddff7f073012e5f03178d29e66fd598c0c1c..5ceab3aa5a1255377f4601611ef4e6401d0cfc3f 100644 (file)
@@ -853,7 +853,7 @@ func addelfdynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s lo
                } else {
                        ldr.Errorf(s, "unexpected relocation for dynamic symbol %s", ldr.SymName(targ))
                }
-               rela.AddAddrPlus(target.Arch, targ, int64(r.Add()))
+               rela.AddAddrPlus(target.Arch, targ, r.Add())
 
                // Not mark r done here. So we still apply it statically,
                // so in the file content we'll also have the right offset
@@ -1208,7 +1208,7 @@ func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) {
 
                                // Look up the trampoline in case it already exists
 
-                               tramp = ldr.LookupOrCreateSym(name, int(ldr.SymVersion(rs)))
+                               tramp = ldr.LookupOrCreateSym(name, ldr.SymVersion(rs))
                                if oName == "runtime.deferreturn" {
                                        ldr.SetIsDeferReturnTramp(tramp, true)
                                }
index f85658372775e38df569a94f417c6e03a48b1a23..9d69152af0ec359cdb7c58c524a172be6493c731 100644 (file)
@@ -497,7 +497,7 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
                }
                immMask := int64(riscv.JTypeImmMask)
 
-               val = (val &^ immMask) | int64(imm)
+               val = (val &^ immMask) | imm
 
                return val, 0, true
 
@@ -719,7 +719,7 @@ func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) {
                        if r.Add() != 0 {
                                name = fmt.Sprintf("%s%+x-tramp%d", oName, r.Add(), i)
                        }
-                       tramp = ldr.LookupOrCreateSym(name, int(ldr.SymVersion(rs)))
+                       tramp = ldr.LookupOrCreateSym(name, ldr.SymVersion(rs))
                        ldr.SetAttrReachable(tramp, true)
                        if ldr.SymType(tramp) == sym.SDYNIMPORT {
                                // Do not reuse trampoline defined in other module.
@@ -744,7 +744,7 @@ func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) {
                if ldr.SymType(tramp) == 0 {
                        trampb := ldr.MakeSymbolUpdater(tramp)
                        ctxt.AddTramp(trampb, ldr.SymType(s))
-                       genCallTramp(ctxt.Arch, ctxt.LinkMode, ldr, trampb, rs, int64(r.Add()))
+                       genCallTramp(ctxt.Arch, ctxt.LinkMode, ldr, trampb, rs, r.Add())
                }
                sb := ldr.MakeSymbolUpdater(s)
                if ldr.SymValue(rs) == 0 {
index d03102cc6be629cc1cbeb13e709bc7cc6ca5ab9a..2ddf5b33ba273a12f838038e2b8a40ac13f3e153 100644 (file)
@@ -302,11 +302,11 @@ func writeTypeSec(ctxt *ld.Link, types []*wasmFuncType) {
                ctxt.Out.WriteByte(0x60) // functype
                writeUleb128(ctxt.Out, uint64(len(t.Params)))
                for _, v := range t.Params {
-                       ctxt.Out.WriteByte(byte(v))
+                       ctxt.Out.WriteByte(v)
                }
                writeUleb128(ctxt.Out, uint64(len(t.Results)))
                for _, v := range t.Results {
-                       ctxt.Out.WriteByte(byte(v))
+                       ctxt.Out.WriteByte(v)
                }
        }
 
index 9c3da66217fd07a7c61bae5be7a97a53b76b3d99..46638a1cdbe7f814651a676c1f0108d874c18ef3 100644 (file)
@@ -147,7 +147,7 @@ func (gs *gState[R]) start(ts trace.Time, resource R, ctx *traceContext) {
                        Name:         gs.startCause.name,
                        Start:        ctx.elapsed(gs.startCause.time),
                        End:          ctx.elapsed(ts),
-                       FromResource: uint64(gs.startCause.resource),
+                       FromResource: gs.startCause.resource,
                        ToResource:   uint64(resource),
                        FromStack:    ctx.Stack(viewerFrames(gs.startCause.stack)),
                })
index 9cfc578372164644a981c633aa1e0c4d8ebe91c2..6b7ef74bd2b94559b46a86a7fddf8691b2871538 100644 (file)
@@ -84,8 +84,7 @@ func _C_res_nclose(state *_C_struct___res_state) {
 }
 
 func cgoNameinfoPTR(b []byte, sa *syscall.RawSockaddr, salen int) (int, error) {
-       gerrno, err := unix.Getnameinfo(sa, salen, &b[0], len(b), nil, 0, unix.NI_NAMEREQD)
-       return int(gerrno), err
+       return unix.Getnameinfo(sa, salen, &b[0], len(b), nil, 0, unix.NI_NAMEREQD)
 }
 
 func cgoSockaddrInet4(ip IP) *syscall.RawSockaddr {
index 36efef39c032c7d22aeb2db4f79e6c22c9a5ef4f..6ee2c2854934734e69f40d39ccc2ff3993dad175 100644 (file)
@@ -469,42 +469,42 @@ func initMetrics() {
                        deps: makeStatDepSet(schedStatsDep),
                        compute: func(in *statAggregate, out *metricValue) {
                                out.kind = metricKindUint64
-                               out.scalar = uint64(in.schedStats.gTotal)
+                               out.scalar = in.schedStats.gTotal
                        },
                },
                "/sched/goroutines/not-in-go:goroutines": {
                        deps: makeStatDepSet(schedStatsDep),
                        compute: func(in *statAggregate, out *metricValue) {
                                out.kind = metricKindUint64
-                               out.scalar = uint64(in.schedStats.gNonGo)
+                               out.scalar = in.schedStats.gNonGo
                        },
                },
                "/sched/goroutines/running:goroutines": {
                        deps: makeStatDepSet(schedStatsDep),
                        compute: func(in *statAggregate, out *metricValue) {
                                out.kind = metricKindUint64
-                               out.scalar = uint64(in.schedStats.gRunning)
+                               out.scalar = in.schedStats.gRunning
                        },
                },
                "/sched/goroutines/runnable:goroutines": {
                        deps: makeStatDepSet(schedStatsDep),
                        compute: func(in *statAggregate, out *metricValue) {
                                out.kind = metricKindUint64
-                               out.scalar = uint64(in.schedStats.gRunnable)
+                               out.scalar = in.schedStats.gRunnable
                        },
                },
                "/sched/goroutines/waiting:goroutines": {
                        deps: makeStatDepSet(schedStatsDep),
                        compute: func(in *statAggregate, out *metricValue) {
                                out.kind = metricKindUint64
-                               out.scalar = uint64(in.schedStats.gWaiting)
+                               out.scalar = in.schedStats.gWaiting
                        },
                },
                "/sched/goroutines-created:goroutines": {
                        deps: makeStatDepSet(schedStatsDep),
                        compute: func(in *statAggregate, out *metricValue) {
                                out.kind = metricKindUint64
-                               out.scalar = uint64(in.schedStats.gCreated)
+                               out.scalar = in.schedStats.gCreated
                        },
                },
                "/sched/latencies:seconds": {
@@ -536,7 +536,7 @@ func initMetrics() {
                        deps: makeStatDepSet(schedStatsDep),
                        compute: func(in *statAggregate, out *metricValue) {
                                out.kind = metricKindUint64
-                               out.scalar = uint64(in.schedStats.threads)
+                               out.scalar = in.schedStats.threads
                        },
                },
                "/sync/mutex/wait/total:seconds": {