From f84a1db19f43df68494f30a67d69e5d4d807b970 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Fri, 15 Sep 2017 11:38:24 -0700 Subject: [PATCH] cmd/link: replace unrolled Cput loops with Cwrite/Cwritestring Passes toolstash-check -all. Change-Id: I1c85a2c0390517f4e9cdbddddbf3c353edca65b3 Reviewed-on: https://go-review.googlesource.com/64051 Run-TryBot: Matthew Dempsky Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/cmd/link/internal/amd64/asm.go | 5 +---- src/cmd/link/internal/arm/asm.go | 5 +---- src/cmd/link/internal/arm64/asm.go | 5 +---- src/cmd/link/internal/ld/elf.go | 8 ++------ src/cmd/link/internal/ld/symtab.go | 7 ++----- src/cmd/link/internal/mips64/asm.go | 5 +---- src/cmd/link/internal/ppc64/asm.go | 5 +---- src/cmd/link/internal/x86/asm.go | 5 +---- 8 files changed, 10 insertions(+), 35 deletions(-) diff --git a/src/cmd/link/internal/amd64/asm.go b/src/cmd/link/internal/amd64/asm.go index 20ef5956a98..0660a6d3bfc 100644 --- a/src/cmd/link/internal/amd64/asm.go +++ b/src/cmd/link/internal/amd64/asm.go @@ -781,10 +781,7 @@ func asmb(ctxt *ld.Link) { sym := ctxt.Syms.Lookup("pclntab", 0) if sym != nil { ld.Lcsize = int32(len(sym.P)) - for i := 0; int32(i) < ld.Lcsize; i++ { - ld.Cput(sym.P[i]) - } - + ld.Cwrite(sym.P) ld.Cflush() } diff --git a/src/cmd/link/internal/arm/asm.go b/src/cmd/link/internal/arm/asm.go index c27672da7d2..2c959b0e96e 100644 --- a/src/cmd/link/internal/arm/asm.go +++ b/src/cmd/link/internal/arm/asm.go @@ -829,10 +829,7 @@ func asmb(ctxt *ld.Link) { sym := ctxt.Syms.Lookup("pclntab", 0) if sym != nil { ld.Lcsize = int32(len(sym.P)) - for i := 0; int32(i) < ld.Lcsize; i++ { - ld.Cput(sym.P[i]) - } - + ld.Cwrite(sym.P) ld.Cflush() } diff --git a/src/cmd/link/internal/arm64/asm.go b/src/cmd/link/internal/arm64/asm.go index bb0bf267f03..5955f2cd6ba 100644 --- a/src/cmd/link/internal/arm64/asm.go +++ b/src/cmd/link/internal/arm64/asm.go @@ -465,10 +465,7 @@ func asmb(ctxt *ld.Link) { sym := ctxt.Syms.Lookup("pclntab", 0) if sym != nil { ld.Lcsize = int32(len(sym.P)) - for i := 0; int32(i) < ld.Lcsize; i++ { - ld.Cput(sym.P[i]) - } - + ld.Cwrite(sym.P) ld.Cflush() } diff --git a/src/cmd/link/internal/ld/elf.go b/src/cmd/link/internal/ld/elf.go index cd364f05765..0edf76ec5a8 100644 --- a/src/cmd/link/internal/ld/elf.go +++ b/src/cmd/link/internal/ld/elf.go @@ -1120,9 +1120,7 @@ func getElfEhdr() *ElfEhdr { } func elf64writehdr() uint32 { - for i := 0; i < EI_NIDENT; i++ { - Cput(ehdr.ident[i]) - } + Cwrite(ehdr.ident[:]) Thearch.Wput(ehdr.type_) Thearch.Wput(ehdr.machine) Thearch.Lput(ehdr.version) @@ -1140,9 +1138,7 @@ func elf64writehdr() uint32 { } func elf32writehdr() uint32 { - for i := 0; i < EI_NIDENT; i++ { - Cput(ehdr.ident[i]) - } + Cwrite(ehdr.ident[:]) Thearch.Wput(ehdr.type_) Thearch.Wput(ehdr.machine) Thearch.Lput(ehdr.version) diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index ca97cb23cf8..9812fe60531 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -233,13 +233,10 @@ func putplan9sym(ctxt *Link, x *Symbol, s string, typ SymbolType, addr int64, go Lputb(uint32(addr)) Cput(uint8(t + 0x80)) /* 0x80 is variable length */ - var i int - for i = 0; i < len(s); i++ { - Cput(s[i]) - } + Cwritestring(s) Cput(0) - Symsize += int32(l) + 1 + int32(i) + 1 + Symsize += int32(l) + 1 + int32(len(s)) + 1 default: return diff --git a/src/cmd/link/internal/mips64/asm.go b/src/cmd/link/internal/mips64/asm.go index d1baef612fa..c3100331e80 100644 --- a/src/cmd/link/internal/mips64/asm.go +++ b/src/cmd/link/internal/mips64/asm.go @@ -258,10 +258,7 @@ func asmb(ctxt *ld.Link) { sym := ctxt.Syms.Lookup("pclntab", 0) if sym != nil { ld.Lcsize = int32(len(sym.P)) - for i := 0; int32(i) < ld.Lcsize; i++ { - ld.Cput(sym.P[i]) - } - + ld.Cwrite(sym.P) ld.Cflush() } } diff --git a/src/cmd/link/internal/ppc64/asm.go b/src/cmd/link/internal/ppc64/asm.go index 2f0947aff8d..4bec2172df0 100644 --- a/src/cmd/link/internal/ppc64/asm.go +++ b/src/cmd/link/internal/ppc64/asm.go @@ -987,10 +987,7 @@ func asmb(ctxt *ld.Link) { sym := ctxt.Syms.Lookup("pclntab", 0) if sym != nil { ld.Lcsize = int32(len(sym.P)) - for i := 0; int32(i) < ld.Lcsize; i++ { - ld.Cput(sym.P[i]) - } - + ld.Cwrite(sym.P) ld.Cflush() } } diff --git a/src/cmd/link/internal/x86/asm.go b/src/cmd/link/internal/x86/asm.go index 069ee4702e8..bfdee795a4a 100644 --- a/src/cmd/link/internal/x86/asm.go +++ b/src/cmd/link/internal/x86/asm.go @@ -709,10 +709,7 @@ func asmb(ctxt *ld.Link) { sym := ctxt.Syms.Lookup("pclntab", 0) if sym != nil { ld.Lcsize = int32(len(sym.P)) - for i := 0; int32(i) < ld.Lcsize; i++ { - ld.Cput(sym.P[i]) - } - + ld.Cwrite(sym.P) ld.Cflush() }