aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal
diff options
context:
space:
mode:
authorqiulaidongfeng <2645477756@qq.com>2025-07-26 16:46:22 +0800
committerAlan Donovan <adonovan@google.com>2025-08-05 10:31:25 -0700
commit4ee0df8c466861bcd258ec55b58283f276d3b3d5 (patch)
tree9f8b467a6eff9720f5033477d21777e373848d2e /src/cmd/internal
parenta2c45f0eb1f281ed39c5111dd0fe4b2728f11cf3 (diff)
downloadgo-4ee0df8c466861bcd258ec55b58283f276d3b3d5.tar.xz
cmd: remove dead code
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>
Diffstat (limited to 'src/cmd/internal')
-rw-r--r--src/cmd/internal/archive/archive.go14
-rw-r--r--src/cmd/internal/gcprog/gcprog.go49
-rw-r--r--src/cmd/internal/goobj/objfile.go18
-rw-r--r--src/cmd/internal/obj/arm64/asm7.go13
-rw-r--r--src/cmd/internal/obj/loong64/asm.go4
-rw-r--r--src/cmd/internal/obj/loong64/obj.go8
-rw-r--r--src/cmd/internal/obj/ppc64/asm9.go4
-rw-r--r--src/cmd/internal/obj/riscv/obj.go18
-rw-r--r--src/cmd/internal/obj/s390x/asmz.go101
-rw-r--r--src/cmd/internal/obj/x86/asm6.go17
-rw-r--r--src/cmd/internal/obj/x86/obj6.go5
-rw-r--r--src/cmd/internal/robustio/robustio.go14
-rw-r--r--src/cmd/internal/script/engine.go8
13 files changed, 0 insertions, 273 deletions
diff --git a/src/cmd/internal/archive/archive.go b/src/cmd/internal/archive/archive.go
index 393034d776..b8abc0d4f6 100644
--- a/src/cmd/internal/archive/archive.go
+++ b/src/cmd/internal/archive/archive.go
@@ -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))
}
diff --git a/src/cmd/internal/gcprog/gcprog.go b/src/cmd/internal/gcprog/gcprog.go
index eeea53daf4..52505f3b20 100644
--- a/src/cmd/internal/gcprog/gcprog.go
+++ b/src/cmd/internal/gcprog/gcprog.go
@@ -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
diff --git a/src/cmd/internal/goobj/objfile.go b/src/cmd/internal/goobj/objfile.go
index a9342427ef..38da67076d 100644
--- a/src/cmd/internal/goobj/objfile.go
+++ b/src/cmd/internal/goobj/objfile.go
@@ -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 {
diff --git a/src/cmd/internal/obj/arm64/asm7.go b/src/cmd/internal/obj/arm64/asm7.go
index 344b73e658..0c9c70aa89 100644
--- a/src/cmd/internal/obj/arm64/asm7.go
+++ b/src/cmd/internal/obj/arm64/asm7.go
@@ -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 {
diff --git a/src/cmd/internal/obj/loong64/asm.go b/src/cmd/internal/obj/loong64/asm.go
index 2ed12698e6..0d1b202e80 100644
--- a/src/cmd/internal/obj/loong64/asm.go
+++ b/src/cmd/internal/obj/loong64/asm.go
@@ -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:
diff --git a/src/cmd/internal/obj/loong64/obj.go b/src/cmd/internal/obj/loong64/obj.go
index 79fbb23fef..a1eb786da3 100644
--- a/src/cmd/internal/obj/loong64/obj.go
+++ b/src/cmd/internal/obj/loong64/obj.go
@@ -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,
diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go
index 9cba8c33ce..dcd3aa59a4 100644
--- a/src/cmd/internal/obj/ppc64/asm9.go
+++ b/src/cmd/internal/obj/ppc64/asm9.go
@@ -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
diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go
index 078e81a2f7..44edb8d841 100644
--- a/src/cmd/internal/obj/riscv/obj.go
+++ b/src/cmd/internal/obj/riscv/obj.go
@@ -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 {
diff --git a/src/cmd/internal/obj/s390x/asmz.go b/src/cmd/internal/obj/s390x/asmz.go
index 957222a155..97de5a4a08 100644
--- a/src/cmd/internal/obj/s390x/asmz.go
+++ b/src/cmd/internal/obj/s390x/asmz.go
@@ -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 {
diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go
index 3332134141..0906f16eaa 100644
--- a/src/cmd/internal/obj/x86/asm6.go
+++ b/src/cmd/internal/obj/x86/asm6.go
@@ -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")
diff --git a/src/cmd/internal/obj/x86/obj6.go b/src/cmd/internal/obj/x86/obj6.go
index 7f308686c1..48287546b3 100644
--- a/src/cmd/internal/obj/x86/obj6.go
+++ b/src/cmd/internal/obj/x86/obj6.go
@@ -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.
diff --git a/src/cmd/internal/robustio/robustio.go b/src/cmd/internal/robustio/robustio.go
index 15b33773cf..73f88dcdd0 100644
--- a/src/cmd/internal/robustio/robustio.go
+++ b/src/cmd/internal/robustio/robustio.go
@@ -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)
-}
diff --git a/src/cmd/internal/script/engine.go b/src/cmd/internal/script/engine.go
index ba821712e5..eb9344f6e2 100644
--- a/src/cmd/internal/script/engine.go
+++ b/src/cmd/internal/script/engine.go
@@ -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.