Skip to content

Commit 7b88b22

Browse files
committed
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 <[email protected]>
1 parent 225981f commit 7b88b22

File tree

2 files changed

+0
-54
lines changed

2 files changed

+0
-54
lines changed

src/cmd/compile/internal/gc/dwinl.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"cmd/internal/dwarf"
99
"cmd/internal/obj"
1010
"cmd/internal/src"
11-
"sort"
1211
"strings"
1312
)
1413

@@ -96,7 +95,6 @@ func assembleInlines(fnsym *obj.LSym, dwVars []*dwarf.Var) dwarf.InlCalls {
9695
// the pre-inlining decls for the target function and assign child
9796
// index accordingly.
9897
for ii, sl := range vmap {
99-
sort.Sort(byClassThenName(sl))
10098
var m map[varPos]int
10199
if ii == 0 {
102100
if !fnsym.WasInlined() {
@@ -311,31 +309,6 @@ func beginRange(calls []dwarf.InlCall, p *obj.Prog, ii int, imap map[int]int) *d
311309
return &call.Ranges[len(call.Ranges)-1]
312310
}
313311

314-
func cmpDwarfVar(a, b *dwarf.Var) bool {
315-
// named before artificial
316-
aart := 0
317-
if strings.HasPrefix(a.Name, "~r") {
318-
aart = 1
319-
}
320-
bart := 0
321-
if strings.HasPrefix(b.Name, "~r") {
322-
bart = 1
323-
}
324-
if aart != bart {
325-
return aart < bart
326-
}
327-
328-
// otherwise sort by name
329-
return a.Name < b.Name
330-
}
331-
332-
// byClassThenName implements sort.Interface for []*dwarf.Var using cmpDwarfVar.
333-
type byClassThenName []*dwarf.Var
334-
335-
func (s byClassThenName) Len() int { return len(s) }
336-
func (s byClassThenName) Less(i, j int) bool { return cmpDwarfVar(s[i], s[j]) }
337-
func (s byClassThenName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
338-
339312
func dumpInlCall(inlcalls dwarf.InlCalls, idx, ilevel int) {
340313
for i := 0; i < ilevel; i++ {
341314
Ctxt.Logf(" ")

src/cmd/compile/internal/gc/pgen.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"fmt"
1616
"math/rand"
1717
"sort"
18-
"strings"
1918
"sync"
2019
"time"
2120
)
@@ -594,35 +593,9 @@ func preInliningDcls(fnsym *obj.LSym) []*Node {
594593
}
595594
rdcl = append(rdcl, n)
596595
}
597-
sort.Sort(byNodeName(rdcl))
598596
return rdcl
599597
}
600598

601-
func cmpNodeName(a, b *Node) bool {
602-
aart := 0
603-
if strings.HasPrefix(a.Sym.Name, "~") {
604-
aart = 1
605-
}
606-
bart := 0
607-
if strings.HasPrefix(b.Sym.Name, "~") {
608-
bart = 1
609-
}
610-
if aart != bart {
611-
return aart < bart
612-
}
613-
614-
aname := unversion(a.Sym.Name)
615-
bname := unversion(b.Sym.Name)
616-
return aname < bname
617-
}
618-
619-
// byNodeName implements sort.Interface for []*Node using cmpNodeName.
620-
type byNodeName []*Node
621-
622-
func (s byNodeName) Len() int { return len(s) }
623-
func (s byNodeName) Less(i, j int) bool { return cmpNodeName(s[i], s[j]) }
624-
func (s byNodeName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
625-
626599
// stackOffset returns the stack location of a LocalSlot relative to the
627600
// stack pointer, suitable for use in a DWARF location entry. This has nothing
628601
// to do with its offset in the user variable.

0 commit comments

Comments
 (0)