aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2025-03-19 10:17:22 -0700
committerKeith Randall <khr@golang.org>2025-04-21 15:50:43 -0700
commit8af32240c6c8f21695cdcb3b6df8293d7f2d3bc7 (patch)
treee57483e9747e59aa32d85c66ef34726c9566e8bb /test/codegen
parent04a9b16f3d69aa66f3aaab44dcd322e4a02a82aa (diff)
downloadgo-8af32240c6c8f21695cdcb3b6df8293d7f2d3bc7.tar.xz
cmd/compile: don't evaluate side effects of range over array
If the thing we're ranging over is an array or ptr to array, and it doesn't have a function call or channel receive in it, then we shouldn't evaluate it. Typecheck the ranged-over value as a constant in that case. That makes the unified exporter replace the range expression with a constant int. Change-Id: I0d4ea081de70d20cf6d1fa8d25ef6cb021975554 Reviewed-on: https://go-review.googlesource.com/c/go/+/659317 Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/issue52635.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/codegen/issue52635.go b/test/codegen/issue52635.go
index 9b08cade36..9ee63f0fbe 100644
--- a/test/codegen/issue52635.go
+++ b/test/codegen/issue52635.go
@@ -12,6 +12,7 @@ package codegen
type T struct {
a *[10]int
b [10]int
+ s []int
}
func (t *T) f() {
@@ -38,4 +39,15 @@ func (t *T) f() {
for i := range *t.a {
(*t.a)[i] = 0
}
+
+ // amd64:-".*runtime.memclrNoHeapPointers"
+ // amd64:"DUFFZERO"
+ for i := range t.b {
+ t.b[i] = 0
+ }
+
+ // amd64:".*runtime.memclrNoHeapPointers"
+ for i := range t.s {
+ t.s[i] = 0
+ }
}