From 028b19888f0c394e4fdc8e769d01fec469a508e2 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 12 Dec 2012 23:15:55 +0900 Subject: [PATCH] Check aliases for liveness when removing dead vars. The live var flow analysis doesn't check for aliases. Rather than changing it to check for aliases (which might break uninitialized var analysis, as it uses "use" from the live var analysis), make dag_remove_dead_vars do the check. Fixes the misplaced text in the menus. --- tools/qfcc/source/dags.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/qfcc/source/dags.c b/tools/qfcc/source/dags.c index 491bae60d..d84bd6f8f 100644 --- a/tools/qfcc/source/dags.c +++ b/tools/qfcc/source/dags.c @@ -388,6 +388,15 @@ dagnode_attach_label (dagnode_t *n, daglabel_t *l) set_add (n->identifiers, l->number); } +static int +dag_alias_live (def_t *def, void *_live_vars) +{ + set_t *live_vars = (set_t *) _live_vars; + if (!def->flowvar) + return 0; + return set_is_member (live_vars, def->flowvar->number); +} + static void dag_remove_dead_vars (dag_t *dag, set_t *live_vars) { @@ -406,6 +415,9 @@ dag_remove_dead_vars (dag_t *dag, set_t *live_vars) continue; if (set_is_member (dag->flownode->global_vars, var->number)) continue; + if (l->op->op_type == op_def + && def_visit_all (l->op->o.def, 1, dag_alias_live, live_vars)) + continue; if (!set_is_member (live_vars, var->number)) set_remove (l->dagnode->identifiers, l->number); }