1
0
mirror of https://github.com/golang/go synced 2024-11-12 01:10:21 -07:00

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>
This commit is contained in:
Josh Bleecher Snyder 2017-04-27 13:15:24 -07:00
parent cf1b323fc8
commit e5c9358fe2
2 changed files with 26 additions and 15 deletions

View File

@ -348,9 +348,9 @@ var passes = [...]pass{
{name: "late opt", fn: opt, required: true}, // TODO: split required rules and optimizing rules
{name: "generic deadcode", fn: deadcode},
{name: "check bce", fn: checkbce},
{name: "writebarrier", fn: writebarrier, required: true}, // expand write barrier ops
{name: "fuse", fn: fuse},
{name: "dse", fn: dse},
{name: "writebarrier", fn: writebarrier, required: true}, // expand write barrier ops
{name: "insert resched checks", fn: insertLoopReschedChecks,
disabled: objabi.Preemptibleloops_enabled == 0}, // insert resched checks in loops.
{name: "tighten", fn: tighten}, // move values closer to their uses

View File

@ -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"
}