]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove var sorting from DWARF inline generation
authorThan McIntosh <thanm@google.com>
Tue, 28 Aug 2018 15:27:07 +0000 (11:27 -0400)
committerThan McIntosh <thanm@google.com>
Wed, 29 Aug 2018 11:30:44 +0000 (11:30 +0000)
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>
src/cmd/compile/internal/gc/dwinl.go
src/cmd/compile/internal/gc/pgen.go

index d191b7ba6c84c4bbd4c33c05ee6b5cfc986aad9b..51251c9139fd24c1874c7b85035ffbf187e0b9fc 100644 (file)
@@ -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("  ")
index cf1164772b0fca519f0c0ed23564bf6f800f574d..7f20643ab57feb717ed7fd539ebfd216d7d7c51e 100644 (file)
@@ -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.