Tweak liveness analysis for return statements

This commit is contained in:
Nigel Tao committed 2022-01-25 14:15:32 +11:00
1 parent 6614ed0e90
commit 84d0576419
1 file changed
+5 -2
+5 -2
View File
@@ -133,6 +133,7 @@ type livenessHelper struct {
tm *t.Map tm *t.Map
vars map[t.ID]int // Maps from local variable name to livenesses index. vars map[t.ID]int // Maps from local variable name to livenesses index.
loops map[a.Loop]*loopLivenesses loops map[a.Loop]*loopLivenesses
final livenesses
} }
func (g *gen) findVars() error { func (g *gen) findVars() error {
@@ -152,14 +153,16 @@ func (g *gen) findVars() error {
} }
if f.Effect().Coroutine() { if f.Effect().Coroutine() {
h.final = make(livenesses, len(h.vars))
r := make(livenesses, len(h.vars)) r := make(livenesses, len(h.vars))
if err := h.doBlock(r, f.Body(), 0); err != nil { if err := h.doBlock(r, f.Body(), 0); err != nil {
return err return err
} }
h.final.reconcile(r)
g.currFunk.varResumables = map[t.ID]bool{} g.currFunk.varResumables = map[t.ID]bool{}
for i, v := range g.currFunk.varList { for i, v := range g.currFunk.varList {
g.currFunk.varResumables[v.Name()] = r[i] == livenessStrong g.currFunk.varResumables[v.Name()] = h.final[i] == livenessStrong
} }
} }
@@ -401,7 +404,7 @@ func (h *livenessHelper) doRet(r livenesses, n *a.Ret, depth uint32) error {
switch n.Keyword() { switch n.Keyword() {
case t.IDReturn: case t.IDReturn:
// No-op. h.final.reconcile(r)
case t.IDYield: case t.IDYield:
r.raiseNoneToWeak() r.raiseNoneToWeak()
default: default: