1// Copyright 2023 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5//go:build go1.22
6
7package main
8
9import (
10	"fmt"
11	"os"
12)
13
14var is []func() int
15
16func inline(j, k int) []*int {
17	var a []*int
18	for private := j; private < k; private++ {
19		a = append(a, &private)
20	}
21	return a
22}
23
24//go:noinline
25func notinline(j, k int) ([]*int, *int) {
26	for shared := j; shared < k; shared++ {
27		if shared == k/2 {
28			// want the call inlined, want "private" in that inline to be transformed,
29			// (believe it ends up on init node of the return).
30			// but do not want "shared" transformed,
31			return inline(j, k), &shared
32		}
33	}
34	return nil, &j
35}
36
37func main() {
38	a, p := notinline(2, 9)
39	fmt.Printf("a[0]=%d,*p=%d\n", *a[0], *p)
40	if *a[0] != 2 {
41		os.Exit(1)
42	}
43}
44