From dcc786b16fd7ea39333968e2b04f922b215d3722 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 17 Nov 2012 22:08:46 +0900 Subject: [PATCH] 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. --- tools/qfcc/source/dags.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/qfcc/source/dags.c b/tools/qfcc/source/dags.c index ed3cfb776..f64b38864 100644 --- a/tools/qfcc/source/dags.c +++ b/tools/qfcc/source/dags.c @@ -332,10 +332,8 @@ dag_create (const flownode_t *flownode) } lx = operand_label (dag, operands[0]); if (lx) { - flowvar_t *var = flow_get_var (lx->op); 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 *)); @@ -349,6 +347,18 @@ dag_create (const flownode_t *flownode) if (set_is_empty (dag->nodes[i]->parents)) 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; }