diff options
author | Keith Randall <khr@golang.org> | 2023-08-11 09:29:30 -0700 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-08-17 21:19:19 +0000 |
commit | 25ec110e5164d43ae8a971928d576a94fb61862f (patch) | |
tree | 19157953236f37dd4f28423abf82d770bed8d015 | |
parent | 6634ce2f418754b504b20ee57a42390186fceb96 (diff) | |
download | go-25ec110e5164d43ae8a971928d576a94fb61862f.tar.gz go-25ec110e5164d43ae8a971928d576a94fb61862f.zip |
[release-branch.go1.21] cmd/compile: ensure empty blocks in write barriers are marked unpreemptible
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>
-rw-r--r-- | src/cmd/compile/internal/ssagen/ssa.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index 678e1ebc11..597a196ba8 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -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 |