Gopher Robot submitted the change![Open in Gerrit]()
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
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:
Code-Review: +2 by Keith Randall, +1 by Junyang Shao, +1 by Keith Randall
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Id77a2473caf66d366f5c94108aa6cb6d3df5b887
Gerrit-Change-Number: 740840
Gerrit-PatchSet: 5