aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2025-01-10 17:33:26 -0800
committerKeith Randall <khr@golang.org>2025-01-12 22:49:39 -0800
commit44a6f817ea0fbeb3ba4aa398794c4e80dba13b1e (patch)
treebf8b97d89a07f0185ab42468d20b2e68887f4986 /test/codegen
parent19e923182e590ae6568c2c714f20f32512aeb3e3 (diff)
downloadgo-44a6f817ea0fbeb3ba4aa398794c4e80dba13b1e.tar.xz
cmd/compile: fix write barrier coalescing
We can't coalesce a non-WB store with a subsequent Move, as the result of the store might be the source of the move. There's a simple codegen test. Not sure how we might do a real test, as all the repro's I've come up with are very expensive and unreliable. Fixes #71228 Change-Id: If18bf181a266b9b90964e2591cd2e61a7168371c Reviewed-on: https://go-review.googlesource.com/c/go/+/642197 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/writebarrier.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/codegen/writebarrier.go b/test/codegen/writebarrier.go
index e125973e7c..e2b1399399 100644
--- a/test/codegen/writebarrier.go
+++ b/test/codegen/writebarrier.go
@@ -63,3 +63,28 @@ func trickyWriteNil(p *int, q **int) {
*q = p
}
}
+
+type S struct {
+ a, b string
+ c *int
+}
+
+var g1, g2 *int
+
+func issue71228(dst *S, ptr *int) {
+ // Make sure that the non-write-barrier write.
+ // "sp.c = ptr" happens before the large write
+ // barrier "*dst = *sp". We approximate testing
+ // that by ensuring that two global variable write
+ // barriers aren't combined.
+ _ = *dst
+ var s S
+ sp := &s
+ //amd64:`.*runtime[.]gcWriteBarrier1`
+ g1 = nil
+ sp.c = ptr // outside of any write barrier
+ //amd64:`.*runtime[.]gcWriteBarrier1`
+ g2 = nil
+ //amd64:`.*runtime[.]wbMove`
+ *dst = *sp
+}