]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: second attempt at fix for issue 23179
authorThan McIntosh <thanm@google.com>
Wed, 20 Dec 2017 14:54:13 +0000 (09:54 -0500)
committerThan McIntosh <thanm@google.com>
Wed, 20 Dec 2017 20:39:16 +0000 (20:39 +0000)
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>
src/cmd/compile/internal/gc/dwinl.go
test/fixedbugs/issue23179.dir/a.go
test/fixedbugs/issue23179.dir/b.go

index 06eebc96e50d4d996b16d9cf0ab425696b7c84fd..e4eae3e87f634974097b51ea1216bee76e5b8b7a 100644 (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
                        }
index 1b796660fdcf45c5e7c8a166a4bca73cad522c7e..3d2816fc69d3c187c48518873278b8a3134e3788 100644 (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
 }
index edf5e6d81266b085325bd3af190da74729e135df..bec3d15e1e1f5c24497a1a9be8bc370e4c9d3f7e 100644 (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{})
 }