[go] cmd/compile: fix slice bounds check elimination after function inlining

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Feb 12, 2026, 12:29:13 PM (18 hours ago) Feb 12
to Youlin Feng, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Junyang Shao, Keith Randall, Keith Randall, Go LUCI, David Chase, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
cmd/compile: fix slice bounds check elimination after function inlining

When creating a dynamically-sized slice, the compiler attempts to use a
stack-allocated buffer if the slice does not escape and its buffer size
is ≤ 32 bytes.

In this case, the SSA will contain a (OpPhi (OpSliceMake) (OpSliceMake))
value: one OpSliceMake uses the stack-allocated buffer, and the other
uses the heap-allocated buffer. The len and cap arguments for these two
OpSliceMake values are expected to be identical.

This CL enables the prove pass to recognize this scenario and handle
OpSliceLen and OpSliceCap as intended.

Fixes #77375
Change-Id: Id77a2473caf66d366f5c94108aa6cb6d3df5b887
Reviewed-by: Keith Randall <k...@golang.org>
Reviewed-by: Junyang Shao <shaoj...@google.com>
Auto-Submit: Keith Randall <k...@golang.org>
Reviewed-by: Keith Randall <k...@google.com>
Files:
  • M src/cmd/compile/internal/ssa/_gen/generic.rules
  • M src/cmd/compile/internal/ssa/prove.go
  • M src/cmd/compile/internal/ssa/rewritegeneric.go
  • A test/codegen/issue77375.go
Change size: M
Delta: 4 files changed, 88 insertions(+), 1 deletion(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Keith Randall, +1 by Junyang Shao, +1 by Keith Randall
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Id77a2473caf66d366f5c94108aa6cb6d3df5b887
Gerrit-Change-Number: 740840
Gerrit-PatchSet: 5
Gerrit-Owner: Youlin Feng <fengy...@live.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@google.com>
Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages