aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/reader.go
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2025-06-03 21:35:20 +0700
committerGopher Robot <gobot@golang.org>2025-06-09 09:29:38 -0700
commitda0e8c4517178f545ee78b11e3d91e1daa7ce07a (patch)
tree0c6249ec0a06ecfd4c1f06215518c6045d024604 /src/cmd/compile/internal/noder/reader.go
parent7800f4f0adbc749be95d13be48524e9702c50bbc (diff)
downloadgo-da0e8c4517178f545ee78b11e3d91e1daa7ce07a.tar.xz
cmd/compile: relax reshaping condition
CL 641955 changes the Unified IR reader to not doing shapify when reading reshaping expression. However, this condition only matters with pointer type shaping, which will lose the original type, causes the reshaping ends up with a completely different type. This CL relaxes the condition, always allow non-pointer types shaping. Updates #71184 Fixes #73947 Change-Id: Ib0bafd8932c52d99266f311b6cbfc75c00383f9b Reviewed-on: https://go-review.googlesource.com/c/go/+/678335 Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/noder/reader.go')
-rw-r--r--src/cmd/compile/internal/noder/reader.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go
index 2c3f7161a8..38b0bc1d8a 100644
--- a/src/cmd/compile/internal/noder/reader.go
+++ b/src/cmd/compile/internal/noder/reader.go
@@ -1014,7 +1014,25 @@ func (pr *pkgReader) objDictIdx(sym *types.Sym, idx index, implicits, explicits
// arguments.
for i, targ := range dict.targs {
basic := r.Bool()
- if dict.shaped && !pr.reshaping {
+ isPointerShape := basic && targ.IsPtr() && !targ.Elem().NotInHeap()
+ // We should not do shapify during the reshaping process, see #71184.
+ // However, this only matters for shapify a pointer type, which will
+ // lose the original underlying type.
+ //
+ // Example with a pointer type:
+ //
+ // - First, shapifying *[]T -> *uint8
+ // - During the reshaping process, *uint8 is shapified to *go.shape.uint8
+ // - This ends up with a different type with the original *[]T
+ //
+ // For a non-pointer type:
+ //
+ // - int -> go.shape.int
+ // - go.shape.int -> go.shape.int
+ //
+ // We always end up with the identical type.
+ canShapify := !pr.reshaping || !isPointerShape
+ if dict.shaped && canShapify {
dict.targs[i] = shapify(targ, basic)
}
}