khr a51e4cc9ce cmd/compile: zero return parameters earlier
Move the zeroing of results earlier.  In particular, they need to
come before any move-to-heap operations, as those require allocation.
Those allocations are points at which the GC can see the uninitialized
result slots.

For the function:

func f() (x, y, z *int) {
  defer(){}()
  escape(&y)
  return
}

We used to generate code like this:

x = nil
y = nil
&y = new(int)
z = nil

Now we will generate:

x = nil
y = nil
z = nil
&y = new(int)

Since the fix for #18860, the return slots are always live if there
is a defer, so the former ordering allowed the GC to see junk
in the z slot.

Fixes #19078

Change-Id: I71554ae437549725bb79e13b2c100b2911d47ed4
Reviewed-on: https://go-review.googlesource.com/38133
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-13 19:39:15 +00:00
..
2016-04-03 17:03:15 +00:00
2012-11-08 09:04:27 -08:00
2012-09-10 13:03:07 -07:00
2012-02-16 23:48:57 -05:00
2015-01-29 13:07:30 +00:00
2012-07-01 21:59:50 +04:00
2013-12-12 17:18:12 -08:00
2012-09-28 08:30:30 -07:00
2015-07-11 14:36:33 +00:00
2015-07-11 14:36:33 +00:00
2012-10-07 21:52:57 +02:00
2012-02-19 14:28:53 +11:00
2012-02-18 21:18:13 -08:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2012-02-24 13:17:26 +11:00
2012-02-23 18:47:26 +11:00
2012-02-23 18:47:26 +11:00
2012-02-23 18:47:26 +11:00
2012-02-23 18:47:26 +11:00
2012-02-23 18:47:26 +11:00
2012-02-23 18:47:26 +11:00
2012-02-23 18:47:26 +11:00
2012-02-23 18:47:26 +11:00
2015-12-17 23:36:13 +00:00
2017-03-06 15:05:42 +00:00
2012-02-23 18:47:26 +11:00
2014-10-27 18:59:02 -04:00
2012-02-23 18:47:26 +11:00
2013-02-11 18:20:52 -05:00
2016-12-15 22:43:28 +00:00
2012-02-24 10:30:39 +11:00
2012-02-24 10:30:39 +11:00
2012-02-24 13:17:26 +11:00
2012-02-24 11:48:19 +11:00
2014-01-29 09:28:23 +01:00
2012-02-24 11:48:19 +11:00
2012-02-24 11:48:19 +11:00
2012-02-24 11:48:19 +11:00
2012-02-24 11:48:19 +11:00
2012-02-24 11:48:19 +11:00
2012-02-24 11:48:19 +11:00