]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: remove dead code
authorqiulaidongfeng <2645477756@qq.com>
Sat, 26 Jul 2025 08:46:22 +0000 (16:46 +0800)
committerAlan Donovan <adonovan@google.com>
Tue, 5 Aug 2025 17:31:25 +0000 (10:31 -0700)
Fixes #74076

Change-Id: Icc67b3d4e342f329584433bd1250c56ae8f5a73d
Reviewed-on: https://go-review.googlesource.com/c/go/+/690635
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
52 files changed:
src/cmd/asm/internal/arch/loong64.go
src/cmd/asm/internal/asm/asm.go
src/cmd/compile/internal/importer/support.go
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/inline/inlheur/scoring.go
src/cmd/compile/internal/ir/copy.go
src/cmd/compile/internal/ir/mini.go
src/cmd/compile/internal/ir/visit.go
src/cmd/compile/internal/noder/posmap.go
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/noder/writer.go
src/cmd/compile/internal/reflectdata/reflect.go
src/cmd/compile/internal/ssa/biasedsparsemap.go
src/cmd/compile/internal/ssa/debug.go
src/cmd/compile/internal/ssa/expand_calls.go
src/cmd/compile/internal/ssa/prove.go
src/cmd/compile/internal/ssa/regalloc.go
src/cmd/compile/internal/ssa/rewrite.go
src/cmd/compile/internal/ssagen/ssa.go
src/cmd/compile/internal/syntax/printer.go
src/cmd/compile/internal/typecheck/iexport.go
src/cmd/compile/internal/typecheck/stmt.go
src/cmd/compile/internal/types/type.go
src/cmd/compile/internal/types2/api.go
src/cmd/compile/internal/types2/compilersupport.go
src/cmd/dist/imports.go
src/cmd/dist/util.go
src/cmd/go/internal/gover/toolchain.go
src/cmd/go/internal/lockedfile/internal/filelock/filelock.go
src/cmd/go/internal/modfetch/codehost/git.go
src/cmd/go/internal/modfetch/coderepo.go
src/cmd/go/internal/modindex/build.go
src/cmd/go/internal/modindex/read.go
src/cmd/go/internal/modload/buildlist.go
src/cmd/go/internal/modload/init.go
src/cmd/go/internal/work/gc.go
src/cmd/internal/archive/archive.go
src/cmd/internal/gcprog/gcprog.go
src/cmd/internal/goobj/objfile.go
src/cmd/internal/obj/arm64/asm7.go
src/cmd/internal/obj/loong64/asm.go
src/cmd/internal/obj/loong64/obj.go
src/cmd/internal/obj/ppc64/asm9.go
src/cmd/internal/obj/riscv/obj.go
src/cmd/internal/obj/s390x/asmz.go
src/cmd/internal/obj/x86/asm6.go
src/cmd/internal/obj/x86/obj6.go
src/cmd/internal/robustio/robustio.go
src/cmd/internal/script/engine.go
src/cmd/link/internal/amd64/asm.go
src/cmd/link/internal/ld/decodesym.go
src/cmd/trace/viewer.go

index bf5175f4a0bad6263b671db3ff5a55bcbd889fb3..21263d34331513fbfacfc32f15be318b4b0dc6ed 100644 (file)
@@ -23,18 +23,6 @@ func jumpLoong64(word string) bool {
        return false
 }
 
-// IsLoong64MUL reports whether the op (as defined by an loong64.A* constant) is
-// one of the MUL/DIV/REM instructions that require special handling.
-func IsLoong64MUL(op obj.As) bool {
-       switch op {
-       case loong64.AMUL, loong64.AMULU, loong64.AMULV, loong64.AMULVU,
-               loong64.ADIV, loong64.ADIVU, loong64.ADIVV, loong64.ADIVVU,
-               loong64.AREM, loong64.AREMU, loong64.AREMV, loong64.AREMVU:
-               return true
-       }
-       return false
-}
-
 // IsLoong64RDTIME reports whether the op (as defined by an loong64.A*
 // constant) is one of the RDTIMELW/RDTIMEHW/RDTIMED instructions that
 // require special handling.
index 9a6e22cab2c28211cef042352b233093a869ef52..6bdbcb9c1b7f0e56c11ad221fb039720d1d897b6 100644 (file)
@@ -974,14 +974,6 @@ func (p *Parser) getConstant(prog *obj.Prog, op obj.As, addr *obj.Addr) int64 {
        return addr.Offset
 }
 
-// getImmediate checks that addr represents an immediate constant and returns its value.
-func (p *Parser) getImmediate(prog *obj.Prog, op obj.As, addr *obj.Addr) int64 {
-       if addr.Type != obj.TYPE_CONST || addr.Name != 0 || addr.Reg != 0 || addr.Index != 0 {
-               p.errorf("%s: expected immediate constant; found %s", op, obj.Dconv(prog, addr))
-       }
-       return addr.Offset
-}
-
 // getRegister checks that addr represents a register and returns its value.
 func (p *Parser) getRegister(prog *obj.Prog, op obj.As, addr *obj.Addr) int16 {
        if addr.Type != obj.TYPE_REG || addr.Offset != 0 || addr.Name != 0 || addr.Index != 0 {
index a443b4d8621e547844008136f4dbfa05ef5708f5..6ce721557a052e9241b74d38b8bd3b03f7eea71e 100644 (file)
@@ -9,20 +9,14 @@ package importer
 import (
        "cmd/compile/internal/base"
        "cmd/compile/internal/types2"
-       "fmt"
        "go/token"
        "internal/pkgbits"
-       "sync"
 )
 
 func assert(p bool) {
        base.Assert(p)
 }
 
-func errorf(format string, args ...interface{}) {
-       panic(fmt.Sprintf(format, args...))
-}
-
 const deltaNewFile = -64 // see cmd/compile/internal/gc/bexport.go
 
 // Synthesize a token.Pos
@@ -31,108 +25,6 @@ type fakeFileSet struct {
        files map[string]*token.File
 }
 
-func (s *fakeFileSet) pos(file string, line, column int) token.Pos {
-       // TODO(mdempsky): Make use of column.
-
-       // Since we don't know the set of needed file positions, we
-       // reserve maxlines positions per file.
-       const maxlines = 64 * 1024
-       f := s.files[file]
-       if f == nil {
-               f = s.fset.AddFile(file, -1, maxlines)
-               s.files[file] = f
-               // Allocate the fake linebreak indices on first use.
-               // TODO(adonovan): opt: save ~512KB using a more complex scheme?
-               fakeLinesOnce.Do(func() {
-                       fakeLines = make([]int, maxlines)
-                       for i := range fakeLines {
-                               fakeLines[i] = i
-                       }
-               })
-               f.SetLines(fakeLines)
-       }
-
-       if line > maxlines {
-               line = 1
-       }
-
-       // Treat the file as if it contained only newlines
-       // and column=1: use the line number as the offset.
-       return f.Pos(line - 1)
-}
-
-var (
-       fakeLines     []int
-       fakeLinesOnce sync.Once
-)
-
-func chanDir(d int) types2.ChanDir {
-       // tag values must match the constants in cmd/compile/internal/gc/go.go
-       switch d {
-       case 1 /* Crecv */ :
-               return types2.RecvOnly
-       case 2 /* Csend */ :
-               return types2.SendOnly
-       case 3 /* Cboth */ :
-               return types2.SendRecv
-       default:
-               errorf("unexpected channel dir %d", d)
-               return 0
-       }
-}
-
-var predeclared = []types2.Type{
-       // basic types
-       types2.Typ[types2.Bool],
-       types2.Typ[types2.Int],
-       types2.Typ[types2.Int8],
-       types2.Typ[types2.Int16],
-       types2.Typ[types2.Int32],
-       types2.Typ[types2.Int64],
-       types2.Typ[types2.Uint],
-       types2.Typ[types2.Uint8],
-       types2.Typ[types2.Uint16],
-       types2.Typ[types2.Uint32],
-       types2.Typ[types2.Uint64],
-       types2.Typ[types2.Uintptr],
-       types2.Typ[types2.Float32],
-       types2.Typ[types2.Float64],
-       types2.Typ[types2.Complex64],
-       types2.Typ[types2.Complex128],
-       types2.Typ[types2.String],
-
-       // basic type aliases
-       types2.Universe.Lookup("byte").Type(),
-       types2.Universe.Lookup("rune").Type(),
-
-       // error
-       types2.Universe.Lookup("error").Type(),
-
-       // untyped types
-       types2.Typ[types2.UntypedBool],
-       types2.Typ[types2.UntypedInt],
-       types2.Typ[types2.UntypedRune],
-       types2.Typ[types2.UntypedFloat],
-       types2.Typ[types2.UntypedComplex],
-       types2.Typ[types2.UntypedString],
-       types2.Typ[types2.UntypedNil],
-
-       // package unsafe
-       types2.Typ[types2.UnsafePointer],
-
-       // invalid type
-       types2.Typ[types2.Invalid], // only appears in packages with errors
-
-       // used internally by gc; never used by this package or in .a files
-       // not to be confused with the universe any
-       anyType{},
-
-       // comparable
-       types2.Universe.Lookup("comparable").Type(),
-
-       // "any" has special handling: see usage of predeclared.
-}
-
 type anyType struct{}
 
 func (t anyType) Underlying() types2.Type { return t }
index c06f76fe9ff029158ef84a102b61f297a7a71557..b39710548ebafadd1fd903f117804018c13c9b27 100644 (file)
@@ -1211,17 +1211,6 @@ func pruneUnusedAutos(ll []*ir.Name, vis *hairyVisitor) []*ir.Name {
        return s
 }
 
-// numNonClosures returns the number of functions in list which are not closures.
-func numNonClosures(list []*ir.Func) int {
-       count := 0
-       for _, fn := range list {
-               if fn.OClosure == nil {
-                       count++
-               }
-       }
-       return count
-}
-
 func doList(list []ir.Node, do func(ir.Node) bool) bool {
        for _, x := range list {
                if x != nil {
index 28fa643132952a526b725853c288009e39216701..1396c4d800331b6e0098630bfb62fdc0e765d4b6 100644 (file)
@@ -399,14 +399,6 @@ func LargestNegativeScoreAdjustment(fn *ir.Func, props *FuncProps) int {
        return score
 }
 
-// LargestPositiveScoreAdjustment tries to estimate the largest possible
-// positive score adjustment that could be applied to a given callsite.
-// At the moment we don't have very many positive score adjustments, so
-// this is just hard-coded, not table-driven.
-func LargestPositiveScoreAdjustment(fn *ir.Func) int {
-       return adjValues[panicPathAdj] + adjValues[initFuncAdj]
-}
-
 // callSiteTab contains entries for each call in the function
 // currently being processed by InlineCalls; this variable will either
 // be set to 'cstabCache' below (for non-inlinable routines) or to the
index d30f7bc688093834e271cd2caf3dd96b75ed62b9..4ec887d397ca68cbc772d5ee8111bc9e810a3b31 100644 (file)
@@ -32,12 +32,3 @@ func DeepCopy(pos src.XPos, n Node) Node {
        }
        return edit(n)
 }
-
-// DeepCopyList returns a list of deep copies (using DeepCopy) of the nodes in list.
-func DeepCopyList(pos src.XPos, list []Node) []Node {
-       var out []Node
-       for _, n := range list {
-               out = append(out, DeepCopy(pos, n))
-       }
-       return out
-}
index 70897fc3f9c8ded156ff57903182c3747842c52b..6c91560e526441f3cd27def3fb3e06acff065185 100644 (file)
@@ -34,15 +34,6 @@ type miniNode struct {
        esc  uint16
 }
 
-// posOr returns pos if known, or else n.pos.
-// For use in DeepCopy.
-func (n *miniNode) posOr(pos src.XPos) src.XPos {
-       if pos.IsKnown() {
-               return pos
-       }
-       return n.pos
-}
-
 // op can be read, but not written.
 // An embedding implementation can provide a SetOp if desired.
 // (The panicking SetOp is with the other panics below.)
index 8dff11af335e238b30f2524bd2e40c4b570c7de8..c68bb5d0330337cac0ee8b2fc903187990241cd5 100644 (file)
@@ -155,19 +155,6 @@ func Any(n Node, cond func(Node) bool) bool {
        return do(n)
 }
 
-// AnyList calls Any(x, cond) for each node x in the list, in order.
-// If any call returns true, AnyList stops and returns true.
-// Otherwise, AnyList returns false after calling Any(x, cond)
-// for every x in the list.
-func AnyList(list Nodes, cond func(Node) bool) bool {
-       for _, x := range list {
-               if Any(x, cond) {
-                       return true
-               }
-       }
-       return false
-}
-
 // EditChildren edits the child nodes of n, replacing each child x with edit(x).
 //
 // Note that EditChildren(n, edit) only calls edit(x) for n's immediate children.
index 439daf454e6fc3c620b1c3dc16952e7c4a3cedfd..9b02765e95cfe75c181bacee4d26d6c9fd7f75d3 100644 (file)
@@ -23,7 +23,6 @@ type poser interface{ Pos() syntax.Pos }
 type ender interface{ End() syntax.Pos }
 
 func (m *posMap) pos(p poser) src.XPos { return m.makeXPos(p.Pos()) }
-func (m *posMap) end(p ender) src.XPos { return m.makeXPos(p.End()) }
 
 func (m *posMap) makeXPos(pos syntax.Pos) src.XPos {
        // Predeclared objects (e.g., the result parameter for error.Error)
index 38b0bc1d8a41530fb710fdc7ad04cb683b27ba62..3cbc7989a746138bca104466f25c0da6357bef28 100644 (file)
@@ -3681,17 +3681,6 @@ func expandInline(fn *ir.Func, pri pkgReaderIndex) {
        typecheck.Target.Funcs = typecheck.Target.Funcs[:topdcls]
 }
 
-// usedLocals returns a set of local variables that are used within body.
-func usedLocals(body []ir.Node) ir.NameSet {
-       var used ir.NameSet
-       ir.VisitList(body, func(n ir.Node) {
-               if n, ok := n.(*ir.Name); ok && n.Op() == ir.ONAME && n.Class == ir.PAUTO {
-                       used.Add(n)
-               }
-       })
-       return used
-}
-
 // @@@ Method wrappers
 //
 // Here we handle constructing "method wrappers," alternative entry
index dd79c3ef4c87cbbcdf48e63c31e160003ebd2c2c..baff0ceea0e931e545fd3ec3649da3b9b99effda 100644 (file)
@@ -2413,11 +2413,6 @@ func (p posVar) String() string {
        return p.pos.String() + ":" + p.var_.String()
 }
 
-func (w *writer) exprList(expr syntax.Expr) {
-       w.Sync(pkgbits.SyncExprList)
-       w.exprs(syntax.UnpackListExpr(expr))
-}
-
 func (w *writer) exprs(exprs []syntax.Expr) {
        w.Sync(pkgbits.SyncExprs)
        w.Len(len(exprs))
index 4d1d7801900a2eca5001ee62389bcb78cc5f5a1f..c561d527a7d1616f623088426c7453d52a870a1a 100644 (file)
@@ -1468,10 +1468,3 @@ func MarkUsedIfaceMethod(n *ir.CallExpr) {
                Add:  InterfaceMethodOffset(ityp, midx),
        })
 }
-
-func deref(t *types.Type) *types.Type {
-       if t.IsPtr() {
-               return t.Elem()
-       }
-       return t
-}
index 3032309b7a2f1b3d3217a4e58330f34e09504d77..25fbaf6862575336dc669df15c15745e7f163aea 100644 (file)
@@ -84,14 +84,6 @@ func (s *biasedSparseMap) getEntry(i int) (x uint, v int32) {
        return
 }
 
-// add inserts x->0 into s, provided that x is in the range of keys stored in s.
-func (s *biasedSparseMap) add(x uint) {
-       if int(x) < s.first || int(x) >= s.cap() {
-               return
-       }
-       s.s.set(ID(int(x)-s.first), 0)
-}
-
 // add inserts x->v into s, provided that x is in the range of keys stored in s.
 func (s *biasedSparseMap) set(x uint, v int32) {
        if int(x) < s.first || int(x) >= s.cap() {
index e92b37fb7bc342b3c9d71f1668cc90e6dbe33bd8..c9a3e4291cc1a6ce89337c37d217cc0082c97c21 100644 (file)
@@ -77,10 +77,6 @@ func (ls *liveSlot) String() string {
        return fmt.Sprintf("0x%x.%d.%d", ls.Registers, ls.stackOffsetValue(), int32(ls.StackOffset)&1)
 }
 
-func (ls liveSlot) absent() bool {
-       return ls.Registers == 0 && !ls.onStack()
-}
-
 // StackOffset encodes whether a value is on the stack and if so, where.
 // It is a 31-bit integer followed by a presence flag at the low-order
 // bit.
index 30606bb8055b76c5133bf6f13733483ee9e0ece5..1730dbf53deacfb1a1a9392bca2080bc041b5799 100644 (file)
@@ -851,27 +851,6 @@ func (c *registerCursor) plus(regWidth Abi1RO) registerCursor {
        return rc
 }
 
-// at returns the register cursor for component i of t, where the first
-// component is numbered 0.
-func (c *registerCursor) at(t *types.Type, i int) registerCursor {
-       rc := *c
-       if i == 0 || len(c.regs) == 0 {
-               return rc
-       }
-       if t.IsArray() {
-               w := c.config.NumParamRegs(t.Elem())
-               rc.nextSlice += Abi1RO(i * w)
-               return rc
-       }
-       if t.IsStruct() {
-               for j := 0; j < i; j++ {
-                       rc.next(t.FieldType(j))
-               }
-               return rc
-       }
-       panic("Haven't implemented this case yet, do I need to?")
-}
-
 func (c *registerCursor) init(regs []abi.RegIndex, info *abi.ABIParamResultInfo, result *[]*Value, storeDest *Value, storeOffset int64) {
        c.regs = regs
        c.nextSlice = 0
@@ -930,17 +909,6 @@ type expandState struct {
        indentLevel     int               // Indentation for debugging recursion
 }
 
-// intPairTypes returns the pair of 32-bit int types needed to encode a 64-bit integer type on a target
-// that has no 64-bit integer registers.
-func (x *expandState) intPairTypes(et types.Kind) (tHi, tLo *types.Type) {
-       tHi = x.typs.UInt32
-       if et == types.TINT64 {
-               tHi = x.typs.Int32
-       }
-       tLo = x.typs.UInt32
-       return
-}
-
 // offsetFrom creates an offset from a pointer, simplifying chained offsets and offsets from SP
 func (x *expandState) offsetFrom(b *Block, from *Value, offset int64, pt *types.Type) *Value {
        ft := from.Type
@@ -964,29 +932,6 @@ func (x *expandState) offsetFrom(b *Block, from *Value, offset int64, pt *types.
        return b.NewValue1I(from.Pos.WithNotStmt(), OpOffPtr, pt, offset, from)
 }
 
-func (x *expandState) regWidth(t *types.Type) Abi1RO {
-       return Abi1RO(x.f.ABI1.NumParamRegs(t))
-}
-
-// regOffset returns the register offset of the i'th element of type t
-func (x *expandState) regOffset(t *types.Type, i int) Abi1RO {
-       // TODO maybe cache this in a map if profiling recommends.
-       if i == 0 {
-               return 0
-       }
-       if t.IsArray() {
-               return Abi1RO(i) * x.regWidth(t.Elem())
-       }
-       if t.IsStruct() {
-               k := Abi1RO(0)
-               for j := 0; j < i; j++ {
-                       k += x.regWidth(t.FieldType(j))
-               }
-               return k
-       }
-       panic("Haven't implemented this case yet, do I need to?")
-}
-
 // prAssignForArg returns the ABIParamAssignment for v, assumed to be an OpArg.
 func (x *expandState) prAssignForArg(v *Value) *abi.ABIParamAssignment {
        if v.Op != OpArg {
index be70226695a91dffec2a545ef7ddbe20129c1e3b..3f85bd2351f25c98ef3f18fd47aaf5eaf5ab162b 100644 (file)
@@ -145,10 +145,7 @@ func (l limit) signedMin(m int64) limit {
        l.min = max(l.min, m)
        return l
 }
-func (l limit) signedMax(m int64) limit {
-       l.max = min(l.max, m)
-       return l
-}
+
 func (l limit) signedMinMax(minimum, maximum int64) limit {
        l.min = max(l.min, minimum)
        l.max = min(l.max, maximum)
index fb9642cfedfbfd651548690862defce6d1d81987..c0881c7a45f5041a4ff1ab43ac86c6bdaa7107fc 100644 (file)
@@ -2980,11 +2980,6 @@ type desiredStateEntry struct {
        regs [4]register
 }
 
-func (d *desiredState) clear() {
-       d.entries = d.entries[:0]
-       d.avoid = 0
-}
-
 // get returns a list of desired registers for value vid.
 func (d *desiredState) get(vid ID) [4]register {
        for _, e := range d.entries {
index 87f7b517c2d3d7547e0393db1dc2365fc8361e45..03b1e39b741ebc55bd44f72c8f658ffb76c14d9a 100644 (file)
@@ -625,51 +625,16 @@ func truncate64Fto32F(f float64) float32 {
        return math.Float32frombits(r)
 }
 
-// extend32Fto64F converts a float32 value to a float64 value preserving the bit
-// pattern of the mantissa.
-func extend32Fto64F(f float32) float64 {
-       if !math.IsNaN(float64(f)) {
-               return float64(f)
-       }
-       // NaN bit patterns aren't necessarily preserved across conversion
-       // instructions so we need to do the conversion manually.
-       b := uint64(math.Float32bits(f))
-       //   | sign                  | exponent      | mantissa                    |
-       r := ((b << 32) & (1 << 63)) | (0x7ff << 52) | ((b & 0x7fffff) << (52 - 23))
-       return math.Float64frombits(r)
-}
-
 // DivisionNeedsFixUp reports whether the division needs fix-up code.
 func DivisionNeedsFixUp(v *Value) bool {
        return v.AuxInt == 0
 }
 
-// auxFrom64F encodes a float64 value so it can be stored in an AuxInt.
-func auxFrom64F(f float64) int64 {
-       if f != f {
-               panic("can't encode a NaN in AuxInt field")
-       }
-       return int64(math.Float64bits(f))
-}
-
-// auxFrom32F encodes a float32 value so it can be stored in an AuxInt.
-func auxFrom32F(f float32) int64 {
-       if f != f {
-               panic("can't encode a NaN in AuxInt field")
-       }
-       return int64(math.Float64bits(extend32Fto64F(f)))
-}
-
 // auxTo32F decodes a float32 from the AuxInt value provided.
 func auxTo32F(i int64) float32 {
        return truncate64Fto32F(math.Float64frombits(uint64(i)))
 }
 
-// auxTo64F decodes a float64 from the AuxInt value provided.
-func auxTo64F(i int64) float64 {
-       return math.Float64frombits(uint64(i))
-}
-
 func auxIntToBool(i int64) bool {
        if i == 0 {
                return false
@@ -703,12 +668,6 @@ func auxIntToValAndOff(i int64) ValAndOff {
 func auxIntToArm64BitField(i int64) arm64BitField {
        return arm64BitField(i)
 }
-func auxIntToInt128(x int64) int128 {
-       if x != 0 {
-               panic("nonzero int128 not allowed")
-       }
-       return 0
-}
 func auxIntToFlagConstant(x int64) flagConstant {
        return flagConstant(x)
 }
@@ -750,12 +709,6 @@ func valAndOffToAuxInt(v ValAndOff) int64 {
 func arm64BitFieldToAuxInt(v arm64BitField) int64 {
        return int64(v)
 }
-func int128ToAuxInt(x int128) int64 {
-       if x != 0 {
-               panic("nonzero int128 not allowed")
-       }
-       return 0
-}
 func flagConstantToAuxInt(x flagConstant) int64 {
        return int64(x)
 }
@@ -826,23 +779,6 @@ func uaddOvf(a, b int64) bool {
        return uint64(a)+uint64(b) < uint64(a)
 }
 
-// loadLSymOffset simulates reading a word at an offset into a
-// read-only symbol's runtime memory. If it would read a pointer to
-// another symbol, that symbol is returned. Otherwise, it returns nil.
-func loadLSymOffset(lsym *obj.LSym, offset int64) *obj.LSym {
-       if lsym.Type != objabi.SRODATA {
-               return nil
-       }
-
-       for _, r := range lsym.R {
-               if int64(r.Off) == offset && r.Type&^objabi.R_WEAK == objabi.R_ADDR && r.Add == 0 {
-                       return r.Sym
-               }
-       }
-
-       return nil
-}
-
 func devirtLECall(v *Value, sym *obj.LSym) *Value {
        v.Op = OpStaticLECall
        auxcall := v.Aux.(*AuxCall)
@@ -1564,10 +1500,6 @@ func GetPPC64Shiftmb(auxint int64) int64 {
        return int64(int8(auxint >> 8))
 }
 
-func GetPPC64Shiftme(auxint int64) int64 {
-       return int64(int8(auxint))
-}
-
 // Test if this value can encoded as a mask for a rlwinm like
 // operation.  Masks can also extend from the msb and wrap to
 // the lsb too.  That is, the valid masks are 32 bit strings
index 72928f267bf36030ef37f5ed62032aab878fd47d..1e2159579dfbf2e46167f731ed79d22b896aae38 100644 (file)
@@ -1322,9 +1322,6 @@ 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(t, c, s.sp)
-}
 
 // newValueOrSfCall* are wrappers around newValue*, which may create a call to a
 // soft-float runtime function instead (when emitting soft-float code).
@@ -5382,26 +5379,6 @@ func (s *state) putArg(n ir.Node, t *types.Type) *ssa.Value {
        return a
 }
 
-func (s *state) storeArgWithBase(n ir.Node, t *types.Type, base *ssa.Value, off int64) {
-       pt := types.NewPtr(t)
-       var addr *ssa.Value
-       if base == s.sp {
-               // Use special routine that avoids allocation on duplicate offsets.
-               addr = s.constOffPtrSP(pt, off)
-       } else {
-               addr = s.newValue1I(ssa.OpOffPtr, pt, off, base)
-       }
-
-       if !ssa.CanSSA(t) {
-               a := s.addr(n)
-               s.move(t, addr, a)
-               return
-       }
-
-       a := s.expr(n)
-       s.storeType(t, addr, a, 0, false)
-}
-
 // slice computes the slice v[i:j:k] and returns ptr, len, and cap of result.
 // i,j,k may be nil, in which case they are set to their default value.
 // v may be a slice, string or pointer to an array.
index 1c0bfc190ecf292efbfbb233d7b1c45fb1396703..d86d77e73f70ec57ab1da3a56e274ca85d45eb8a 100644 (file)
@@ -138,10 +138,6 @@ func impliesSemi(tok token) bool {
 
 // TODO(gri) provide table of []byte values for all tokens to avoid repeated string conversion
 
-func lineComment(text string) bool {
-       return strings.HasPrefix(text, "//")
-}
-
 func (p *printer) addWhitespace(kind ctrlSymbol, text string) {
        p.pending = append(p.pending, whitespace{p.lastTok, kind /*text*/})
        switch kind {
index 29d6b2cc2dcb55bfee0552d8706a695cf8774df0..f3498f600901181a256c6a8b259cf8aac2bf9d9a 100644 (file)
 
 package typecheck
 
-import (
-       "strings"
-)
-
 const blankMarker = "$"
 
-// TparamName returns the real name of a type parameter, after stripping its
-// qualifying prefix and reverting blank-name encoding. See TparamExportName
-// for details.
-func TparamName(exportName string) string {
-       // Remove the "path" from the type param name that makes it unique.
-       ix := strings.LastIndex(exportName, ".")
-       if ix < 0 {
-               return ""
-       }
-       name := exportName[ix+1:]
-       if strings.HasPrefix(name, blankMarker) {
-               return "_"
-       }
-       return name
-}
-
 // The name used for dictionary parameters or local variables.
 const LocalDictName = ".dict"
index ac49f251bb93a4247a89b9e8efe9f65c39c4034e..2ca8e7fb8616269dd85a4b4fb14d33baa8fd6eb7 100644 (file)
@@ -19,9 +19,6 @@ func RangeExprType(t *types.Type) *types.Type {
        return t
 }
 
-func typecheckrangeExpr(n *ir.RangeStmt) {
-}
-
 // type check assignment.
 // if this assignment is the definition of a var on the left side,
 // fill in the var's type.
index d73b5e8d7b407a43861db56fba5a28d9f396d13d..f28490fc446d3ee0d09ad8855c30396e74bc4472 100644 (file)
@@ -1694,13 +1694,6 @@ func fieldsHasShape(fields []*Field) bool {
        return false
 }
 
-// newBasic returns a new basic type of the given kind.
-func newBasic(kind Kind, obj Object) *Type {
-       t := newType(kind)
-       t.obj = obj
-       return t
-}
-
 // NewInterface returns a new interface for the given methods and
 // embedded types. Embedded types are specified as fields with no Sym.
 func NewInterface(methods []*Field) *Type {
index 49cc0e54ecf750294cbdd63dd230fb60a3875108..8752eff99212e66802fe74ec53167ba063536bfd 100644 (file)
@@ -187,10 +187,6 @@ type Config struct {
        EnableAlias bool
 }
 
-func srcimporter_setUsesCgo(conf *Config) {
-       conf.go115UsesCgo = true
-}
-
 // Info holds result type information for a type-checked package.
 // Only the information for which a map is provided is collected.
 // If the package has type errors, the collected information may
index 20a13642887a7f13917c8e2de7c5e9891de59ce2..d29241a2ed70b9013fd8877e373e291db82a4622 100644 (file)
@@ -13,12 +13,6 @@ func AsPointer(t Type) *Pointer {
        return u
 }
 
-// If t is a signature, AsSignature returns that type, otherwise it returns nil.
-func AsSignature(t Type) *Signature {
-       u, _ := t.Underlying().(*Signature)
-       return u
-}
-
 // If typ is a type parameter, CoreType returns the single underlying
 // type of all types in the corresponding type constraint if it exists, or
 // nil otherwise. If the type set contains only unrestricted and restricted
index 05dd84d0f12a0a72691b401d6c0b685c30069180..0ec2b06c4f6e7af6e12906b678d5bf4b52e6a2ab 100644 (file)
@@ -205,18 +205,6 @@ func (r *importReader) readImport(imports *[]string) {
        r.readString(imports)
 }
 
-// readComments is like ioutil.ReadAll, except that it only reads the leading
-// block of comments in the file.
-func readComments(f io.Reader) ([]byte, error) {
-       r := &importReader{b: bufio.NewReader(f)}
-       r.peekByte(true)
-       if r.err == nil && !r.eof {
-               // Didn't reach EOF, so must have found a non-space byte. Remove it.
-               r.buf = r.buf[:len(r.buf)-1]
-       }
-       return r.buf, r.err
-}
-
 // readimports returns the imports found in the named file.
 func readimports(file string) []string {
        var imports []string
index 4d5e3589dc27d377de92bf75ff1e84fd9d313d54..7db06f86ea7297ad5f535869e5531e771e7a5021 100644 (file)
@@ -362,16 +362,6 @@ func errprintf(format string, args ...interface{}) {
        fmt.Fprintf(os.Stderr, format, args...)
 }
 
-// xsamefile reports whether f1 and f2 are the same file (or dir).
-func xsamefile(f1, f2 string) bool {
-       fi1, err1 := os.Stat(f1)
-       fi2, err2 := os.Stat(f2)
-       if err1 != nil || err2 != nil {
-               return f1 == f2
-       }
-       return os.SameFile(fi1, fi2)
-}
-
 func xgetgoarm() string {
        // If we're building on an actual arm system, and not building
        // a cross-compiling toolchain, try to exec ourselves
index 43b117edcf00237da81b4d734bef76db322f58f9..a24df98168056b771a8eca885349e845f89f7621 100644 (file)
@@ -52,16 +52,6 @@ func maybeToolchainVersion(name string) string {
        return FromToolchain(name)
 }
 
-// ToolchainMax returns the maximum of x and y interpreted as toolchain names,
-// compared using Compare(FromToolchain(x), FromToolchain(y)).
-// If x and y compare equal, Max returns x.
-func ToolchainMax(x, y string) string {
-       if Compare(FromToolchain(x), FromToolchain(y)) < 0 {
-               return y
-       }
-       return x
-}
-
 // Startup records the information that went into the startup-time version switch.
 // It is initialized by switchGoToolchain.
 var Startup struct {
index d37331892d1efb5b909469f032a0b35025cba4ef..f0452f014777f9892f282811bd8ec3fe131408c8 100644 (file)
@@ -8,7 +8,6 @@
 package filelock
 
 import (
-       "errors"
        "io/fs"
 )
 
@@ -74,10 +73,3 @@ func (lt lockType) String() string {
                return "Unlock"
        }
 }
-
-// IsNotSupported returns a boolean indicating whether the error is known to
-// report that a function is not supported (possibly for a specific input).
-// It is satisfied by errors.ErrUnsupported as well as some syscall errors.
-func IsNotSupported(err error) bool {
-       return errors.Is(err, errors.ErrUnsupported)
-}
index b445ac248622021dcf97e72ca6c7df768a7e9d97..8a1c12b90a5c07309ca2d3c0bad0ccb12ee27aa3 100644 (file)
@@ -387,23 +387,6 @@ func (r *gitRepo) Latest(ctx context.Context) (*RevInfo, error) {
        return info, nil
 }
 
-// findRef finds some ref name for the given hash,
-// for use when the server requires giving a ref instead of a hash.
-// There may be multiple ref names for a given hash,
-// in which case this returns some name - it doesn't matter which.
-func (r *gitRepo) findRef(ctx context.Context, hash string) (ref string, ok bool) {
-       refs, err := r.loadRefs(ctx)
-       if err != nil {
-               return "", false
-       }
-       for ref, h := range refs {
-               if h == hash {
-                       return ref, true
-               }
-       }
-       return "", false
-}
-
 func (r *gitRepo) checkConfigSHA256(ctx context.Context) bool {
        if hashType, sha256CfgErr := r.runGit(ctx, "git", "config", "extensions.objectformat"); sha256CfgErr == nil {
                return "sha256" == strings.TrimSpace(string(hashType))
index afed35c970975e99896a84cda5f2bb519919287d..3df469d28525fa3ca2b5c229eb8363fb3f05bba6 100644 (file)
@@ -1009,10 +1009,6 @@ func LegacyGoMod(modPath string) []byte {
        return fmt.Appendf(nil, "module %s\n", modfile.AutoQuote(modPath))
 }
 
-func (r *codeRepo) modPrefix(rev string) string {
-       return r.modPath + "@" + rev
-}
-
 func (r *codeRepo) retractedVersions(ctx context.Context) (func(string) bool, error) {
        vs, err := r.Versions(ctx, "")
        if err != nil {
index d7e09fed25f43a2c4c934260cec8568db49160f3..761bda8d39b158dad9fee22b188b9ed47f327a5c 100644 (file)
@@ -10,7 +10,6 @@ package modindex
 import (
        "bytes"
        "cmd/go/internal/fsys"
-       "cmd/go/internal/str"
        "errors"
        "fmt"
        "go/ast"
@@ -118,96 +117,12 @@ func (ctxt *Context) joinPath(elem ...string) string {
        return filepath.Join(elem...)
 }
 
-// splitPathList calls ctxt.SplitPathList (if not nil) or else filepath.SplitList.
-func (ctxt *Context) splitPathList(s string) []string {
-       if f := ctxt.SplitPathList; f != nil {
-               return f(s)
-       }
-       return filepath.SplitList(s)
-}
-
-// isAbsPath calls ctxt.IsAbsPath (if not nil) or else filepath.IsAbs.
-func (ctxt *Context) isAbsPath(path string) bool {
-       if f := ctxt.IsAbsPath; f != nil {
-               return f(path)
-       }
-       return filepath.IsAbs(path)
-}
-
 // isDir reports whether path is a directory.
 func isDir(path string) bool {
        fi, err := fsys.Stat(path)
        return err == nil && fi.IsDir()
 }
 
-// hasSubdir calls ctxt.HasSubdir (if not nil) or else uses
-// the local file system to answer the question.
-func (ctxt *Context) hasSubdir(root, dir string) (rel string, ok bool) {
-       if f := ctxt.HasSubdir; f != nil {
-               return f(root, dir)
-       }
-
-       // Try using paths we received.
-       if rel, ok = hasSubdir(root, dir); ok {
-               return
-       }
-
-       // Try expanding symlinks and comparing
-       // expanded against unexpanded and
-       // expanded against expanded.
-       rootSym, _ := filepath.EvalSymlinks(root)
-       dirSym, _ := filepath.EvalSymlinks(dir)
-
-       if rel, ok = hasSubdir(rootSym, dir); ok {
-               return
-       }
-       if rel, ok = hasSubdir(root, dirSym); ok {
-               return
-       }
-       return hasSubdir(rootSym, dirSym)
-}
-
-// hasSubdir reports if dir is within root by performing lexical analysis only.
-func hasSubdir(root, dir string) (rel string, ok bool) {
-       root = str.WithFilePathSeparator(filepath.Clean(root))
-       dir = filepath.Clean(dir)
-       if !strings.HasPrefix(dir, root) {
-               return "", false
-       }
-       return filepath.ToSlash(dir[len(root):]), true
-}
-
-// gopath returns the list of Go path directories.
-func (ctxt *Context) gopath() []string {
-       var all []string
-       for _, p := range ctxt.splitPathList(ctxt.GOPATH) {
-               if p == "" || p == ctxt.GOROOT {
-                       // Empty paths are uninteresting.
-                       // If the path is the GOROOT, ignore it.
-                       // People sometimes set GOPATH=$GOROOT.
-                       // Do not get confused by this common mistake.
-                       continue
-               }
-               if strings.HasPrefix(p, "~") {
-                       // Path segments starting with ~ on Unix are almost always
-                       // users who have incorrectly quoted ~ while setting GOPATH,
-                       // preventing it from expanding to $HOME.
-                       // The situation is made more confusing by the fact that
-                       // bash allows quoted ~ in $PATH (most shells do not).
-                       // Do not get confused by this, and do not try to use the path.
-                       // It does not exist, and printing errors about it confuses
-                       // those users even more, because they think "sure ~ exists!".
-                       // The go command diagnoses this situation and prints a
-                       // useful error.
-                       // On Windows, ~ is used in short names, such as c:\progra~1
-                       // for c:\program files.
-                       continue
-               }
-               all = append(all, p)
-       }
-       return all
-}
-
 var defaultToolTags, defaultReleaseTags []string
 
 // NoGoError is the error used by Import to describe a directory
@@ -266,114 +181,12 @@ func fileListForExt(p *build.Package, ext string) *[]string {
        return nil
 }
 
-var errNoModules = errors.New("not using modules")
-
-func findImportComment(data []byte) (s string, line int) {
-       // expect keyword package
-       word, data := parseWord(data)
-       if string(word) != "package" {
-               return "", 0
-       }
-
-       // expect package name
-       _, data = parseWord(data)
-
-       // now ready for import comment, a // or /* */ comment
-       // beginning and ending on the current line.
-       for len(data) > 0 && (data[0] == ' ' || data[0] == '\t' || data[0] == '\r') {
-               data = data[1:]
-       }
-
-       var comment []byte
-       switch {
-       case bytes.HasPrefix(data, slashSlash):
-               comment, _, _ = bytes.Cut(data[2:], newline)
-       case bytes.HasPrefix(data, slashStar):
-               var ok bool
-               comment, _, ok = bytes.Cut(data[2:], starSlash)
-               if !ok {
-                       // malformed comment
-                       return "", 0
-               }
-               if bytes.Contains(comment, newline) {
-                       return "", 0
-               }
-       }
-       comment = bytes.TrimSpace(comment)
-
-       // split comment into `import`, `"pkg"`
-       word, arg := parseWord(comment)
-       if string(word) != "import" {
-               return "", 0
-       }
-
-       line = 1 + bytes.Count(data[:cap(data)-cap(arg)], newline)
-       return strings.TrimSpace(string(arg)), line
-}
-
 var (
        slashSlash = []byte("//")
        slashStar  = []byte("/*")
        starSlash  = []byte("*/")
-       newline    = []byte("\n")
 )
 
-// skipSpaceOrComment returns data with any leading spaces or comments removed.
-func skipSpaceOrComment(data []byte) []byte {
-       for len(data) > 0 {
-               switch data[0] {
-               case ' ', '\t', '\r', '\n':
-                       data = data[1:]
-                       continue
-               case '/':
-                       if bytes.HasPrefix(data, slashSlash) {
-                               i := bytes.Index(data, newline)
-                               if i < 0 {
-                                       return nil
-                               }
-                               data = data[i+1:]
-                               continue
-                       }
-                       if bytes.HasPrefix(data, slashStar) {
-                               data = data[2:]
-                               i := bytes.Index(data, starSlash)
-                               if i < 0 {
-                                       return nil
-                               }
-                               data = data[i+2:]
-                               continue
-                       }
-               }
-               break
-       }
-       return data
-}
-
-// parseWord skips any leading spaces or comments in data
-// and then parses the beginning of data as an identifier or keyword,
-// returning that word and what remains after the word.
-func parseWord(data []byte) (word, rest []byte) {
-       data = skipSpaceOrComment(data)
-
-       // Parse past leading word characters.
-       rest = data
-       for {
-               r, size := utf8.DecodeRune(rest)
-               if unicode.IsLetter(r) || '0' <= r && r <= '9' || r == '_' {
-                       rest = rest[size:]
-                       continue
-               }
-               break
-       }
-
-       word = data[:len(data)-len(rest)]
-       if len(word) == 0 {
-               return nil, nil
-       }
-
-       return word, rest
-}
-
 var dummyPkg build.Package
 
 // fileInfo records information learned about a file included in a build.
index d87fb06b57e173083bbd754df7e0cf1bf66b3312..399e89eca3cf47d859469cadd0b8a4ced07ee3d5 100644 (file)
@@ -1039,11 +1039,6 @@ func (r *reader) string() string {
        return r.d.stringTableAt(r.int())
 }
 
-// bool reads the next bool.
-func (r *reader) bool() bool {
-       return r.int() != 0
-}
-
 // tokpos reads the next token.Position.
 func (r *reader) tokpos() token.Position {
        return token.Position{
index eefc0083c93ddb61cbefc020deee8918a084f522..cd3ec4f102473b26da273ce1c372e249601e966d 100644 (file)
@@ -658,11 +658,6 @@ func EditBuildList(ctx context.Context, add, mustSelect []module.Version) (chang
        return changed, nil
 }
 
-// OverrideRoots edits the global requirement roots by replacing the specific module versions.
-func OverrideRoots(ctx context.Context, replace []module.Version) {
-       requirements = overrideRoots(ctx, requirements, replace)
-}
-
 func overrideRoots(ctx context.Context, rs *Requirements, replace []module.Version) *Requirements {
        drop := make(map[string]bool)
        for _, m := range replace {
index cb9d74df68cb5ba56e97b978e3f4e41060f81749..25151103edb5796bc1c30219b3655243f0758aab 100644 (file)
@@ -305,30 +305,6 @@ func (mms *MainModuleSet) Godebugs() []*modfile.Godebug {
        return nil
 }
 
-// Toolchain returns the toolchain set on the single module, in module mode,
-// or the go.work file in workspace mode.
-func (mms *MainModuleSet) Toolchain() string {
-       if inWorkspaceMode() {
-               if mms.workFile != nil && mms.workFile.Toolchain != nil {
-                       return mms.workFile.Toolchain.Name
-               }
-               return "go" + mms.GoVersion()
-       }
-       if mms != nil && len(mms.versions) == 1 {
-               f := mms.ModFile(mms.mustGetSingleMainModule())
-               if f == nil {
-                       // Special case: we are outside a module, like 'go run x.go'.
-                       // Assume the local Go version.
-                       // TODO(#49228): Clean this up; see loadModFile.
-                       return gover.LocalToolchain()
-               }
-               if f.Toolchain != nil {
-                       return f.Toolchain.Name
-               }
-       }
-       return "go" + mms.GoVersion()
-}
-
 func (mms *MainModuleSet) WorkFileReplaceMap() map[module.Version]module.Version {
        return mms.workFileReplaceMap
 }
index 39a1f5f74c228c2cb8045632eff539c2d98e6e3c..71c36e80cbaaabbd17539d98c6865d59fa6b0e0c 100644 (file)
@@ -6,7 +6,6 @@ package work
 
 import (
        "bufio"
-       "bytes"
        "fmt"
        "internal/buildcfg"
        "internal/platform"
@@ -438,32 +437,6 @@ func (gcToolchain) symabis(b *Builder, a *Action, sfiles []string) (string, erro
        return symabis, nil
 }
 
-// toolVerify checks that the command line args writes the same output file
-// if run using newTool instead.
-// Unused now but kept around for future use.
-func toolVerify(a *Action, b *Builder, p *load.Package, newTool string, ofile string, args []any) error {
-       newArgs := make([]any, len(args))
-       copy(newArgs, args)
-       newArgs[1] = base.Tool(newTool)
-       newArgs[3] = ofile + ".new" // x.6 becomes x.6.new
-       if err := b.Shell(a).run(p.Dir, p.ImportPath, nil, newArgs...); err != nil {
-               return err
-       }
-       data1, err := os.ReadFile(ofile)
-       if err != nil {
-               return err
-       }
-       data2, err := os.ReadFile(ofile + ".new")
-       if err != nil {
-               return err
-       }
-       if !bytes.Equal(data1, data2) {
-               return fmt.Errorf("%s and %s produced different output files:\n%s\n%s", filepath.Base(args[1].(string)), newTool, strings.Join(str.StringList(args...), " "), strings.Join(str.StringList(newArgs...), " "))
-       }
-       os.Remove(ofile + ".new")
-       return nil
-}
-
 func (gcToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) error {
        absOfiles := make([]string, 0, len(ofiles))
        for _, f := range ofiles {
index 393034d7769f2d662de1cc3db1abf2dec48316ec..b8abc0d4f648fd9430123b3e398c1d88f9adb5d8 100644 (file)
@@ -498,20 +498,6 @@ func exactly16Bytes(s string) string {
 // architecture-independent object file output
 const HeaderSize = 60
 
-func ReadHeader(b *bufio.Reader, name string) int {
-       var buf [HeaderSize]byte
-       if _, err := io.ReadFull(b, buf[:]); err != nil {
-               return -1
-       }
-       aname := strings.Trim(string(buf[0:16]), " ")
-       if !strings.HasPrefix(aname, name) {
-               return -1
-       }
-       asize := strings.Trim(string(buf[48:58]), " ")
-       i, _ := strconv.Atoi(asize)
-       return i
-}
-
 func FormatHeader(arhdr []byte, name string, size int64) {
        copy(arhdr[:], fmt.Sprintf("%-16s%-12d%-6d%-6d%-8o%-10d`\n", name, 0, 0, 0, 0644, size))
 }
index eeea53daf4a5e9404cfaffd1bfbf1123e48554d7..52505f3b20243d69eae54565e6f04828e361100e 100644 (file)
@@ -56,11 +56,6 @@ func (w *Writer) Debug(out io.Writer) {
        w.debug = out
 }
 
-// BitIndex returns the number of bits written to the bit stream so far.
-func (w *Writer) BitIndex() int64 {
-       return w.index
-}
-
 // byte writes the byte x to the output.
 func (w *Writer) byte(x byte) {
        if w.debug != nil {
@@ -98,20 +93,6 @@ func (w *Writer) Ptr(index int64) {
        w.lit(1)
 }
 
-// ShouldRepeat reports whether it would be worthwhile to
-// use a Repeat to describe c elements of n bits each,
-// compared to just emitting c copies of the n-bit description.
-func (w *Writer) ShouldRepeat(n, c int64) bool {
-       // Should we lay out the bits directly instead of
-       // encoding them as a repetition? Certainly if count==1,
-       // since there's nothing to repeat, but also if the total
-       // size of the plain pointer bits for the type will fit in
-       // 4 or fewer bytes, since using a repetition will require
-       // flushing the current bits plus at least one byte for
-       // the repeat size and one for the repeat count.
-       return c > 1 && c*n > 4*8
-}
-
 // Repeat emits an instruction to repeat the description
 // of the last n words c times (including the initial description, c+1 times in total).
 func (w *Writer) Repeat(n, c int64) {
@@ -163,36 +144,6 @@ func (w *Writer) ZeroUntil(index int64) {
        w.Repeat(1, skip-1)
 }
 
-// Append emits the given GC program into the current output.
-// The caller asserts that the program emits n bits (describes n words),
-// and Append panics if that is not true.
-func (w *Writer) Append(prog []byte, n int64) {
-       w.flushlit()
-       if w.debug != nil {
-               fmt.Fprintf(w.debug, "gcprog: append prog for %d ptrs\n", n)
-               fmt.Fprintf(w.debug, "\t")
-       }
-       n1 := progbits(prog)
-       if n1 != n {
-               panic("gcprog: wrong bit count in append")
-       }
-       // The last byte of the prog terminates the program.
-       // Don't emit that, or else our own program will end.
-       for i, x := range prog[:len(prog)-1] {
-               if w.debug != nil {
-                       if i > 0 {
-                               fmt.Fprintf(w.debug, " ")
-                       }
-                       fmt.Fprintf(w.debug, "%02x", x)
-               }
-               w.byte(x)
-       }
-       if w.debug != nil {
-               fmt.Fprintf(w.debug, "\n")
-       }
-       w.index += n
-}
-
 // progbits returns the length of the bit stream encoded by the program p.
 func progbits(p []byte) int64 {
        var n int64
index a9342427efbc0948f6a506244dfc87ac1b86ceac..38da67076d5bb26e1dc8f6a6b98a2f04dd1f061b 100644 (file)
@@ -635,29 +635,11 @@ func (r *Reader) uint64At(off uint32) uint64 {
        return binary.LittleEndian.Uint64(b)
 }
 
-func (r *Reader) int64At(off uint32) int64 {
-       return int64(r.uint64At(off))
-}
-
 func (r *Reader) uint32At(off uint32) uint32 {
        b := r.BytesAt(off, 4)
        return binary.LittleEndian.Uint32(b)
 }
 
-func (r *Reader) int32At(off uint32) int32 {
-       return int32(r.uint32At(off))
-}
-
-func (r *Reader) uint16At(off uint32) uint16 {
-       b := r.BytesAt(off, 2)
-       return binary.LittleEndian.Uint16(b)
-}
-
-func (r *Reader) uint8At(off uint32) uint8 {
-       b := r.BytesAt(off, 1)
-       return b[0]
-}
-
 func (r *Reader) StringAt(off uint32, len uint32) string {
        b := r.b[off : off+len]
        if r.readonly {
index 344b73e658f11eaf97ce210c0b6cfa46344d7ab2..0c9c70aa89aee1578ed52484d9671786c7a81784 100644 (file)
@@ -1054,15 +1054,6 @@ var sysInstFields = map[SpecialOperand]struct {
 // Used for padding NOOP instruction
 const OP_NOOP = 0xd503201f
 
-// pcAlignPadLength returns the number of bytes required to align pc to alignedValue,
-// reporting an error if alignedValue is not a power of two or is out of range.
-func pcAlignPadLength(ctxt *obj.Link, pc int64, alignedValue int64) int {
-       if !((alignedValue&(alignedValue-1) == 0) && 8 <= alignedValue && alignedValue <= 2048) {
-               ctxt.Diag("alignment value of an instruction must be a power of two and in the range [8, 2048], got %d\n", alignedValue)
-       }
-       return int(-pc & (alignedValue - 1))
-}
-
 // size returns the size of the sequence of machine instructions when p is encoded with o.
 // Usually it just returns o.size directly, in some cases it checks whether the optimization
 // conditions are met, and if so returns the size of the optimized instruction sequence.
@@ -1209,10 +1200,6 @@ type codeBuffer struct {
        data *[]byte
 }
 
-func (cb *codeBuffer) pc() int64 {
-       return int64(len(*cb.data))
-}
-
 // Write a sequence of opcodes into the code buffer.
 func (cb *codeBuffer) emit(op ...uint32) {
        for _, o := range op {
index 2ed12698e6fd987368dea9ef29c8113b0bb5062a..0d1b202e80037d0ade232f6672810fc79dde5aca 100644 (file)
@@ -729,10 +729,6 @@ func isint32(v int64) bool {
        return int64(int32(v)) == v
 }
 
-func isuint32(v uint64) bool {
-       return uint64(uint32(v)) == v
-}
-
 func (c *ctxt0) aclass(a *obj.Addr) int {
        switch a.Type {
        case obj.TYPE_NONE:
index 79fbb23fef92e1e9185383abccdfd947d64998cb..a1eb786da3106786149c80c776dc26a2255588cd 100644 (file)
@@ -771,14 +771,6 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
        return end
 }
 
-func (c *ctxt0) addnop(p *obj.Prog) {
-       q := c.newprog()
-       q.As = ANOOP
-       q.Pos = p.Pos
-       q.Link = p.Link
-       p.Link = q
-}
-
 var Linkloong64 = obj.LinkArch{
        Arch:           sys.ArchLoong64,
        Init:           buildop,
index 9cba8c33ced087156fc33b5927aa0a8b42b4df13..dcd3aa59a4690a255bb01dc6ff5c23d8b3207db5 100644 (file)
@@ -2137,10 +2137,6 @@ func OPVCC(o uint32, xo uint32, oe uint32, rc uint32) uint32 {
        return o<<26 | xo<<1 | oe<<10 | rc&1
 }
 
-func OPCC(o uint32, xo uint32, rc uint32) uint32 {
-       return OPVCC(o, xo, 0, rc)
-}
-
 /* Generate MD-form opcode */
 func OPMD(o, xo, rc uint32) uint32 {
        return o<<26 | xo<<2 | rc&1
index 078e81a2f7a317d97fac65ffa8a6a03b3ef26c65..44edb8d841837aba971c54e0965e483c8de6e50e 100644 (file)
@@ -1072,24 +1072,6 @@ func regV(r uint32) uint32 {
        return regVal(r, REG_V0, REG_V31)
 }
 
-// regAddr extracts a register from an Addr.
-func regAddr(a obj.Addr, min, max uint32) uint32 {
-       if a.Type != obj.TYPE_REG {
-               panic(fmt.Sprintf("ill typed: %+v", a))
-       }
-       return regVal(uint32(a.Reg), min, max)
-}
-
-// regIAddr extracts the integer register from an Addr.
-func regIAddr(a obj.Addr) uint32 {
-       return regAddr(a, REG_X0, REG_X31)
-}
-
-// regFAddr extracts the float register from an Addr.
-func regFAddr(a obj.Addr) uint32 {
-       return regAddr(a, REG_F0, REG_F31)
-}
-
 // immEven checks that the immediate is a multiple of two. If it
 // is not, an error is returned.
 func immEven(x int64) error {
index 957222a1559388540db306c37a4ca04e51bfe90f..97de5a4a0896d53c5861412c91542d9aaa728fd8 100644 (file)
@@ -2677,20 +2677,6 @@ func (c *ctxtz) addrilreloc(sym *obj.LSym, add int64) {
        })
 }
 
-func (c *ctxtz) addrilrelocoffset(sym *obj.LSym, add, offset int64) {
-       if sym == nil {
-               c.ctxt.Diag("require symbol to apply relocation")
-       }
-       offset += int64(2) // relocation offset from start of instruction
-       c.cursym.AddRel(c.ctxt, obj.Reloc{
-               Type: objabi.R_PCRELDBL,
-               Off:  int32(c.pc + offset),
-               Siz:  4,
-               Sym:  sym,
-               Add:  add + offset + 4,
-       })
-}
-
 // Add a CALL relocation for the immediate in a RIL style instruction.
 // The addend will be adjusted as required.
 func (c *ctxtz) addcallreloc(sym *obj.LSym, add int64) {
@@ -4745,16 +4731,6 @@ func zI(op, i1 uint32, asm *[]byte) {
        *asm = append(*asm, uint8(op>>8), uint8(i1))
 }
 
-func zMII(op, m1, ri2, ri3 uint32, asm *[]byte) {
-       *asm = append(*asm,
-               uint8(op>>8),
-               (uint8(m1)<<4)|uint8((ri2>>8)&0x0F),
-               uint8(ri2),
-               uint8(ri3>>16),
-               uint8(ri3>>8),
-               uint8(ri3))
-}
-
 func zRI(op, r1_m1, i2_ri2 uint32, asm *[]byte) {
        *asm = append(*asm,
                uint8(op>>8),
@@ -4807,16 +4783,6 @@ func zRIL(f form, op, r1_m1, i2_ri2 uint32, asm *[]byte) {
                uint8(i2_ri2))
 }
 
-func zRIS(op, r1, m3, b4, d4, i2 uint32, asm *[]byte) {
-       *asm = append(*asm,
-               uint8(op>>8),
-               (uint8(r1)<<4)|uint8(m3&0x0F),
-               (uint8(b4)<<4)|(uint8(d4>>8)&0x0F),
-               uint8(d4),
-               uint8(i2),
-               uint8(op))
-}
-
 func zRR(op, r1, r2 uint32, asm *[]byte) {
        *asm = append(*asm, uint8(op>>8), (uint8(r1)<<4)|uint8(r2&0x0F))
 }
@@ -4845,16 +4811,6 @@ func zRRF(op, r3_m3, m4, r1, r2 uint32, asm *[]byte) {
                (uint8(r1)<<4)|uint8(r2&0x0F))
 }
 
-func zRRS(op, r1, r2, b4, d4, m3 uint32, asm *[]byte) {
-       *asm = append(*asm,
-               uint8(op>>8),
-               (uint8(r1)<<4)|uint8(r2&0x0F),
-               (uint8(b4)<<4)|uint8((d4>>8)&0x0F),
-               uint8(d4),
-               uint8(m3)<<4,
-               uint8(op))
-}
-
 func zRS(op, r1, r3_m3, b2, d2 uint32, asm *[]byte) {
        *asm = append(*asm,
                uint8(op>>8),
@@ -4863,23 +4819,6 @@ func zRS(op, r1, r3_m3, b2, d2 uint32, asm *[]byte) {
                uint8(d2))
 }
 
-func zRSI(op, r1, r3, ri2 uint32, asm *[]byte) {
-       *asm = append(*asm,
-               uint8(op>>8),
-               (uint8(r1)<<4)|uint8(r3&0x0F),
-               uint8(ri2>>8),
-               uint8(ri2))
-}
-
-func zRSL(op, l1, b2, d2 uint32, asm *[]byte) {
-       *asm = append(*asm,
-               uint8(op>>8),
-               uint8(l1),
-               (uint8(b2)<<4)|uint8((d2>>8)&0x0F),
-               uint8(d2),
-               uint8(op))
-}
-
 func zRSY(op, r1, r3_m3, b2, d2 uint32, asm *[]byte) {
        dl2 := uint16(d2) & 0x0FFF
        *asm = append(*asm,
@@ -4909,16 +4848,6 @@ func zRXE(op, r1, x2, b2, d2, m3 uint32, asm *[]byte) {
                uint8(op))
 }
 
-func zRXF(op, r3, x2, b2, d2, m1 uint32, asm *[]byte) {
-       *asm = append(*asm,
-               uint8(op>>8),
-               (uint8(r3)<<4)|uint8(x2&0x0F),
-               (uint8(b2)<<4)|uint8((d2>>8)&0x0F),
-               uint8(d2),
-               uint8(m1)<<4,
-               uint8(op))
-}
-
 func zRXY(op, r1_m1, x2, b2, d2 uint32, asm *[]byte) {
        dl2 := uint16(d2) & 0x0FFF
        *asm = append(*asm,
@@ -4967,16 +4896,6 @@ func zSIY(op, i2, b1, d1 uint32, asm *[]byte) {
                uint8(op))
 }
 
-func zSMI(op, m1, b3, d3, ri2 uint32, asm *[]byte) {
-       *asm = append(*asm,
-               uint8(op>>8),
-               uint8(m1)<<4,
-               (uint8(b3)<<4)|uint8((d3>>8)&0x0F),
-               uint8(d3),
-               uint8(ri2>>8),
-               uint8(ri2))
-}
-
 // Expected argument values for the instruction formats.
 //
 // Format    a1  a2  a3  a4  a5  a6
@@ -5006,26 +4925,6 @@ func zSS(f form, op, l1_r1, l2_i3_r3, b1_b2, d1_d2, b2_b4, d2_d4 uint32, asm *[]
                uint8(d2_d4))
 }
 
-func zSSE(op, b1, d1, b2, d2 uint32, asm *[]byte) {
-       *asm = append(*asm,
-               uint8(op>>8),
-               uint8(op),
-               (uint8(b1)<<4)|uint8((d1>>8)&0x0F),
-               uint8(d1),
-               (uint8(b2)<<4)|uint8((d2>>8)&0x0F),
-               uint8(d2))
-}
-
-func zSSF(op, r3, b1, d1, b2, d2 uint32, asm *[]byte) {
-       *asm = append(*asm,
-               uint8(op>>8),
-               (uint8(r3)<<4)|(uint8(op)&0x0F),
-               (uint8(b1)<<4)|uint8((d1>>8)&0x0F),
-               uint8(d1),
-               (uint8(b2)<<4)|uint8((d2>>8)&0x0F),
-               uint8(d2))
-}
-
 func rxb(va, vb, vc, vd uint32) uint8 {
        mask := uint8(0)
        if va >= REG_V16 && va <= REG_V31 {
index 3332134141776436d0bbf7da92eeba24306053e9..0906f16eaae7507c714e6466d2a82b7df3529af8 100644 (file)
@@ -2037,23 +2037,6 @@ type nopPad struct {
        n int32     // Size of the pad
 }
 
-// requireAlignment ensures that the function alignment is at
-// least as high as a, which should be a power of two
-// and between 8 and 2048, inclusive.
-//
-// the boolean result indicates whether the alignment meets those constraints
-func requireAlignment(a int64, ctxt *obj.Link, cursym *obj.LSym) bool {
-       if !((a&(a-1) == 0) && 8 <= a && a <= 2048) {
-               ctxt.Diag("alignment value of an instruction must be a power of two and in the range [8, 2048], got %d\n", a)
-               return false
-       }
-       // By default function alignment is 32 bytes for amd64
-       if cursym.Func().Align < int32(a) {
-               cursym.Func().Align = int32(a)
-       }
-       return true
-}
-
 func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
        if ctxt.Retpoline && ctxt.Arch.Family == sys.I386 {
                ctxt.Diag("-spectre=ret not supported on 386")
index 7f308686c113eb466e13cf746fc2f5ed8879c5b6..48287546b387696e7ef43450539e6600df4f52e4 100644 (file)
@@ -852,11 +852,6 @@ func isZeroArgRuntimeCall(s *obj.LSym) bool {
        return false
 }
 
-func indir_cx(ctxt *obj.Link, a *obj.Addr) {
-       a.Type = obj.TYPE_MEM
-       a.Reg = REG_CX
-}
-
 // loadG ensures the G is loaded into a register (either CX or REGG),
 // appending instructions to p if necessary. It returns the new last
 // instruction and the G register.
index 15b33773cf5f5b065a3b1931d3d8ea7f5446f680..73f88dcdd040afdc1745a518b21e8b6829c91570 100644 (file)
@@ -37,17 +37,3 @@ func ReadFile(filename string) ([]byte, error) {
 func RemoveAll(path string) error {
        return removeAll(path)
 }
-
-// IsEphemeralError reports whether err is one of the errors that the functions
-// in this package attempt to mitigate.
-//
-// Errors considered ephemeral include:
-//   - syscall.ERROR_ACCESS_DENIED
-//   - syscall.ERROR_FILE_NOT_FOUND
-//   - internal/syscall/windows.ERROR_SHARING_VIOLATION
-//
-// This set may be expanded in the future; programs must not rely on the
-// non-ephemerality of any given error.
-func IsEphemeralError(err error) bool {
-       return isEphemeralError(err)
-}
index ba821712e5ec69bc35ba85183d982b8365529921..eb9344f6e2a1eb1cc2cee89cd0e46eb970df2529 100644 (file)
@@ -72,14 +72,6 @@ type Engine struct {
        Quiet bool
 }
 
-// NewEngine returns an Engine configured with a basic set of commands and conditions.
-func NewEngine() *Engine {
-       return &Engine{
-               Cmds:  DefaultCmds(),
-               Conds: DefaultConds(),
-       }
-}
-
 // A Cmd is a command that is available to a script.
 type Cmd interface {
        // Run begins running the command.
index 7754cf9bfa58bb99cac3e2357e2380e56d63b8bf..b8127a2538ea18382aaa7aba6f3000a81db31d80 100644 (file)
@@ -40,10 +40,6 @@ import (
        "log"
 )
 
-func PADDR(x uint32) uint32 {
-       return x &^ 0x80000000
-}
-
 func gentext(ctxt *ld.Link, ldr *loader.Loader) {
        initfunc, addmoduledata := ld.PrepareAddmoduledata(ctxt)
        if initfunc == nil {
index 8c9fa8efab5a1eaadf6fbd4758633106afee16ee..949ea5590589ae4f94ee4bd4e0fa76a9b0be2b91 100644 (file)
@@ -244,35 +244,6 @@ func decodetypeGcmask(ctxt *Link, s loader.Sym) []byte {
        return ctxt.loader.Data(mask)
 }
 
-// Type.commonType.gc
-func decodetypeGcprog(ctxt *Link, s loader.Sym) []byte {
-       if ctxt.loader.SymType(s) == sym.SDYNIMPORT {
-               symData := ctxt.loader.Data(s)
-               addr := decodetypeGcprogShlib(ctxt, symData)
-               sect := findShlibSection(ctxt, ctxt.loader.SymPkg(s), addr)
-               if sect != nil {
-                       // A gcprog is a 4-byte uint32 indicating length, followed by
-                       // the actual program.
-                       progsize := make([]byte, 4)
-                       _, err := sect.ReadAt(progsize, int64(addr-sect.Addr))
-                       if err != nil {
-                               log.Fatal(err)
-                       }
-                       progbytes := make([]byte, ctxt.Arch.ByteOrder.Uint32(progsize))
-                       _, err = sect.ReadAt(progbytes, int64(addr-sect.Addr+4))
-                       if err != nil {
-                               log.Fatal(err)
-                       }
-                       return append(progsize, progbytes...)
-               }
-               Exitf("cannot find gcprog for %s", ctxt.loader.SymName(s))
-               return nil
-       }
-       relocs := ctxt.loader.Relocs(s)
-       rs := decodeRelocSym(ctxt.loader, s, &relocs, 2*int32(ctxt.Arch.PtrSize)+8+1*int32(ctxt.Arch.PtrSize))
-       return ctxt.loader.Data(rs)
-}
-
 // Find the elf.Section of a given shared library that contains a given address.
 func findShlibSection(ctxt *Link, path string, addr uint64) *elf.Section {
        for _, shlib := range ctxt.Shlibs {
index da83e81ab9327e36a20149c5862f373e67ada5d3..f8abcec2cb7df1796cbbe75ffefcec4a9a19ddf0 100644 (file)
@@ -9,7 +9,6 @@ import (
        "internal/trace"
        "internal/trace/traceviewer"
        "slices"
-       "time"
 )
 
 // viewerFrames returns the frames of the stack of ev. The given frame slice is
@@ -40,7 +39,3 @@ func viewerGState(state trace.GoState, inMarkAssist bool) traceviewer.GState {
                panic(fmt.Sprintf("unknown GoState: %s", state.String()))
        }
 }
-
-func viewerTime(t time.Duration) float64 {
-       return float64(t) / float64(time.Microsecond)
-}