Commit d75925d6 authored by Cherry Zhang's avatar Cherry Zhang

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/36940Reviewed-by: default avatarDavid Chase <drchase@google.com>
parent 1b853006
...@@ -27,3 +27,27 @@ func TestWriteBarrierStoreOrder(t *testing.T) { ...@@ -27,3 +27,27 @@ func TestWriteBarrierStoreOrder(t *testing.T) {
writebarrier(fun.f) writebarrier(fun.f)
CheckFunc(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)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment