[dev.link] cmd/link: pass reloc by value to Adddynrel2

Adddynrel2 is a function pointer. In dynrelocsym we pass &r to
it, which will cause r to escape. Pass it by value instead.

Linking cmd/compile,

name           old alloc/op   new alloc/op   delta
Dodata_GC        15.8MB ± 0%     5.9MB ± 0%  -62.55%  (p=0.008 n=5+5)

Change-Id: Ib86005d1026ebaca57777b27ead037e613585f44
Reviewed-on: https://go-review.googlesource.com/c/go/+/231045
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Cherry Zhang 2020-04-30 01:32:48 -04:00
parent 5aa59c6a99
commit 516c29a79f
9 changed files with 15 additions and 15 deletions

View file

@ -233,7 +233,7 @@ type Arch struct {
Dragonflydynld string
Solarisdynld string
Adddynrel func(*Target, *loader.Loader, *ArchSyms, *sym.Symbol, *sym.Reloc) bool
Adddynrel2 func(*Target, *loader.Loader, *ArchSyms, loader.Sym, *loader.Reloc2, int) bool
Adddynrel2 func(*Target, *loader.Loader, *ArchSyms, loader.Sym, loader.Reloc2, int) bool
Archinit func(*Link)
// Archreloc is an arch-specific hook that assists in relocation processing
// (invoked by 'relocsym'); it handles target-specific relocation tasks.