]> Cypherpunks repositories - gostls13.git/commit
cmd/compile, unique: model data flow of non-string pointers
authorCherry Mui <cherryyz@google.com>
Wed, 21 May 2025 18:33:13 +0000 (14:33 -0400)
committerCherry Mui <cherryyz@google.com>
Thu, 22 May 2025 03:07:36 +0000 (20:07 -0700)
commit5e6a868b28d3e7a71fa328c18ff5e93d72a1fb67
tree6d026379ac2e2544116d72cddab70ef935418e6b
parent8bf816ae6879fa4537cc6e6e292769df2d7dbb78
cmd/compile, unique: model data flow of non-string pointers

Currently, hash/maphash.Comparable escapes its parameter if it
contains non-string pointers, but does not escape strings or types
that contain strings but no other pointers. This is achieved by a
compiler intrinsic.

unique.Make does something similar: it stores its parameter to a
central map, with strings cloned. So from the escape analysis's
perspective, the non-string pointers are passed through, whereas
string pointers are not. We currently cannot model this type of
type-dependent data flow directly in Go. So we do this with a
compiler intrinsic. In fact, we can unify this and the intrinsic
above.

Tests are from Jake Bailey's CL 671955 (thanks!).

Fixes #73680.

Change-Id: Ia6a78e09dee39f8d9198a16758e4b5322ee2c56a
Reviewed-on: https://go-review.googlesource.com/c/go/+/675156
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Jake Bailey <jacob.b.bailey@gmail.com>
src/cmd/compile/internal/escape/call.go
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/walk/expr.go
src/hash/maphash/maphash.go
src/internal/abi/escape.go
src/unique/clone.go
src/unique/handle_test.go
test/escape_unique.go [new file with mode: 0644]