1
0
mirror of https://github.com/golang/go synced 2024-11-18 04:04:49 -07:00

cmd/compile: add a test for writebarrier pass with single-block loop

The old writebarrier implementation fails to handle single-block
loop where a memory Phi value depends on the write barrier store
in the same block. The new implementation (CL 36834) doesn't have
this problem. Add a test to ensure it.

Fix #19067.

Change-Id: Iab13c6817edc12be8a048d18699b4450fa7ed712
Reviewed-on: https://go-review.googlesource.com/36940
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Cherry Zhang 2017-02-13 21:27:53 -05:00
parent 1b85300602
commit d75925d6ba

View File

@ -27,3 +27,27 @@ func TestWriteBarrierStoreOrder(t *testing.T) {
writebarrier(fun.f)
CheckFunc(fun.f)
}
func TestWriteBarrierPhi(t *testing.T) {
// Make sure writebarrier phase works for single-block loop, where
// a Phi op takes the store in the same block as argument.
// See issue #19067.
c := testConfig(t)
ptrType := &TypeImpl{Size_: 8, Ptr: true, Name: "testptr"} // dummy for testing
fun := Fun(c, "entry",
Bloc("entry",
Valu("start", OpInitMem, TypeMem, 0, nil),
Valu("sb", OpSB, TypeInvalid, 0, nil),
Valu("sp", OpSP, TypeInvalid, 0, nil),
Goto("loop")),
Bloc("loop",
Valu("phi", OpPhi, TypeMem, 0, nil, "start", "wb"),
Valu("v", OpConstNil, ptrType, 0, nil),
Valu("addr", OpAddr, ptrType, 0, nil, "sb"),
Valu("wb", OpStore, TypeMem, 8, ptrType, "addr", "v", "phi"), // has write barrier
Goto("loop")))
CheckFunc(fun.f)
writebarrier(fun.f)
CheckFunc(fun.f)
}