Skip to content

Commit c3e8a20

Browse files
nikita-vanyasinjosharian
authored andcommitted
cmd/link/internal: eliminate all ld.Cputime() usages
Also a similar 'elapsed' function and its usages were deleted. Fixes #19865. Change-Id: Ib125365e69cf2eda60de64fa74290c8c7d1fd65a Reviewed-on: https://go-review.googlesource.com/c/go/+/171730 Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]> Reviewed-by: Than McIntosh <[email protected]>
1 parent 65a1e24 commit c3e8a20

File tree

17 files changed

+12
-259
lines changed

17 files changed

+12
-259
lines changed

src/cmd/link/internal/amd64/asm.go

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -659,14 +659,6 @@ func addgotsym(ctxt *ld.Link, s *sym.Symbol) {
659659
}
660660

661661
func asmb(ctxt *ld.Link) {
662-
if ctxt.Debugvlog != 0 {
663-
ctxt.Logf("%5.2f asmb\n", ld.Cputime())
664-
}
665-
666-
if ctxt.Debugvlog != 0 {
667-
ctxt.Logf("%5.2f codeblk\n", ld.Cputime())
668-
}
669-
670662
if ctxt.IsELF {
671663
ld.Asmbelfsetup()
672664
}
@@ -681,24 +673,14 @@ func asmb(ctxt *ld.Link) {
681673
}
682674

683675
if ld.Segrodata.Filelen > 0 {
684-
if ctxt.Debugvlog != 0 {
685-
ctxt.Logf("%5.2f rodatblk\n", ld.Cputime())
686-
}
687676
ctxt.Out.SeekSet(int64(ld.Segrodata.Fileoff))
688677
ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
689678
}
690679
if ld.Segrelrodata.Filelen > 0 {
691-
if ctxt.Debugvlog != 0 {
692-
ctxt.Logf("%5.2f relrodatblk\n", ld.Cputime())
693-
}
694680
ctxt.Out.SeekSet(int64(ld.Segrelrodata.Fileoff))
695681
ld.Datblk(ctxt, int64(ld.Segrelrodata.Vaddr), int64(ld.Segrelrodata.Filelen))
696682
}
697683

698-
if ctxt.Debugvlog != 0 {
699-
ctxt.Logf("%5.2f datblk\n", ld.Cputime())
700-
}
701-
702684
ctxt.Out.SeekSet(int64(ld.Segdata.Fileoff))
703685
ld.Datblk(ctxt, int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
704686

@@ -740,9 +722,6 @@ func asmb2(ctxt *ld.Link) {
740722
ld.Lcsize = 0
741723
symo := int64(0)
742724
if !*ld.FlagS {
743-
if ctxt.Debugvlog != 0 {
744-
ctxt.Logf("%5.2f sym\n", ld.Cputime())
745-
}
746725
switch ctxt.HeadType {
747726
default:
748727
case objabi.Hplan9:
@@ -775,10 +754,6 @@ func asmb2(ctxt *ld.Link) {
775754
ctxt.Out.Flush()
776755
ctxt.Out.Write(ld.Elfstrdat)
777756

778-
if ctxt.Debugvlog != 0 {
779-
ctxt.Logf("%5.2f dwarf\n", ld.Cputime())
780-
}
781-
782757
if ctxt.LinkMode == ld.LinkExternal {
783758
ld.Elfemitreloc(ctxt)
784759
}
@@ -796,9 +771,7 @@ func asmb2(ctxt *ld.Link) {
796771
}
797772

798773
case objabi.Hwindows:
799-
if ctxt.Debugvlog != 0 {
800-
ctxt.Logf("%5.2f dwarf\n", ld.Cputime())
801-
}
774+
// Do nothing
802775

803776
case objabi.Hdarwin:
804777
if ctxt.LinkMode == ld.LinkExternal {
@@ -807,9 +780,6 @@ func asmb2(ctxt *ld.Link) {
807780
}
808781
}
809782

810-
if ctxt.Debugvlog != 0 {
811-
ctxt.Logf("%5.2f headr\n", ld.Cputime())
812-
}
813783
ctxt.Out.SeekSet(0)
814784
switch ctxt.HeadType {
815785
default:

src/cmd/link/internal/arm/asm.go

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,6 @@ func addgotsym(ctxt *ld.Link, s *sym.Symbol) {
760760
}
761761

762762
func asmb(ctxt *ld.Link) {
763-
if ctxt.Debugvlog != 0 {
764-
ctxt.Logf("%5.2f asmb\n", ld.Cputime())
765-
}
766-
767763
if ctxt.IsELF {
768764
ld.Asmbelfsetup()
769765
}
@@ -777,24 +773,14 @@ func asmb(ctxt *ld.Link) {
777773
}
778774

779775
if ld.Segrodata.Filelen > 0 {
780-
if ctxt.Debugvlog != 0 {
781-
ctxt.Logf("%5.2f rodatblk\n", ld.Cputime())
782-
}
783776
ctxt.Out.SeekSet(int64(ld.Segrodata.Fileoff))
784777
ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
785778
}
786779
if ld.Segrelrodata.Filelen > 0 {
787-
if ctxt.Debugvlog != 0 {
788-
ctxt.Logf("%5.2f relrodatblk\n", ld.Cputime())
789-
}
790780
ctxt.Out.SeekSet(int64(ld.Segrelrodata.Fileoff))
791781
ld.Datblk(ctxt, int64(ld.Segrelrodata.Vaddr), int64(ld.Segrelrodata.Filelen))
792782
}
793783

794-
if ctxt.Debugvlog != 0 {
795-
ctxt.Logf("%5.2f datblk\n", ld.Cputime())
796-
}
797-
798784
ctxt.Out.SeekSet(int64(ld.Segdata.Fileoff))
799785
ld.Datblk(ctxt, int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
800786

@@ -815,9 +801,6 @@ func asmb2(ctxt *ld.Link) {
815801
symo := uint32(0)
816802
if !*ld.FlagS {
817803
// TODO: rationalize
818-
if ctxt.Debugvlog != 0 {
819-
ctxt.Logf("%5.2f sym\n", ld.Cputime())
820-
}
821804
switch ctxt.HeadType {
822805
default:
823806
if ctxt.IsELF {
@@ -840,9 +823,6 @@ func asmb2(ctxt *ld.Link) {
840823
switch ctxt.HeadType {
841824
default:
842825
if ctxt.IsELF {
843-
if ctxt.Debugvlog != 0 {
844-
ctxt.Logf("%5.2f elfsym\n", ld.Cputime())
845-
}
846826
ld.Asmelfsym(ctxt)
847827
ctxt.Out.Flush()
848828
ctxt.Out.Write(ld.Elfstrdat)
@@ -864,9 +844,7 @@ func asmb2(ctxt *ld.Link) {
864844
}
865845

866846
case objabi.Hwindows:
867-
if ctxt.Debugvlog != 0 {
868-
ctxt.Logf("%5.2f dwarf\n", ld.Cputime())
869-
}
847+
// Do nothing
870848

871849
case objabi.Hdarwin:
872850
if ctxt.LinkMode == ld.LinkExternal {
@@ -875,9 +853,6 @@ func asmb2(ctxt *ld.Link) {
875853
}
876854
}
877855

878-
if ctxt.Debugvlog != 0 {
879-
ctxt.Logf("%5.2f header\n", ld.Cputime())
880-
}
881856
ctxt.Out.SeekSet(0)
882857
switch ctxt.HeadType {
883858
default:

src/cmd/link/internal/arm64/asm.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,6 @@ func addgotsym(ctxt *ld.Link, s *sym.Symbol) {
803803
}
804804

805805
func asmb(ctxt *ld.Link) {
806-
if ctxt.Debugvlog != 0 {
807-
ctxt.Logf("%5.2f asmb\n", ld.Cputime())
808-
}
809-
810806
if ctxt.IsELF {
811807
ld.Asmbelfsetup()
812808
}
@@ -820,24 +816,14 @@ func asmb(ctxt *ld.Link) {
820816
}
821817

822818
if ld.Segrodata.Filelen > 0 {
823-
if ctxt.Debugvlog != 0 {
824-
ctxt.Logf("%5.2f rodatblk\n", ld.Cputime())
825-
}
826819
ctxt.Out.SeekSet(int64(ld.Segrodata.Fileoff))
827820
ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
828821
}
829822
if ld.Segrelrodata.Filelen > 0 {
830-
if ctxt.Debugvlog != 0 {
831-
ctxt.Logf("%5.2f relrodatblk\n", ld.Cputime())
832-
}
833823
ctxt.Out.SeekSet(int64(ld.Segrelrodata.Fileoff))
834824
ld.Datblk(ctxt, int64(ld.Segrelrodata.Vaddr), int64(ld.Segrelrodata.Filelen))
835825
}
836826

837-
if ctxt.Debugvlog != 0 {
838-
ctxt.Logf("%5.2f datblk\n", ld.Cputime())
839-
}
840-
841827
ctxt.Out.SeekSet(int64(ld.Segdata.Fileoff))
842828
ld.Datblk(ctxt, int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
843829

@@ -858,9 +844,6 @@ func asmb2(ctxt *ld.Link) {
858844
symo := uint32(0)
859845
if !*ld.FlagS {
860846
// TODO: rationalize
861-
if ctxt.Debugvlog != 0 {
862-
ctxt.Logf("%5.2f sym\n", ld.Cputime())
863-
}
864847
switch ctxt.HeadType {
865848
default:
866849
if ctxt.IsELF {
@@ -879,9 +862,6 @@ func asmb2(ctxt *ld.Link) {
879862
switch ctxt.HeadType {
880863
default:
881864
if ctxt.IsELF {
882-
if ctxt.Debugvlog != 0 {
883-
ctxt.Logf("%5.2f elfsym\n", ld.Cputime())
884-
}
885865
ld.Asmelfsym(ctxt)
886866
ctxt.Out.Flush()
887867
ctxt.Out.Write(ld.Elfstrdat)
@@ -909,9 +889,6 @@ func asmb2(ctxt *ld.Link) {
909889
}
910890
}
911891

912-
if ctxt.Debugvlog != 0 {
913-
ctxt.Logf("%5.2f header\n", ld.Cputime())
914-
}
915892
ctxt.Out.SeekSet(0)
916893
switch ctxt.HeadType {
917894
default:

src/cmd/link/internal/ld/data.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,6 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
559559
}
560560

561561
func (ctxt *Link) reloc() {
562-
if ctxt.Debugvlog != 0 {
563-
ctxt.Logf("%5.2f reloc\n", Cputime())
564-
}
565-
566562
for _, s := range ctxt.Textp {
567563
relocsym(ctxt, s)
568564
}
@@ -623,9 +619,6 @@ func (ctxt *Link) windynrelocsyms() {
623619
if !(ctxt.HeadType == objabi.Hwindows && iscgo && ctxt.LinkMode == LinkInternal) {
624620
return
625621
}
626-
if ctxt.Debugvlog != 0 {
627-
ctxt.Logf("%5.2f windynrelocsyms\n", Cputime())
628-
}
629622

630623
/* relocation table */
631624
rel := ctxt.Syms.Lookup(".rel", 0)
@@ -672,9 +665,6 @@ func dynreloc(ctxt *Link, data *[sym.SXREF][]*sym.Symbol) {
672665
if *FlagD {
673666
return
674667
}
675-
if ctxt.Debugvlog != 0 {
676-
ctxt.Logf("%5.2f dynreloc\n", Cputime())
677-
}
678668

679669
for _, s := range ctxt.Textp {
680670
dynrelocsym(ctxt, s)
@@ -1143,10 +1133,6 @@ func checkdatsize(ctxt *Link, datsize int64, symn sym.SymKind) {
11431133
var datap []*sym.Symbol
11441134

11451135
func (ctxt *Link) dodata() {
1146-
if ctxt.Debugvlog != 0 {
1147-
ctxt.Logf("%5.2f dodata\n", Cputime())
1148-
}
1149-
11501136
if (ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin) || (ctxt.HeadType == objabi.Haix && ctxt.LinkMode == LinkExternal) {
11511137
// The values in moduledata are filled out by relocations
11521138
// pointing to the addresses of these special symbols.

src/cmd/link/internal/ld/deadcode.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ import (
4646
//
4747
// Any unreached text symbols are removed from ctxt.Textp.
4848
func deadcode(ctxt *Link) {
49-
if ctxt.Debugvlog != 0 {
50-
ctxt.Logf("%5.2f deadcode\n", Cputime())
51-
}
52-
5349
d := &deadcodepass{
5450
ctxt: ctxt,
5551
ifaceMethod: make(map[methodsig]bool),

src/cmd/link/internal/ld/dwarf.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,10 +1798,6 @@ func dwarfGenerateDebugSyms(ctxt *Link) {
17981798
return
17991799
}
18001800

1801-
if ctxt.Debugvlog != 0 {
1802-
ctxt.Logf("%5.2f dwarf\n", Cputime())
1803-
}
1804-
18051801
abbrev := writeabbrev(ctxt)
18061802
syms := []*sym.Symbol{abbrev}
18071803

src/cmd/link/internal/ld/ld.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func addlib(ctxt *Link, src string, obj string, lib string) *sym.Library {
165165
pname, isshlib := findlib(ctxt, lib)
166166

167167
if ctxt.Debugvlog > 1 {
168-
ctxt.Logf("%5.2f addlib: %s %s pulls in %s isshlib %v\n", elapsed(), obj, src, pname, isshlib)
168+
ctxt.Logf("addlib: %s %s pulls in %s isshlib %v\n", obj, src, pname, isshlib)
169169
}
170170

171171
if isshlib {
@@ -188,7 +188,7 @@ func addlibpath(ctxt *Link, srcref string, objref string, file string, pkg strin
188188
}
189189

190190
if ctxt.Debugvlog > 1 {
191-
ctxt.Logf("%5.2f addlibpath: srcref: %s objref: %s file: %s pkg: %s shlib: %s\n", Cputime(), srcref, objref, file, pkg, shlib)
191+
ctxt.Logf("addlibpath: srcref: %s objref: %s file: %s pkg: %s shlib: %s\n", srcref, objref, file, pkg, shlib)
192192
}
193193

194194
l := &sym.Library{}

src/cmd/link/internal/ld/lib.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ func (ctxt *Link) loadlib() {
402402
lib := ctxt.Library[i]
403403
if lib.Shlib == "" {
404404
if ctxt.Debugvlog > 1 {
405-
ctxt.Logf("%5.2f autolib: %s (from %s)\n", Cputime(), lib.File, lib.Objref)
405+
ctxt.Logf("autolib: %s (from %s)\n", lib.File, lib.Objref)
406406
}
407407
loadobjfile(ctxt, lib)
408408
}
@@ -411,7 +411,7 @@ func (ctxt *Link) loadlib() {
411411
for _, lib := range ctxt.Library {
412412
if lib.Shlib != "" {
413413
if ctxt.Debugvlog > 1 {
414-
ctxt.Logf("%5.2f autolib: %s (from %s)\n", Cputime(), lib.Shlib, lib.Objref)
414+
ctxt.Logf("autolib: %s (from %s)\n", lib.Shlib, lib.Objref)
415415
}
416416
ldshlibsyms(ctxt, lib.Shlib)
417417
}
@@ -842,7 +842,7 @@ func loadobjfile(ctxt *Link, lib *sym.Library) {
842842
pkg := objabi.PathToPrefix(lib.Pkg)
843843

844844
if ctxt.Debugvlog > 1 {
845-
ctxt.Logf("%5.2f ldobj: %s (%s)\n", Cputime(), lib.File, pkg)
845+
ctxt.Logf("ldobj: %s (%s)\n", lib.File, pkg)
846846
}
847847
f, err := bio.Open(lib.File)
848848
if err != nil {
@@ -1439,7 +1439,7 @@ func (ctxt *Link) hostlink() {
14391439
}
14401440

14411441
if ctxt.Debugvlog != 0 {
1442-
ctxt.Logf("%5.2f host link:", Cputime())
1442+
ctxt.Logf("host link:")
14431443
for _, v := range argv {
14441444
ctxt.Logf(" %q", v)
14451445
}
@@ -1877,7 +1877,7 @@ func ldshlibsyms(ctxt *Link, shlib string) {
18771877
}
18781878
}
18791879
if ctxt.Debugvlog > 1 {
1880-
ctxt.Logf("%5.2f ldshlibsyms: found library with name %s at %s\n", Cputime(), shlib, libpath)
1880+
ctxt.Logf("ldshlibsyms: found library with name %s at %s\n", shlib, libpath)
18811881
}
18821882

18831883
f, err := elf.Open(libpath)
@@ -2387,7 +2387,7 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
23872387
}
23882388

23892389
if ctxt.Debugvlog != 0 || *flagN {
2390-
ctxt.Logf("%5.2f symsize = %d\n", Cputime(), uint32(Symsize))
2390+
ctxt.Logf("symsize = %d\n", uint32(Symsize))
23912391
}
23922392
}
23932393

src/cmd/link/internal/ld/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ func Main(arch *sys.Arch, theArch Arch) {
274274
ctxt.hostlink()
275275
ctxt.archive()
276276
if ctxt.Debugvlog != 0 {
277-
ctxt.Logf("%5.2f cpu time\n", Cputime())
278277
ctxt.Logf("%d symbols\n", len(ctxt.Syms.Allsym))
279278
ctxt.Logf("%d liveness data\n", liveness)
280279
}

src/cmd/link/internal/ld/pcln.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ func (ctxt *Link) pclntab() {
393393
ftab.Size = int64(len(ftab.P))
394394

395395
if ctxt.Debugvlog != 0 {
396-
ctxt.Logf("%5.2f pclntab=%d bytes, funcdata total %d bytes\n", Cputime(), ftab.Size, funcdataBytes)
396+
ctxt.Logf("pclntab=%d bytes, funcdata total %d bytes\n", ftab.Size, funcdataBytes)
397397
}
398398
}
399399

0 commit comments

Comments
 (0)