mirror of https://github.com/golang/go.git
cmd/compile: remove var sorting from DWARF inline generation
When generation DWARF inline info records, the current implementation includes a sorting pass that reorders a subprogram's child variable DIEs based on class (param/auto) and name. This sorting is no longer needed, and can cause problems for a debugger (if we want to use the DWARF info for creating a call to an optimized function); this patch removes it. Ordering of DWARF subprogram variable/parameter DIEs is still deterministic with this change, since it is keyed off the order in which vars appear in the pre-inlining function "Dcl" list. Updates #27039 Change-Id: I3b91290d11bb3b9b36fb61271d80b801841401ee Reviewed-on: https://go-review.googlesource.com/131895 Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
225981f8e7
commit
7b88b22acf
|
|
@ -8,7 +8,6 @@ import (
|
|||
"cmd/internal/dwarf"
|
||||
"cmd/internal/obj"
|
||||
"cmd/internal/src"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -96,7 +95,6 @@ func assembleInlines(fnsym *obj.LSym, dwVars []*dwarf.Var) dwarf.InlCalls {
|
|||
// the pre-inlining decls for the target function and assign child
|
||||
// index accordingly.
|
||||
for ii, sl := range vmap {
|
||||
sort.Sort(byClassThenName(sl))
|
||||
var m map[varPos]int
|
||||
if ii == 0 {
|
||||
if !fnsym.WasInlined() {
|
||||
|
|
@ -311,31 +309,6 @@ func beginRange(calls []dwarf.InlCall, p *obj.Prog, ii int, imap map[int]int) *d
|
|||
return &call.Ranges[len(call.Ranges)-1]
|
||||
}
|
||||
|
||||
func cmpDwarfVar(a, b *dwarf.Var) bool {
|
||||
// named before artificial
|
||||
aart := 0
|
||||
if strings.HasPrefix(a.Name, "~r") {
|
||||
aart = 1
|
||||
}
|
||||
bart := 0
|
||||
if strings.HasPrefix(b.Name, "~r") {
|
||||
bart = 1
|
||||
}
|
||||
if aart != bart {
|
||||
return aart < bart
|
||||
}
|
||||
|
||||
// otherwise sort by name
|
||||
return a.Name < b.Name
|
||||
}
|
||||
|
||||
// byClassThenName implements sort.Interface for []*dwarf.Var using cmpDwarfVar.
|
||||
type byClassThenName []*dwarf.Var
|
||||
|
||||
func (s byClassThenName) Len() int { return len(s) }
|
||||
func (s byClassThenName) Less(i, j int) bool { return cmpDwarfVar(s[i], s[j]) }
|
||||
func (s byClassThenName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
|
||||
func dumpInlCall(inlcalls dwarf.InlCalls, idx, ilevel int) {
|
||||
for i := 0; i < ilevel; i++ {
|
||||
Ctxt.Logf(" ")
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import (
|
|||
"fmt"
|
||||
"math/rand"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -594,35 +593,9 @@ func preInliningDcls(fnsym *obj.LSym) []*Node {
|
|||
}
|
||||
rdcl = append(rdcl, n)
|
||||
}
|
||||
sort.Sort(byNodeName(rdcl))
|
||||
return rdcl
|
||||
}
|
||||
|
||||
func cmpNodeName(a, b *Node) bool {
|
||||
aart := 0
|
||||
if strings.HasPrefix(a.Sym.Name, "~") {
|
||||
aart = 1
|
||||
}
|
||||
bart := 0
|
||||
if strings.HasPrefix(b.Sym.Name, "~") {
|
||||
bart = 1
|
||||
}
|
||||
if aart != bart {
|
||||
return aart < bart
|
||||
}
|
||||
|
||||
aname := unversion(a.Sym.Name)
|
||||
bname := unversion(b.Sym.Name)
|
||||
return aname < bname
|
||||
}
|
||||
|
||||
// byNodeName implements sort.Interface for []*Node using cmpNodeName.
|
||||
type byNodeName []*Node
|
||||
|
||||
func (s byNodeName) Len() int { return len(s) }
|
||||
func (s byNodeName) Less(i, j int) bool { return cmpNodeName(s[i], s[j]) }
|
||||
func (s byNodeName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
|
||||
// stackOffset returns the stack location of a LocalSlot relative to the
|
||||
// stack pointer, suitable for use in a DWARF location entry. This has nothing
|
||||
// to do with its offset in the user variable.
|
||||
|
|
|
|||
Loading…
Reference in New Issue