aboutsummaryrefslogtreecommitdiff
path: root/test/writebarrier.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2017-04-27 13:15:24 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2017-04-29 16:37:02 +0000
commite5c9358fe2ff1d0c1e9a76e5e5d0e7d65c308da6 (patch)
treecb9d4d43447bd337f8c1b295243f37f42d3368e3 /test/writebarrier.go
parentcf1b323fc891664b2c72726db51933b6f75f5dac (diff)
downloadgo-e5c9358fe2ff1d0c1e9a76e5e5d0e7d65c308da6.tar.gz
go-e5c9358fe2ff1d0c1e9a76e5e5d0e7d65c308da6.zip
cmd/compile: move writebarrier pass after dse
This avoids generating writeBarrier.enabled blocks for dead stores. Change-Id: Ib11d8e2ba952f3f1f01d16776e40a7200a7683cf Reviewed-on: https://go-review.googlesource.com/42012 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'test/writebarrier.go')
-rw-r--r--test/writebarrier.go39
1 files changed, 25 insertions, 14 deletions
diff --git a/test/writebarrier.go b/test/writebarrier.go
index 13f7b54608..f3149e1b49 100644
--- a/test/writebarrier.go
+++ b/test/writebarrier.go
@@ -11,14 +11,14 @@ package p
import "unsafe"
func f(x **byte, y *byte) {
- *x = y // ERROR "write barrier"
+ *x = y // no barrier (dead store)
z := y // no barrier
*x = z // ERROR "write barrier"
}
func f1(x *[]byte, y []byte) {
- *x = y // ERROR "write barrier"
+ *x = y // no barrier (dead store)
z := y // no barrier
*x = z // ERROR "write barrier"
@@ -32,21 +32,21 @@ func f1a(x *[]byte, y *[]byte) {
}
func f2(x *interface{}, y interface{}) {
- *x = y // ERROR "write barrier"
+ *x = y // no barrier (dead store)
z := y // no barrier
*x = z // ERROR "write barrier"
}
func f2a(x *interface{}, y *interface{}) {
- *x = *y // ERROR "write barrier"
+ *x = *y // no barrier (dead store)
z := y // no barrier
*x = z // ERROR "write barrier"
}
func f3(x *string, y string) {
- *x = y // ERROR "write barrier"
+ *x = y // no barrier (dead store)
z := y // no barrier
*x = z // ERROR "write barrier"
@@ -204,12 +204,18 @@ var y21 struct {
}
var z21 int
-func f21(x *int) {
- // Global -> heap pointer updates must have write barriers.
- x21 = x // ERROR "write barrier"
- y21.x = x // ERROR "write barrier"
- x21 = &z21 // ERROR "write barrier"
- y21.x = &z21 // ERROR "write barrier"
+// f21x: Global -> heap pointer updates must have write barriers.
+func f21a(x *int) {
+ x21 = x // ERROR "write barrier"
+ y21.x = x // ERROR "write barrier"
+}
+
+func f21b(x *int) {
+ x21 = &z21 // ERROR "write barrier"
+ y21.x = &z21 // ERROR "write barrier"
+}
+
+func f21c(x *int) {
y21 = struct{ x *int }{x} // ERROR "write barrier"
}
@@ -229,10 +235,15 @@ type T23 struct {
var t23 T23
var i23 int
-func f23() {
- // zeroing global needs write barrier for the hybrid barrier.
+// f23x: zeroing global needs write barrier for the hybrid barrier.
+func f23a() {
t23 = T23{} // ERROR "write barrier"
// also test partial assignments
- t23 = T23{a: 1} // ERROR "write barrier"
+ t23 = T23{a: 1} // ERROR "write barrier"
+}
+
+func f23b() {
+ t23 = T23{} // no barrier (dead store)
+ // also test partial assignments
t23 = T23{p: &i23} // ERROR "write barrier"
}