diff options
author | Than McIntosh <thanm@google.com> | 2019-03-22 08:14:45 -0400 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2019-03-27 17:01:50 +0000 |
commit | e552f772f7857d4511ab6259e2b1e31b2b9c5c42 (patch) | |
tree | 1218a07ac63cc9e4c4336857125681ba397a90ed | |
parent | fc6457d1d2f6330a628d398701912c19e1f3b1ec (diff) | |
download | go-e552f772f7857d4511ab6259e2b1e31b2b9c5c42.tar.gz go-e552f772f7857d4511ab6259e2b1e31b2b9c5c42.zip |
[release-branch.go1.12] cmd/compile: better handling for PAUTOHEAP in DWARF inline gen
When generating DWARF inline info records, the post-SSA code looks
through the original "pre-inline" dcl list for the function so as to
handle situations where formal params are promoted or optimized away.
This code was not properly handling the case where an output parameter
was promoted to the heap -- in this case the param node is converted
in place from class PPARAMOUT to class PAUTOHEAP. This caused
inconsistencies later on, since the variable entry in the abstract
subprogram DIE wound up as a local and not an output parameter.
Updates #30908.
Fixes #31028.
Change-Id: Ia70b89f0cf7f9b16246d95df17ad6e307228b8c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/168818
Reviewed-by: Cherry Zhang <cherryyz@google.com>
(cherry picked from commit 68a98d52794fc324841f62732411f6bba23fc62c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/169417
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r-- | src/cmd/compile/internal/gc/dwinl.go | 2 | ||||
-rw-r--r-- | src/cmd/compile/internal/gc/pgen.go | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/gc/dwinl.go b/src/cmd/compile/internal/gc/dwinl.go index ade76f40f8..cc42a04c64 100644 --- a/src/cmd/compile/internal/gc/dwinl.go +++ b/src/cmd/compile/internal/gc/dwinl.go @@ -127,7 +127,7 @@ func assembleInlines(fnsym *obj.LSym, dwVars []*dwarf.Var) dwarf.InlCalls { DeclLine: v.DeclLine, DeclCol: v.DeclCol, } - synthesized := strings.HasPrefix(v.Name, "~r") || canonName == "_" + synthesized := strings.HasPrefix(v.Name, "~r") || canonName == "_" || strings.HasPrefix(v.Name, "~b") if idx, found := m[vp]; found { v.ChildIndex = int32(idx) v.IsInAbstract = !synthesized diff --git a/src/cmd/compile/internal/gc/pgen.go b/src/cmd/compile/internal/gc/pgen.go index 1dc4b53427..28143dee29 100644 --- a/src/cmd/compile/internal/gc/pgen.go +++ b/src/cmd/compile/internal/gc/pgen.go @@ -597,8 +597,22 @@ func createDwarfVars(fnsym *obj.LSym, fn *Func, automDecls []*Node) ([]*Node, [] typename := dwarf.InfoPrefix + typesymname(n.Type) decls = append(decls, n) abbrev := dwarf.DW_ABRV_AUTO_LOCLIST + isReturnValue := (n.Class() == PPARAMOUT) if n.Class() == PPARAM || n.Class() == PPARAMOUT { abbrev = dwarf.DW_ABRV_PARAM_LOCLIST + } else if n.Class() == PAUTOHEAP { + // If dcl in question has been promoted to heap, do a bit + // of extra work to recover original class (auto or param); + // see issue 30908. This insures that we get the proper + // signature in the abstract function DIE, but leaves a + // misleading location for the param (we want pointer-to-heap + // and not stack). + // TODO(thanm): generate a better location expression + stackcopy := n.Name.Param.Stackcopy + if stackcopy != nil && (stackcopy.Class() == PPARAM || stackcopy.Class() == PPARAMOUT) { + abbrev = dwarf.DW_ABRV_PARAM_LOCLIST + isReturnValue = (stackcopy.Class() == PPARAMOUT) + } } inlIndex := 0 if genDwarfInline > 1 { @@ -612,7 +626,7 @@ func createDwarfVars(fnsym *obj.LSym, fn *Func, automDecls []*Node) ([]*Node, [] declpos := Ctxt.InnermostPos(n.Pos) vars = append(vars, &dwarf.Var{ Name: n.Sym.Name, - IsReturnValue: n.Class() == PPARAMOUT, + IsReturnValue: isReturnValue, Abbrev: abbrev, StackOffset: int32(n.Xoffset), Type: Ctxt.Lookup(typename), |