]> Cypherpunks.ru repositories - gostls13.git/blob - test/live.go
cmd/compile,runtime: redo how map assignments work
[gostls13.git] / test / live.go
1 // errorcheckwithauto -0 -l -live -wb=0
2 // +build !ppc64,!ppc64le
3 // ppc64 needs a better tighten pass to make f18 pass
4
5 // Copyright 2014 The Go Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style
7 // license that can be found in the LICENSE file.
8
9 // liveness tests with inlining disabled.
10 // see also live2.go.
11
12 package main
13
14 func printnl()
15
16 //go:noescape
17 func printpointer(**int)
18
19 //go:noescape
20 func printintpointer(*int)
21
22 //go:noescape
23 func printstringpointer(*string)
24
25 //go:noescape
26 func printstring(string)
27
28 //go:noescape
29 func printbytepointer(*byte)
30
31 func printint(int)
32
33 func f1() {
34         var x *int
35         printpointer(&x) // ERROR "live at call to printpointer: x$"
36         printpointer(&x) // ERROR "live at call to printpointer: x$"
37 }
38
39 func f2(b bool) {
40         if b {
41                 printint(0) // nothing live here
42                 return
43         }
44         var x *int
45         printpointer(&x) // ERROR "live at call to printpointer: x$"
46         printpointer(&x) // ERROR "live at call to printpointer: x$"
47 }
48
49 func f3(b1, b2 bool) {
50         // Here x and y are ambiguously live. In previous go versions they
51         // were marked as live throughout the function to avoid being
52         // poisoned in GODEBUG=gcdead=1 mode; this is now no longer the
53         // case.
54
55         printint(0)
56         if b1 == false {
57                 printint(0)
58                 return
59         }
60
61         if b2 {
62                 var x *int
63                 printpointer(&x) // ERROR "live at call to printpointer: x$"
64                 printpointer(&x) // ERROR "live at call to printpointer: x$"
65         } else {
66                 var y *int
67                 printpointer(&y) // ERROR "live at call to printpointer: y$"
68                 printpointer(&y) // ERROR "live at call to printpointer: y$"
69         }
70         printint(0) // ERROR "f3: x \(type \*int\) is ambiguously live$" "f3: y \(type \*int\) is ambiguously live$" "live at call to printint: x y$"
71 }
72
73 // The old algorithm treated x as live on all code that
74 // could flow to a return statement, so it included the
75 // function entry and code above the declaration of x
76 // but would not include an indirect use of x in an infinite loop.
77 // Check that these cases are handled correctly.
78
79 func f4(b1, b2 bool) { // x not live here
80         if b2 {
81                 printint(0) // x not live here
82                 return
83         }
84         var z **int
85         x := new(int)
86         *x = 42
87         z = &x
88         printint(**z) // ERROR "live at call to printint: x$"
89         if b2 {
90                 printint(1) // x not live here
91                 return
92         }
93         for {
94                 printint(**z) // ERROR "live at call to printint: x$"
95         }
96 }
97
98 func f5(b1 bool) {
99         var z **int
100         if b1 {
101                 x := new(int)
102                 *x = 42
103                 z = &x
104         } else {
105                 y := new(int)
106                 *y = 54
107                 z = &y
108         }
109         printint(**z) // ERROR "f5: x \(type \*int\) is ambiguously live$" "f5: y \(type \*int\) is ambiguously live$" "live at call to printint: x y$"
110 }
111
112 // confusion about the _ result used to cause spurious "live at entry to f6: _".
113
114 func f6() (_, y string) {
115         y = "hello"
116         return
117 }
118
119 // confusion about addressed results used to cause "live at entry to f7: x".
120
121 func f7() (x string) {
122         _ = &x
123         x = "hello"
124         return
125 }
126
127 // ignoring block returns used to cause "live at entry to f8: x, y".
128
129 func f8() (x, y string) {
130         return g8()
131 }
132
133 func g8() (string, string)
134
135 // ignoring block assignments used to cause "live at entry to f9: x"
136 // issue 7205
137
138 var i9 interface{}
139
140 func f9() bool {
141         g8()
142         x := i9
143         y := interface{}(99.0i) // ERROR "live at call to convT2E: x.data x.type$"
144         i9 = y                  // make y escape so the line above has to call convT2E
145         return x != y
146 }
147
148 // liveness formerly confused by UNDEF followed by RET,
149 // leading to "live at entry to f10: ~r1" (unnamed result).
150
151 func f10() string {
152         panic(1)
153 }
154
155 // liveness formerly confused by select, thinking runtime.selectgo
156 // can return to next instruction; it always jumps elsewhere.
157 // note that you have to use at least two cases in the select
158 // to get a true select; smaller selects compile to optimized helper functions.
159
160 var c chan *int
161 var b bool
162
163 // this used to have a spurious "live at entry to f11a: ~r0"
164 func f11a() *int {
165         select { // ERROR "live at call to newselect: autotmp_[0-9]+$" "live at call to selectgo: autotmp_[0-9]+$"
166         case <-c: // ERROR "live at call to selectrecv: autotmp_[0-9]+$"
167                 return nil
168         case <-c: // ERROR "live at call to selectrecv: autotmp_[0-9]+$"
169                 return nil
170         }
171 }
172
173 func f11b() *int {
174         p := new(int)
175         if b {
176                 // At this point p is dead: the code here cannot
177                 // get to the bottom of the function.
178                 // This used to have a spurious "live at call to printint: p".
179                 printint(1) // nothing live here!
180                 select {    // ERROR "live at call to newselect: autotmp_[0-9]+$" "live at call to selectgo: autotmp_[0-9]+$"
181                 case <-c: // ERROR "live at call to selectrecv: autotmp_[0-9]+$"
182                         return nil
183                 case <-c: // ERROR "live at call to selectrecv: autotmp_[0-9]+$"
184                         return nil
185                 }
186         }
187         println(*p)
188         return nil
189 }
190
191 var sink *int
192
193 func f11c() *int {
194         p := new(int)
195         sink = p // prevent stack allocation, otherwise p is rematerializeable
196         if b {
197                 // Unlike previous, the cases in this select fall through,
198                 // so we can get to the println, so p is not dead.
199                 printint(1) // ERROR "live at call to printint: p$"
200                 select {    // ERROR "live at call to newselect: autotmp_[0-9]+ p$" "live at call to selectgo: autotmp_[0-9]+ p$"
201                 case <-c: // ERROR "live at call to selectrecv: autotmp_[0-9]+ p$"
202                 case <-c: // ERROR "live at call to selectrecv: autotmp_[0-9]+ p$"
203                 }
204         }
205         println(*p)
206         return nil
207 }
208
209 // similarly, select{} does not fall through.
210 // this used to have a spurious "live at entry to f12: ~r0".
211
212 func f12() *int {
213         if b {
214                 select {}
215         } else {
216                 return nil
217         }
218 }
219
220 // incorrectly placed VARDEF annotations can cause missing liveness annotations.
221 // this used to be missing the fact that s is live during the call to g13 (because it is
222 // needed for the call to h13).
223
224 func f13() {
225         s := g14()
226         s = h13(s, g13(s)) // ERROR "live at call to g13: s.ptr$"
227 }
228
229 func g13(string) string
230 func h13(string, string) string
231
232 // more incorrectly placed VARDEF.
233
234 func f14() {
235         x := g14()
236         printstringpointer(&x) // ERROR "live at call to printstringpointer: x$"
237 }
238
239 func g14() string
240
241 func f15() {
242         var x string
243         _ = &x
244         x = g15()      // ERROR "live at call to g15: x$"
245         printstring(x) // ERROR "live at call to printstring: x$"
246 }
247
248 func g15() string
249
250 // Checking that various temporaries do not persist or cause
251 // ambiguously live values that must be zeroed.
252 // The exact temporary names are inconsequential but we are
253 // trying to check that there is only one at any given site,
254 // and also that none show up in "ambiguously live" messages.
255
256 var m map[string]int
257
258 func f16() {
259         if b {
260                 delete(m, "hi") // ERROR "live at call to mapdelete: autotmp_[0-9]+$"
261         }
262         delete(m, "hi") // ERROR "live at call to mapdelete: autotmp_[0-9]+$"
263         delete(m, "hi") // ERROR "live at call to mapdelete: autotmp_[0-9]+$"
264 }
265
266 var m2s map[string]*byte
267 var m2 map[[2]string]*byte
268 var x2 [2]string
269 var bp *byte
270
271 func f17a(p *byte) { // ERROR "live at entry to f17a: p$"
272         if b {
273                 m2[x2] = p // ERROR "live at call to mapassign: p$"
274         }
275         m2[x2] = p // ERROR "live at call to mapassign: p$"
276         m2[x2] = p // ERROR "live at call to mapassign: p$"
277 }
278
279 func f17b(p *byte) { // ERROR "live at entry to f17b: p$"
280         // key temporary
281         if b {
282                 m2s["x"] = p // ERROR "live at call to mapassign: p autotmp_[0-9]+$"
283         }
284         m2s["x"] = p // ERROR "live at call to mapassign: p autotmp_[0-9]+$"
285         m2s["x"] = p // ERROR "live at call to mapassign: p autotmp_[0-9]+$"
286 }
287
288 func f17c() {
289         // key and value temporaries
290         if b {
291                 m2s["x"] = f17d() // ERROR "live at call to f17d: autotmp_[0-9]+$" "live at call to mapassign: autotmp_[0-9]+ autotmp_[0-9]+$"
292         }
293         m2s["x"] = f17d() // ERROR "live at call to f17d: autotmp_[0-9]+$" "live at call to mapassign: autotmp_[0-9]+ autotmp_[0-9]+$"
294         m2s["x"] = f17d() // ERROR "live at call to f17d: autotmp_[0-9]+$" "live at call to mapassign: autotmp_[0-9]+ autotmp_[0-9]+$"
295 }
296
297 func f17d() *byte
298
299 func g18() [2]string
300
301 func f18() {
302         // key temporary for mapaccess.
303         // temporary introduced by orderexpr.
304         var z *byte
305         if b {
306                 z = m2[g18()] // ERROR "live at call to mapaccess1: autotmp_[0-9]+$"
307         }
308         z = m2[g18()] // ERROR "live at call to mapaccess1: autotmp_[0-9]+$"
309         z = m2[g18()] // ERROR "live at call to mapaccess1: autotmp_[0-9]+$"
310         printbytepointer(z)
311 }
312
313 var ch chan *byte
314
315 func f19() {
316         // dest temporary for channel receive.
317         var z *byte
318
319         if b {
320                 z = <-ch // ERROR "live at call to chanrecv1: autotmp_[0-9]+$"
321         }
322         z = <-ch // ERROR "live at call to chanrecv1: autotmp_[0-9]+$"
323         z = <-ch // ERROR "live at call to chanrecv1: autotmp_[0-9]+$"
324         printbytepointer(z)
325 }
326
327 func f20() {
328         // src temporary for channel send
329         if b {
330                 ch <- nil // ERROR "live at call to chansend1: autotmp_[0-9]+$"
331         }
332         ch <- nil // ERROR "live at call to chansend1: autotmp_[0-9]+$"
333         ch <- nil // ERROR "live at call to chansend1: autotmp_[0-9]+$"
334 }
335
336 func f21() {
337         // key temporary for mapaccess using array literal key.
338         var z *byte
339         if b {
340                 z = m2[[2]string{"x", "y"}] // ERROR "live at call to mapaccess1: autotmp_[0-9]+$"
341         }
342         z = m2[[2]string{"x", "y"}] // ERROR "live at call to mapaccess1: autotmp_[0-9]+$"
343         z = m2[[2]string{"x", "y"}] // ERROR "live at call to mapaccess1: autotmp_[0-9]+$"
344         printbytepointer(z)
345 }
346
347 func f23() {
348         // key temporary for two-result map access using array literal key.
349         var z *byte
350         var ok bool
351         if b {
352                 z, ok = m2[[2]string{"x", "y"}] // ERROR "live at call to mapaccess2: autotmp_[0-9]+$"
353         }
354         z, ok = m2[[2]string{"x", "y"}] // ERROR "live at call to mapaccess2: autotmp_[0-9]+$"
355         z, ok = m2[[2]string{"x", "y"}] // ERROR "live at call to mapaccess2: autotmp_[0-9]+$"
356         printbytepointer(z)
357         print(ok)
358 }
359
360 func f24() {
361         // key temporary for map access using array literal key.
362         // value temporary too.
363         if b {
364                 m2[[2]string{"x", "y"}] = nil // ERROR "live at call to mapassign: autotmp_[0-9]+$"
365         }
366         m2[[2]string{"x", "y"}] = nil // ERROR "live at call to mapassign: autotmp_[0-9]+$"
367         m2[[2]string{"x", "y"}] = nil // ERROR "live at call to mapassign: autotmp_[0-9]+$"
368 }
369
370 // defer should not cause spurious ambiguously live variables
371
372 func f25(b bool) {
373         defer g25()
374         if b {
375                 return
376         }
377         var x string
378         _ = &x
379         x = g15()      // ERROR "live at call to g15: x$"
380         printstring(x) // ERROR "live at call to printstring: x$"
381 } // ERROR "live at call to deferreturn: x$"
382
383 func g25()
384
385 // non-escaping ... slices passed to function call should die on return,
386 // so that the temporaries do not stack and do not cause ambiguously
387 // live variables.
388
389 func f26(b bool) {
390         if b {
391                 print26((*int)(nil), (*int)(nil), (*int)(nil)) // ERROR "live at call to print26: autotmp_[0-9]+$"
392         }
393         print26((*int)(nil), (*int)(nil), (*int)(nil)) // ERROR "live at call to print26: autotmp_[0-9]+$"
394         print26((*int)(nil), (*int)(nil), (*int)(nil)) // ERROR "live at call to print26: autotmp_[0-9]+$"
395         printnl()
396 }
397
398 //go:noescape
399 func print26(...interface{})
400
401 // non-escaping closures passed to function call should die on return
402
403 func f27(b bool) {
404         x := 0
405         if b {
406                 call27(func() { x++ }) // ERROR "live at call to call27: autotmp_[0-9]+$"
407         }
408         call27(func() { x++ }) // ERROR "live at call to call27: autotmp_[0-9]+$"
409         call27(func() { x++ }) // ERROR "live at call to call27: autotmp_[0-9]+$"
410         printnl()
411 }
412
413 // but defer does escape to later execution in the function
414
415 func f27defer(b bool) {
416         x := 0
417         if b {
418                 defer call27(func() { x++ }) // ERROR "live at call to deferproc: autotmp_[0-9]+$" "live at call to deferreturn: autotmp_[0-9]+$"
419         }
420         defer call27(func() { x++ }) // ERROR "f27defer: autotmp_[0-9]+ \(type struct { F uintptr; x \*int }\) is ambiguously live$" "live at call to deferproc: autotmp_[0-9]+ autotmp_[0-9]+$" "live at call to deferreturn: autotmp_[0-9]+ autotmp_[0-9]+$"
421         printnl()                    // ERROR "live at call to printnl: autotmp_[0-9]+ autotmp_[0-9]+$"
422 } // ERROR "live at call to deferreturn: autotmp_[0-9]+ autotmp_[0-9]+$"
423
424 // and newproc (go) escapes to the heap
425
426 func f27go(b bool) {
427         x := 0
428         if b {
429                 go call27(func() { x++ }) // ERROR "live at call to newobject: &x$" "live at call to newproc: &x$"
430         }
431         go call27(func() { x++ }) // ERROR "live at call to newobject: &x$"
432         printnl()
433 }
434
435 //go:noescape
436 func call27(func())
437
438 // concatstring slice should die on return
439
440 var s1, s2, s3, s4, s5, s6, s7, s8, s9, s10 string
441
442 func f28(b bool) {
443         if b {
444                 printstring(s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10) // ERROR "live at call to concatstrings: autotmp_[0-9]+$" "live at call to printstring: autotmp_[0-9]+$"
445         }
446         printstring(s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10) // ERROR "live at call to concatstrings: autotmp_[0-9]+$" "live at call to printstring: autotmp_[0-9]+$"
447         printstring(s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10) // ERROR "live at call to concatstrings: autotmp_[0-9]+$" "live at call to printstring: autotmp_[0-9]+$"
448 }
449
450 // map iterator should die on end of range loop
451
452 func f29(b bool) {
453         if b {
454                 for k := range m { // ERROR "live at call to mapiterinit: autotmp_[0-9]+$" "live at call to mapiternext: autotmp_[0-9]+$"
455                         printstring(k) // ERROR "live at call to printstring: autotmp_[0-9]+$"
456                 }
457         }
458         for k := range m { // ERROR "live at call to mapiterinit: autotmp_[0-9]+$" "live at call to mapiternext: autotmp_[0-9]+$"
459                 printstring(k) // ERROR "live at call to printstring: autotmp_[0-9]+$"
460         }
461         for k := range m { // ERROR "live at call to mapiterinit: autotmp_[0-9]+$" "live at call to mapiternext: autotmp_[0-9]+$"
462                 printstring(k) // ERROR "live at call to printstring: autotmp_[0-9]+$"
463         }
464 }
465
466 // copy of array of pointers should die at end of range loop
467
468 var ptrarr [10]*int
469
470 func f30(b bool) {
471         // two live temps during print(p):
472         // the copy of ptrarr and the internal iterator pointer.
473         if b {
474                 for _, p := range ptrarr {
475                         printintpointer(p) // ERROR "live at call to printintpointer: autotmp_[0-9]+ autotmp_[0-9]+$"
476                 }
477         }
478         for _, p := range ptrarr {
479                 printintpointer(p) // ERROR "live at call to printintpointer: autotmp_[0-9]+ autotmp_[0-9]+$"
480         }
481         for _, p := range ptrarr {
482                 printintpointer(p) // ERROR "live at call to printintpointer: autotmp_[0-9]+ autotmp_[0-9]+$"
483         }
484 }
485
486 // conversion to interface should not leave temporary behind
487
488 func f31(b1, b2, b3 bool) {
489         if b1 {
490                 g31("a") // ERROR "live at call to convT2E: autotmp_[0-9]+$" "live at call to g31: autotmp_[0-9]+$"
491         }
492         if b2 {
493                 h31("b") // ERROR "live at call to convT2E: autotmp_[0-9]+ autotmp_[0-9]+$" "live at call to h31: autotmp_[0-9]+$" "live at call to newobject: autotmp_[0-9]+$"
494         }
495         if b3 {
496                 panic("asdf") // ERROR "live at call to convT2E: autotmp_[0-9]+$" "live at call to gopanic: autotmp_[0-9]+$"
497         }
498         print(b3)
499 }
500
501 func g31(interface{})
502 func h31(...interface{})
503
504 // non-escaping partial functions passed to function call should die on return
505
506 type T32 int
507
508 func (t *T32) Inc() { // ERROR "live at entry to \(\*T32\).Inc: t$"
509         *t++
510 }
511
512 var t32 T32
513
514 func f32(b bool) {
515         if b {
516                 call32(t32.Inc) // ERROR "live at call to call32: autotmp_[0-9]+$"
517         }
518         call32(t32.Inc) // ERROR "live at call to call32: autotmp_[0-9]+$"
519         call32(t32.Inc) // ERROR "live at call to call32: autotmp_[0-9]+$"
520 }
521
522 //go:noescape
523 func call32(func())
524
525 // temporaries introduced during if conditions and && || expressions
526 // should die once the condition has been acted upon.
527
528 var m33 map[interface{}]int
529
530 func f33() {
531         if m33[nil] == 0 { // ERROR "live at call to mapaccess1: autotmp_[0-9]+$"
532                 printnl()
533                 return
534         } else {
535                 printnl()
536         }
537         printnl()
538 }
539
540 func f34() {
541         if m33[nil] == 0 { // ERROR "live at call to mapaccess1: autotmp_[0-9]+$"
542                 printnl()
543                 return
544         }
545         printnl()
546 }
547
548 func f35() {
549         if m33[nil] == 0 && m33[nil] == 0 { // ERROR "live at call to mapaccess1: autotmp_[0-9]+$"
550                 printnl()
551                 return
552         }
553         printnl()
554 }
555
556 func f36() {
557         if m33[nil] == 0 || m33[nil] == 0 { // ERROR "live at call to mapaccess1: autotmp_[0-9]+$"
558                 printnl()
559                 return
560         }
561         printnl()
562 }
563
564 func f37() {
565         if (m33[nil] == 0 || m33[nil] == 0) && m33[nil] == 0 { // ERROR "live at call to mapaccess1: autotmp_[0-9]+$"
566                 printnl()
567                 return
568         }
569         printnl()
570 }
571
572 // select temps should disappear in the case bodies
573
574 var c38 chan string
575
576 func fc38() chan string
577 func fi38(int) *string
578 func fb38() *bool
579
580 func f38(b bool) {
581         // we don't care what temps are printed on the lines with output.
582         // we care that the println lines have no live variables
583         // and therefore no output.
584         if b {
585                 select { // ERROR "live at call to newselect: autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+$" "live at call to selectgo: autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+$"
586                 case <-fc38(): // ERROR "live at call to selectrecv: autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+$"
587                         printnl()
588                 case fc38() <- *fi38(1): // ERROR "live at call to fc38: autotmp_[0-9]+$" "live at call to fi38: autotmp_[0-9]+ autotmp_[0-9]+$" "live at call to selectsend: autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+$"
589                         printnl()
590                 case *fi38(2) = <-fc38(): // ERROR "live at call to fc38: autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+$" "live at call to fi38: autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+$" "live at call to selectrecv: autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+$"
591                         printnl()
592                 case *fi38(3), *fb38() = <-fc38(): // ERROR "live at call to fb38: autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+$" "live at call to fc38: autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+$" "live at call to fi38: autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+$" "live at call to selectrecv2: autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+ autotmp_[0-9]+$"
593                         printnl()
594                 }
595                 printnl()
596         }
597         printnl()
598 }
599
600 // issue 8097: mishandling of x = x during return.
601
602 func f39() (x []int) {
603         x = []int{1}
604         printnl() // ERROR "live at call to printnl: autotmp_[0-9]+$"
605         return x
606 }
607
608 func f39a() (x []int) {
609         x = []int{1}
610         printnl() // ERROR "live at call to printnl: autotmp_[0-9]+$"
611         return
612 }
613
614 func f39b() (x [10]*int) {
615         x = [10]*int{}
616         x[0] = new(int) // ERROR "live at call to newobject: x$"
617         printnl()       // ERROR "live at call to printnl: x$"
618         return x
619 }
620
621 func f39c() (x [10]*int) {
622         x = [10]*int{}
623         x[0] = new(int) // ERROR "live at call to newobject: x$"
624         printnl()       // ERROR "live at call to printnl: x$"
625         return
626 }
627
628 // issue 8142: lost 'addrtaken' bit on inlined variables.
629 // no inlining in this test, so just checking that non-inlined works.
630
631 type T40 struct {
632         m map[int]int
633 }
634
635 func newT40() *T40 {
636         ret := T40{}
637         ret.m = make(map[int]int) // ERROR "live at call to makemap: &ret$"
638         return &ret
639 }
640
641 func bad40() {
642         t := newT40()
643         _ = t
644         printnl()
645 }
646
647 func good40() {
648         ret := T40{}
649         ret.m = make(map[int]int) // ERROR "live at call to makemap: autotmp_[0-9]+ ret$"
650         t := &ret
651         printnl() // ERROR "live at call to printnl: autotmp_[0-9]+ ret$"
652         _ = t
653 }
654
655 func ddd1(x, y *int) { // ERROR "live at entry to ddd1: x y$"
656         ddd2(x, y) // ERROR "live at call to ddd2: autotmp_[0-9]+$"
657         printnl()
658         // Note: no autotmp live at printnl.  See issue 16996.
659 }
660 func ddd2(a ...*int) { // ERROR "live at entry to ddd2: a$"
661         sink = a[0]
662 }
663
664 // issue 16016: autogenerated wrapper should have arguments live
665 type T struct{}
666
667 func (*T) Foo(ptr *int) {}
668
669 type R struct{ *T } // ERRORAUTO "live at entry to \(\*R\)\.Foo: \.this ptr" "live at entry to R\.Foo: \.this ptr"