mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: find last StoreWB explicitly
In writebarrier phase, a chain of StoreWBs is rewritten to branchy code to invoke write barriers, and the last store in the chain is spliced into a Phi op to join the memory of the two branches. We must find the last store explicitly, since the values are not scheduled and they may not come in dependency order. Fixes #18169. Change-Id: If547e3c562ef0669bc5622c1bb711904dc36314d Reviewed-on: https://go-review.googlesource.com/33915 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
af67f7de3f
commit
ed0b232cdc
4 changed files with 82 additions and 16 deletions
29
src/cmd/compile/internal/ssa/writebarrier_test.go
Normal file
29
src/cmd/compile/internal/ssa/writebarrier_test.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package ssa
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestWriteBarrierStoreOrder(t *testing.T) {
|
||||
// Make sure writebarrier phase works even StoreWB ops are not in dependency order
|
||||
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),
|
||||
Valu("v", OpConstNil, ptrType, 0, nil),
|
||||
Valu("addr1", OpAddr, ptrType, 0, nil, "sb"),
|
||||
Valu("wb2", OpStoreWB, TypeMem, 8, nil, "addr1", "v", "wb1"),
|
||||
Valu("wb1", OpStoreWB, TypeMem, 8, nil, "addr1", "v", "start"), // wb1 and wb2 are out of order
|
||||
Goto("exit")),
|
||||
Bloc("exit",
|
||||
Exit("wb2")))
|
||||
|
||||
CheckFunc(fun.f)
|
||||
writebarrier(fun.f)
|
||||
CheckFunc(fun.f)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue