]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use canonical stringslice/ representations in abiutils
authorThan McIntosh <thanm@google.com>
Wed, 10 Nov 2021 20:36:25 +0000 (15:36 -0500)
committerThan McIntosh <thanm@google.com>
Thu, 11 Nov 2021 11:47:33 +0000 (11:47 +0000)
A chunk of code in abiutils was synthesizing the internals of a Go
string type as "struct { unsafe.Pointer, uintptr }" instead of the
more canonical representation "struct { *uint8, int }" used elsewhere
in the compiler. The abiutils type was being pulled into the code
during late call expansion, which resulted in two different entries in
the SSA named value table for the same variable piece, each with
different types; this then confused DWARF location list generation.
This patch changes the abiutils synthesized type to be consistent with
other parts of the back end, and makes a similar change for
synthesized slice types (use "struct { *uint8, int, int }").

Fixes #47354.

Change-Id: If789031cdc7abaf215bc75ee6eb863defbe530be
Reviewed-on: https://go-review.googlesource.com/c/go/+/362715
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/abi/abiutils.go

index 74c8707b298aa2fdbf6254cb2f599d7f15833525..529150a390b1d577e93bfa554bb2a42553c77549 100644 (file)
@@ -715,19 +715,20 @@ func setup() {
        synthOnce.Do(func() {
                fname := types.BuiltinPkg.Lookup
                nxp := src.NoXPos
-               unsp := types.Types[types.TUNSAFEPTR]
-               ui := types.Types[types.TUINTPTR]
+               bp := types.NewPtr(types.Types[types.TUINT8])
+               it := types.Types[types.TINT]
                synthSlice = types.NewStruct(types.NoPkg, []*types.Field{
-                       types.NewField(nxp, fname("ptr"), unsp),
-                       types.NewField(nxp, fname("len"), ui),
-                       types.NewField(nxp, fname("cap"), ui),
+                       types.NewField(nxp, fname("ptr"), bp),
+                       types.NewField(nxp, fname("len"), it),
+                       types.NewField(nxp, fname("cap"), it),
                })
                types.CalcStructSize(synthSlice)
                synthString = types.NewStruct(types.NoPkg, []*types.Field{
-                       types.NewField(nxp, fname("data"), unsp),
-                       types.NewField(nxp, fname("len"), ui),
+                       types.NewField(nxp, fname("data"), bp),
+                       types.NewField(nxp, fname("len"), it),
                })
                types.CalcStructSize(synthString)
+               unsp := types.Types[types.TUNSAFEPTR]
                synthIface = types.NewStruct(types.NoPkg, []*types.Field{
                        types.NewField(nxp, fname("f1"), unsp),
                        types.NewField(nxp, fname("f2"), unsp),