]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: ensure write barrier branches get marked uninterruptible
authorKeith Randall <khr@golang.org>
Wed, 9 Aug 2023 22:49:48 +0000 (15:49 -0700)
committerKeith Randall <khr@golang.org>
Thu, 10 Aug 2023 21:54:31 +0000 (21:54 +0000)
The branch itself can't be marked, so we ensure we mark the last
ssa.Value in the block as uninterruptible, because that's where the
branch ends up getting its uninterruptibility from.

This is somewhat conservative, as we're marking an instruction as
uninterruptible that doesn't need to be. But it is an easy fix.

TODO: figure out a test

Change-Id: Icd314f0bbdce8f80019bafb9e861baca4e7ecbb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/518055
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/cmd/compile/internal/liveness/plive.go

index 2d05ed1a4a49013bbcf7c707e788567d0543862f..e240ba6736b7bfc8c7f74d6a93260ea5597ed479 100644 (file)
@@ -558,8 +558,11 @@ func (lv *liveness) markUnsafePoints() {
 
                        // Mark everything after the load unsafe.
                        found := false
-                       for _, v := range decisionBlock.Values {
-                               if found {
+                       for i, v := range decisionBlock.Values {
+                               if found || i == len(decisionBlock.Values)-1 {
+                                       // Note: we need at least one instruction marked so that
+                                       // the branch instruction at the end of the block also
+                                       // gets marked.
                                        lv.unsafePoints.Set(int32(v.ID))
                                }
                                found = found || v == load