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.
This commit is contained in:
Bill Currie 2012-12-12 23:15:55 +09:00
parent 95c249e8b9
commit 028b19888f

View file

@ -388,6 +388,15 @@ dagnode_attach_label (dagnode_t *n, daglabel_t *l)
set_add (n->identifiers, l->number); 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 static void
dag_remove_dead_vars (dag_t *dag, set_t *live_vars) 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; continue;
if (set_is_member (dag->flownode->global_vars, var->number)) if (set_is_member (dag->flownode->global_vars, var->number))
continue; 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)) if (!set_is_member (live_vars, var->number))
set_remove (l->dagnode->identifiers, l->number); set_remove (l->dagnode->identifiers, l->number);
} }