Remove dead variables after creating the dag.

Not adding them while creating the dag completely broke the dag as
node(deadvar) always returned null. Code quality is back to where it was
before the dags rewrite.
This commit is contained in:
Bill Currie 2012-11-17 22:08:46 +09:00
parent deb5484c7e
commit dcc786b16f

View file

@ -332,10 +332,8 @@ dag_create (const flownode_t *flownode)
} }
lx = operand_label (dag, operands[0]); lx = operand_label (dag, operands[0]);
if (lx) { if (lx) {
flowvar_t *var = flow_get_var (lx->op);
lx->expr = s->expr; lx->expr = s->expr;
if (set_is_member (flownode->live_vars.out, var->number)) dagnode_attach_label (n, lx);
dagnode_attach_label (n, lx);
} }
} }
nodes = malloc (dag->num_nodes * sizeof (dagnode_t *)); nodes = malloc (dag->num_nodes * sizeof (dagnode_t *));
@ -349,6 +347,18 @@ dag_create (const flownode_t *flownode)
if (set_is_empty (dag->nodes[i]->parents)) if (set_is_empty (dag->nodes[i]->parents))
set_add (dag->roots, dag->nodes[i]->number); set_add (dag->roots, dag->nodes[i]->number);
} }
for (i = 0; i < dag->num_labels; i++) {
daglabel_t *l = dag->labels[i];
flowvar_t *var;
if (!l->op || !l->dagnode)
continue;
var = flow_get_var (l->op);
if (!var)
continue;
if (!set_is_member (flownode->live_vars.out, var->number))
set_remove (l->dagnode->identifiers, l->number);
}
return dag; return dag;
} }