Commit e95989c1 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile/internal/gc: remove unnecessary bitvector in plive

In livenessepilogue, if we save liveness information for instructions
before updating liveout, we can avoid an extra bitvector temporary and
some extra copying around.

Passes toolstash-check -all.

Change-Id: I10d5803167ef3eba2e9e95094adc7e3d33929cc7
Reviewed-on: https://go-review.googlesource.com/38408Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent d8ed449d
...@@ -583,7 +583,6 @@ func livenesssolve(lv *Liveness) { ...@@ -583,7 +583,6 @@ func livenesssolve(lv *Liveness) {
// variables at each safe point locations. // variables at each safe point locations.
func livenessepilogue(lv *Liveness) { func livenessepilogue(lv *Liveness) {
nvars := int32(len(lv.vars)) nvars := int32(len(lv.vars))
livein := bvalloc(nvars)
liveout := bvalloc(nvars) liveout := bvalloc(nvars)
any := bvalloc(nvars) any := bvalloc(nvars)
all := bvalloc(nvars) all := bvalloc(nvars)
...@@ -655,9 +654,7 @@ func livenessepilogue(lv *Liveness) { ...@@ -655,9 +654,7 @@ func livenessepilogue(lv *Liveness) {
// Annotate ambiguously live variables so that they can // Annotate ambiguously live variables so that they can
// be zeroed at function entry. // be zeroed at function entry.
// livein and liveout are dead here and used as temporaries. // liveout is dead here and used as a temporary.
livein.Clear()
liveout.AndNot(any, all) liveout.AndNot(any, all)
if !liveout.IsEmpty() { if !liveout.IsEmpty() {
for pos := int32(0); pos < liveout.n; pos++ { for pos := int32(0); pos < liveout.n; pos++ {
...@@ -688,51 +685,44 @@ func livenessepilogue(lv *Liveness) { ...@@ -688,51 +685,44 @@ func livenessepilogue(lv *Liveness) {
be := lv.blockEffects(b) be := lv.blockEffects(b)
// walk backward, emit pcdata and populate the maps // walk backward, emit pcdata and populate the maps
pos := int32(be.lastbitmapindex) index := int32(be.lastbitmapindex)
if pos < 0 { if index < 0 {
// the first block we encounter should have the ATEXT so // the first block we encounter should have the ATEXT so
// at no point should pos ever be less than zero. // at no point should pos ever be less than zero.
Fatalf("livenessepilogue") Fatalf("livenessepilogue")
} }
livein.Copy(be.liveout) liveout.Copy(be.liveout)
for i := len(b.Values) - 1; i >= 0; i-- { for i := len(b.Values) - 1; i >= 0; i-- {
v := b.Values[i] v := b.Values[i]
// Propagate liveness information if issafepoint(v) {
{ // Found an interesting instruction, record the
pos, e := lv.valueEffects(v) // corresponding liveness information.
liveout.Copy(livein)
if e&varkill != 0 {
livein.Unset(pos)
}
if e&uevar != 0 {
livein.Set(pos)
}
}
if !issafepoint(v) { live := lv.livevars[index]
continue live.Or(live, liveout)
live.Or(live, livedefer) // only for non-entry safe points
index--
} }
// Found an interesting instruction, record the // Update liveness information.
// corresponding liveness information. pos, e := lv.valueEffects(v)
if e&varkill != 0 {
// Record live variables. liveout.Unset(pos)
live := lv.livevars[pos] }
live.Or(live, liveout) if e&uevar != 0 {
live.Or(live, livedefer) // only for non-entry safe points liveout.Set(pos)
}
pos--
} }
if b == lv.f.Entry { if b == lv.f.Entry {
if pos != 0 { if index != 0 {
Fatalf("bad pos for entry point: %v", pos) Fatalf("bad index for entry point: %v", index)
} }
// Record live variables. // Record live variables.
live := lv.livevars[pos] live := lv.livevars[index]
live.Or(live, liveout) live.Or(live, liveout)
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment