cmd/compile: second attempt at fix for issue 23179

My previous fix for issue 23179 was incomplete; it turns out that if
an unnamed parameter is below a specific size threshold, it gets
register-promoted away by the compiler (hence not encountered during
some parts of DWARF inline info processing), but if it is sufficiently
large, it is allocated to the stack as a named variable and treated as
a regular parameter by DWARF generation. Interestingly, something in
the ppc64le build of k8s causes an unnamed parameter to be retained
(where on amd64 it is deleted), meaning that this wasn't caught in my
amd64 testing.

The fix is to insure that "_" params are treated in the same way that
"~r%d" return temps are when matching up post-optimization inlined
routine params with pre-inlining declarations. I've also updated the
test case to include a "_" parameter with a very large size, which
also triggers the bug on amd64.

Fixes #23179.

Change-Id: I961c84cc7a873ad3f8f91db098a5e13896c4856e
Reviewed-on: https://go-review.googlesource.com/84975
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
Than McIntosh 2017-12-20 09:54:13 -05:00
parent 0504cd68e6
commit 841d865a56
3 changed files with 9 additions and 8 deletions

View file

@ -129,10 +129,10 @@ func assembleInlines(fnsym *obj.LSym, fn *Node, dwVars []*dwarf.Var) dwarf.InlCa
DeclLine: sl[j].DeclLine,
DeclCol: sl[j].DeclCol,
}
returnTmp := strings.HasPrefix(sl[j].Name, "~r")
synthesized := strings.HasPrefix(sl[j].Name, "~r") || canonName == "_"
if idx, found := m[vp]; found {
sl[j].ChildIndex = int32(idx)
sl[j].IsInAbstract = !returnTmp
sl[j].IsInAbstract = !synthesized
sl[j].Name = canonName
} else {
// Variable can't be found in the pre-inline dcl list.
@ -140,10 +140,7 @@ func assembleInlines(fnsym *obj.LSym, fn *Node, dwVars []*dwarf.Var) dwarf.InlCa
// because a composite variable was split into pieces,
// and we're looking at a piece. We can also see
// return temps (~r%d) that were created during
// lowering.
if ii != 0 && !returnTmp {
Fatalf("unexpected: can't find var %s in preInliningDcls for %v\n", sl[j].Name, Ctxt.InlTree.InlinedFunction(int(ii-1)))
}
// lowering, or unnamed params ("_").
sl[j].ChildIndex = int32(synthCount)
synthCount += 1
}

View file

@ -4,6 +4,10 @@
package a
func F(x int, _ int, _ bool) int {
type Large struct {
x [256]int
}
func F(x int, _ int, _ bool, _ Large) int {
return x
}

View file

@ -7,5 +7,5 @@ package b
import "a"
func G(x int) int {
return a.F(x, 1, false)
return a.F(x, 1, false, a.Large{})
}