Commit f4d38a87 authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle

cmd/compile: de-dup the gclocals symbols in compiler too

These symbols are de-duplicated in the linker but the compiler generates quite
many duplicates too: 2425 of 13769 total symbols for runtime.a for example.
De-duplicating them in the compiler saves the linker a bit of work.

Fixes #14983

Change-Id: I5f18e5f9743563c795aad8f0a22d17a7ed147711
Reviewed-on: https://go-review.googlesource.com/22293Reviewed-by: 's avatarDavid Crawshaw <crawshaw@golang.org>
parent d3c79d32
......@@ -8,7 +8,6 @@ import (
"cmd/compile/internal/ssa"
"cmd/internal/obj"
"cmd/internal/sys"
"crypto/md5"
"fmt"
"sort"
"strings"
......@@ -130,15 +129,6 @@ func removevardef(firstp *obj.Prog) {
}
}
func gcsymdup(s *Sym) {
ls := Linksym(s)
if len(ls.R) > 0 {
Fatalf("cannot rosymdup %s with relocations", ls.Name)
}
ls.Name = fmt.Sprintf("gclocals·%x", md5.Sum(ls.P))
ls.Dupok = true
}
func emitptrargsmap() {
if Curfn.Func.Nname.Sym.Name == "_" {
return
......@@ -559,9 +549,6 @@ func genlegacy(ptxt *obj.Prog, gcargs, gclocals *Sym) {
// Emit garbage collection symbols.
liveness(Curfn, ptxt, gcargs, gclocals)
gcsymdup(gcargs)
gcsymdup(gclocals)
Thearch.Defframe(ptxt)
if Debug['f'] != 0 {
......
......@@ -18,6 +18,7 @@ package gc
import (
"cmd/internal/obj"
"cmd/internal/sys"
"crypto/md5"
"fmt"
"sort"
"strings"
......@@ -1689,7 +1690,17 @@ func onebitwritesymbol(arr []Bvec, sym *Sym) {
}
duint32(sym, 0, uint32(i)) // number of bitmaps
ggloblsym(sym, int32(off), obj.RODATA)
ls := Linksym(sym)
ls.Name = fmt.Sprintf("gclocals·%x", md5.Sum(ls.P))
ls.Dupok = true
sv := obj.SymVer{ls.Name, 0}
ls2, ok := Ctxt.Hash[sv]
if ok {
sym.Lsym = ls2
} else {
Ctxt.Hash[sv] = ls
ggloblsym(sym, int32(off), obj.RODATA)
}
}
func printprog(p *obj.Prog) {
......
......@@ -4005,8 +4005,6 @@ func genssa(f *ssa.Func, ptxt *obj.Prog, gcargs, gclocals *Sym) {
// Generate gc bitmaps.
liveness(Curfn, ptxt, gcargs, gclocals)
gcsymdup(gcargs)
gcsymdup(gclocals)
// Add frame prologue. Zero ambiguously live variables.
Thearch.Defframe(ptxt)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment