aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/base/debug.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2022-08-18 20:59:26 -0700
committerMatthew Dempsky <mdempsky@google.com>2022-08-23 18:14:10 +0000
commit6985ab27dfd10de6d9e119a51c541a2bc1cbcdf7 (patch)
treea7871676373681bd8d4bbb5b10a07a89221693a0 /src/cmd/compile/internal/base/debug.go
parent0a6e1fa986e04add090afa50b8e566dca40df760 (diff)
downloadgo-6985ab27dfd10de6d9e119a51c541a2bc1cbcdf7.tar.xz
cmd/compile: fix unified IR's pointer-shaping
In CL 424734, I implemented pointer shaping for unified IR. Evidently though, we didn't have any test cases that check that uses of pointer-shaped expressions were handled correctly. In the reported test case, the struct field "children items[*node[T]]" gets shaped to "children items[go.shape.*uint8]" (underlying type "[]go.shape.*uint8"); and so the expression "n.children[i]" has type "go.shape.*uint8" and the ".items" field selection expression fails. The fix implemented in this CL is that any expression of derived type now gets an explicit "reshape" operation applied to it, to ensure it has the appropriate type for its context. E.g., the "n.children[i]" OINDEX expression above gets "reshaped" from "go.shape.*uint8" to "*node[go.shape.int]", allowing the field selection to succeed. This CL also adds a "-d=reshape" compiler debugging flag, because I anticipate debugging reshaping operations will be something to come up again in the future. Fixes #54535. Change-Id: Id847bd8f51300d2491d679505ee4d2e974ca972a Reviewed-on: https://go-review.googlesource.com/c/go/+/424936 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: hopehook <hopehook@qq.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/base/debug.go')
-rw-r--r--src/cmd/compile/internal/base/debug.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/base/debug.go b/src/cmd/compile/internal/base/debug.go
index f1d020f342..5edb665e37 100644
--- a/src/cmd/compile/internal/base/debug.go
+++ b/src/cmd/compile/internal/base/debug.go
@@ -34,6 +34,7 @@ type DebugFlags struct {
NoRefName int `help:"do not include referenced symbol names in object file"`
PCTab string `help:"print named pc-value table\nOne of: pctospadj, pctofile, pctoline, pctoinline, pctopcdata"`
Panic int `help:"show all compiler panics"`
+ Reshape int `help:"print information about expression reshaping"`
Slice int `help:"print information about slice compilation"`
SoftFloat int `help:"force compiler to emit soft-float code"`
SyncFrames int `help:"how many writer stack frames to include at sync points in unified export data"`