cmd/compile: in clobberdead mode, don't clobber slots that are live for defers

There are stack slots that are kept live for defers, which are
tracked separately. Don't clobber them.

Change-Id: Ib558345758b5a4fd89c7ff8a3fe08087059add21
Reviewed-on: https://go-review.googlesource.com/c/go/+/310329
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Zhang 2021-04-14 23:36:14 -04:00
parent 4fb74e0555
commit 9fbcba6664

View file

@ -995,9 +995,11 @@ func (lv *liveness) clobber(b *ssa.Block) {
// of b.Values.
func clobber(lv *liveness, b *ssa.Block, live bitvec.BitVec) {
for i, n := range lv.vars {
if !live.Get(int32(i)) && !n.Addrtaken() {
if !live.Get(int32(i)) && !n.Addrtaken() && !n.OpenDeferSlot() && !n.IsOutputParamHeapAddr() {
// Don't clobber stack objects (address-taken). They are
// tracked dynamically.
// Also don't clobber slots that are live for defers (see
// the code setting livedefer in epilogue).
clobberVar(b, n)
}
}