1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:40:04 -07:00

cmd/compile/internal/dwarfgen: remove unversion

The unified export data format doesn't rely on embedding version
numbers in local variable names anymore, so there's no need to look
for them.

While here, simplify the checking for "~r" or "~b" to just "~",
because the next commit is going to eliminate "~b", but introduce
"~p".

Change-Id: I3ac73150ee561c66356a0c4aee5290b44a4893ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/527695
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Matthew Dempsky 2023-09-12 03:17:23 -07:00
parent 4b17b36b3f
commit 661e3be497
2 changed files with 4 additions and 15 deletions

View File

@ -323,7 +323,7 @@ func preInliningDcls(fnsym *obj.LSym) []*ir.Name {
c := n.Sym().Name[0] c := n.Sym().Name[0]
// Avoid reporting "_" parameters, since if there are more than // Avoid reporting "_" parameters, since if there are more than
// one, it can result in a collision later on, as in #23179. // one, it can result in a collision later on, as in #23179.
if unversion(n.Sym().Name) == "_" || c == '.' || n.Type().IsUntyped() { if n.Sym().Name == "_" || c == '.' || n.Type().IsUntyped() {
continue continue
} }
rdcl = append(rdcl, n) rdcl = append(rdcl, n)

View File

@ -124,18 +124,16 @@ func assembleInlines(fnsym *obj.LSym, dwVars []*dwarf.Var) dwarf.InlCalls {
// caller. // caller.
synthCount := len(m) synthCount := len(m)
for _, v := range sl { for _, v := range sl {
canonName := unversion(v.Name)
vp := varPos{ vp := varPos{
DeclName: canonName, DeclName: v.Name,
DeclFile: v.DeclFile, DeclFile: v.DeclFile,
DeclLine: v.DeclLine, DeclLine: v.DeclLine,
DeclCol: v.DeclCol, DeclCol: v.DeclCol,
} }
synthesized := strings.HasPrefix(v.Name, "~r") || canonName == "_" || strings.HasPrefix(v.Name, "~b") synthesized := strings.HasPrefix(v.Name, "~") || v.Name == "_"
if idx, found := m[vp]; found { if idx, found := m[vp]; found {
v.ChildIndex = int32(idx) v.ChildIndex = int32(idx)
v.IsInAbstract = !synthesized v.IsInAbstract = !synthesized
v.Name = canonName
} else { } else {
// Variable can't be found in the pre-inline dcl list. // Variable can't be found in the pre-inline dcl list.
// In the top-level case (ii=0) this can happen // In the top-level case (ii=0) this can happen
@ -220,15 +218,6 @@ func AbstractFunc(fn *obj.LSym) {
base.Ctxt.DwarfAbstractFunc(ifn, fn) base.Ctxt.DwarfAbstractFunc(ifn, fn)
} }
// Undo any versioning performed when a name was written
// out as part of export data.
func unversion(name string) string {
if i := strings.Index(name, "·"); i > 0 {
name = name[:i]
}
return name
}
// Given a function that was inlined as part of the compilation, dig // Given a function that was inlined as part of the compilation, dig
// up the pre-inlining DCL list for the function and create a map that // up the pre-inlining DCL list for the function and create a map that
// supports lookup of pre-inline dcl index, based on variable // supports lookup of pre-inline dcl index, based on variable
@ -241,7 +230,7 @@ func makePreinlineDclMap(fnsym *obj.LSym) map[varPos]int {
for i, n := range dcl { for i, n := range dcl {
pos := base.Ctxt.InnermostPos(n.Pos()) pos := base.Ctxt.InnermostPos(n.Pos())
vp := varPos{ vp := varPos{
DeclName: unversion(n.Sym().Name), DeclName: n.Sym().Name,
DeclFile: pos.RelFilename(), DeclFile: pos.RelFilename(),
DeclLine: pos.RelLine(), DeclLine: pos.RelLine(),
DeclCol: pos.RelCol(), DeclCol: pos.RelCol(),