diff options
author | Austin Clements <austin@google.com> | 2016-03-16 18:22:58 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2016-03-16 22:42:45 +0000 |
commit | 3e54ca9a4624fda0bcd76192aa529e826ef12b4f (patch) | |
tree | 6a36221aef31071d3b57f24c5832c9d4e94fc170 /test/writebarrier.go | |
parent | 4e75932cf7148c6ed10f93bbc07a79a7f89e8bd2 (diff) | |
download | go-3e54ca9a4624fda0bcd76192aa529e826ef12b4f.tar.gz go-3e54ca9a4624fda0bcd76192aa529e826ef12b4f.zip |
cmd/compile: omit write barrier when assigning global function
Currently we generate write barriers when the right side of an
assignment is a global function. This doesn't fall into the existing
case of storing an address of a global because we haven't lowered the
function to a pointer yet.
This write barrier is unnecessary, so eliminate it.
Fixes #13901.
Change-Id: Ibc10e00a8803db0fd75224b66ab94c3737842a79
Reviewed-on: https://go-review.googlesource.com/20772
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/writebarrier.go')
-rw-r--r-- | test/writebarrier.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/writebarrier.go b/test/writebarrier.go index dcd20a0225..e591eaab32 100644 --- a/test/writebarrier.go +++ b/test/writebarrier.go @@ -158,3 +158,13 @@ func t1(i interface{}) **int { } return nil } + +type T17 struct { + f func(*T17) +} + +func f17(x *T17) { + // See golang.org/issue/13901 + x.f = f17 // no barrier + x.f = func(y *T17) { *y = *x } // ERROR "write barrier" +} |