mirror of
https://github.com/golang/go.git
synced 2026-04-02 17:30:01 +09:00
Fixes #77720 Add a generic SSA rewrite that forwards `Load` from a `Move` destination back to the `Move` source when it is provably safe, so field reads like `s.h.Value().typ` don’t force a full struct copy. - Add `Load <- Move` rewrite in `generic.rules` with safety guard: non-volatile source - Tweak `fixedbugs/issue22200*` so that it can still trigger the "stack frame too large" error. - Regenerate `rewritegeneric.go`. - Add `test/codegen/moveload.go` to assert no `MOVUPS` and direct `MOVBLZX` in both direct and inlined forms. Benchmark results (linux/amd64, i7-14700KF): $ go test cmd/compile/internal/test -run='^$' -bench='MoveLoad' -count=20 Before: BenchmarkMoveLoadTypViaValue-20 ~76.9 ns/op BenchmarkMoveLoadTypViaPtr-20 ~1.97 ns/op After: BenchmarkMoveLoadTypViaValue-20 ~1.894 ns/op BenchmarkMoveLoadTypViaPtr-20 ~1.905 ns/op The rewrite removes the redundant struct copy in `s.h.Value().typ`, bringing it in line with the direct pointer form. Change-Id: Iddf2263e390030ba013e0642a695b87c75f899da Reviewed-on: https://go-review.googlesource.com/c/go/+/748200 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Mark Freeman <markfreeman@google.com>
23 lines
432 B
Go
23 lines
432 B
Go
// errorcheck
|
|
|
|
// Copyright 2017 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package p
|
|
|
|
func f1(x *[1<<30 - 1e6]byte) byte {
|
|
sum := byte(0)
|
|
for _, b := range *x {
|
|
sum += b
|
|
}
|
|
return sum
|
|
}
|
|
func f2(x *[1<<30 + 1e6]byte) byte { // GC_ERROR "stack frame too large"
|
|
sum := byte(0)
|
|
for _, b := range *x {
|
|
sum += b
|
|
}
|
|
return sum
|
|
}
|