]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't clear ptrmask in fillptrmask
authorIan Lance Taylor <iant@golang.org>
Thu, 6 Nov 2025 04:32:38 +0000 (20:32 -0800)
committerGopher Robot <gobot@golang.org>
Wed, 12 Nov 2025 18:03:49 +0000 (10:03 -0800)
It is only ever called with a newly allocated slice.

This clearing code dates back to the C version of the compiler,
in which the function started like this:

static void
gengcmask(Type *t, uint8 gcmask[16])
{
...

memset(gcmask, 0, 16);
if(!haspointers(t))
return;

That memset was required for C, but not for Go.

Change-Id: I6fceb99b2dc8682685dca2e4289fcd58e2e5a0e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/718340
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
src/cmd/compile/internal/reflectdata/reflect.go

index 38b9391c5f1a572cc0e9d88b61aa83b2d28d55fd..324007ea798f13a379206d5448186624af06d3d6 100644 (file)
@@ -1282,7 +1282,6 @@ func dgcptrmask(t *types.Type, write bool) *obj.LSym {
 // word offsets in t that hold pointers.
 // ptrmask is assumed to fit at least types.PtrDataSize(t)/PtrSize bits.
 func fillptrmask(t *types.Type, ptrmask []byte) {
-       clear(ptrmask)
        if !t.HasPointers() {
                return
        }