]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[release-branch.go1.21] cmd/compile: ensure empty blocks in write barriers are marked...
authorKeith Randall <khr@golang.org>
Fri, 11 Aug 2023 16:29:30 +0000 (09:29 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 17 Aug 2023 21:19:19 +0000 (21:19 +0000)
Fixes #61958

Change-Id: I242ab77ad2f1ea1dad2d14ef756fa92f9378429f
Reviewed-on: https://go-review.googlesource.com/c/go/+/518755
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/ssagen/ssa.go

index 678e1ebc11e96ba7869d6acc6ed7a55e2c5674a3..597a196ba8c45b20b0164fa458ea0da6eb565b70 100644 (file)
@@ -7083,8 +7083,21 @@ func genssa(f *ssa.Func, pp *objw.Progs) {
                // for an empty block this will be used for its control
                // instruction. We won't use the actual liveness map on a
                // control instruction. Just mark it something that is
-               // preemptible, unless this function is "all unsafe".
-               s.pp.NextLive = objw.LivenessIndex{StackMapIndex: -1, IsUnsafePoint: liveness.IsUnsafe(f)}
+               // preemptible, unless this function is "all unsafe", or
+               // the empty block is in a write barrier.
+               unsafe := liveness.IsUnsafe(f)
+               if b.Kind == ssa.BlockPlain {
+                       // Empty blocks that are part of write barriers need
+                       // to have their control instructions marked unsafe.
+                       c := b.Succs[0].Block()
+                       for _, v := range c.Values {
+                               if v.Op == ssa.OpWBend {
+                                       unsafe = true
+                                       break
+                               }
+                       }
+               }
+               s.pp.NextLive = objw.LivenessIndex{StackMapIndex: -1, IsUnsafePoint: unsafe}
 
                if idx, ok := argLiveBlockMap[b.ID]; ok && idx != argLiveIdx {
                        argLiveIdx = idx