summaryrefslogtreecommitdiffstats
path: root/src/cmd/compile/internal/loopvar/testdata/opt-121.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:25:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:25:22 +0000
commitf6ad4dcef54c5ce997a4bad5a6d86de229015700 (patch)
tree7cfa4e31ace5c2bd95c72b154d15af494b2bcbef /src/cmd/compile/internal/loopvar/testdata/opt-121.go
parentInitial commit. (diff)
downloadgolang-1.22-f6ad4dcef54c5ce997a4bad5a6d86de229015700.tar.xz
golang-1.22-f6ad4dcef54c5ce997a4bad5a6d86de229015700.zip
Adding upstream version 1.22.1.upstream/1.22.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/cmd/compile/internal/loopvar/testdata/opt-121.go')
-rw-r--r--src/cmd/compile/internal/loopvar/testdata/opt-121.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/loopvar/testdata/opt-121.go b/src/cmd/compile/internal/loopvar/testdata/opt-121.go
new file mode 100644
index 0000000..4afb658
--- /dev/null
+++ b/src/cmd/compile/internal/loopvar/testdata/opt-121.go
@@ -0,0 +1,43 @@
+// Copyright 2023 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.
+
+//go:build go1.21
+
+package main
+
+import (
+ "fmt"
+ "os"
+)
+
+var is []func() int
+
+func inline(j, k int) []*int {
+ var a []*int
+ for private := j; private < k; private++ {
+ a = append(a, &private)
+ }
+ return a
+}
+
+//go:noinline
+func notinline(j, k int) ([]*int, *int) {
+ for shared := j; shared < k; shared++ {
+ if shared == k/2 {
+ // want the call inlined, want "private" in that inline to be transformed,
+ // (believe it ends up on init node of the return).
+ // but do not want "shared" transformed,
+ return inline(j, k), &shared
+ }
+ }
+ return nil, &j
+}
+
+func main() {
+ a, p := notinline(2, 9)
+ fmt.Printf("a[0]=%d,*p=%d\n", *a[0], *p)
+ if *a[0] != 2 {
+ os.Exit(1)
+ }
+}