aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
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
+}