mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-29 23:52:22 +00:00
[qfcc] Use ud- and du-chains for block live analysis
The ud- and du-chains include known side-effects of the instructions and thus depict a more accurate view of what operands an instruction uses or defines. Fixes the arraylife2 test.
This commit is contained in:
parent
a5ed154cfe
commit
fb1b3e0869
1 changed files with 20 additions and 1 deletions
|
@ -1237,12 +1237,30 @@ flow_live_vars (flowgraph_t *graph)
|
||||||
|
|
||||||
// first, calculate use and def for each block, and initialize the in and
|
// first, calculate use and def for each block, and initialize the in and
|
||||||
// out sets.
|
// out sets.
|
||||||
|
set_t *node_statements = set_new ();
|
||||||
for (i = 0; i < graph->num_nodes; i++) {
|
for (i = 0; i < graph->num_nodes; i++) {
|
||||||
node = graph->nodes[i];
|
node = graph->nodes[i];
|
||||||
use = set_new ();
|
use = set_new ();
|
||||||
def = set_new ();
|
def = set_new ();
|
||||||
|
set_empty (node_statements);
|
||||||
for (st = node->sblock->statements; st; st = st->next) {
|
for (st = node->sblock->statements; st; st = st->next) {
|
||||||
flow_analyze_statement (st, stuse, stdef, 0, 0);
|
set_add (node_statements, st->number);
|
||||||
|
}
|
||||||
|
for (st = node->sblock->statements; st; st = st->next) {
|
||||||
|
set_empty (stuse);
|
||||||
|
set_empty (stdef);
|
||||||
|
for (int i = 0; i < st->num_use; i++) {
|
||||||
|
udchain_t ud = graph->func->ud_chains[st->first_use + i];
|
||||||
|
if (!set_is_member (node_statements, ud.defst)) {
|
||||||
|
set_add (stuse, ud.var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < st->num_def; i++) {
|
||||||
|
udchain_t du = graph->func->du_chains[st->first_def + i];
|
||||||
|
if (!set_is_member (node_statements, du.usest)) {
|
||||||
|
set_add (stdef, du.var);
|
||||||
|
}
|
||||||
|
}
|
||||||
live_set_use (stuse, use, def);
|
live_set_use (stuse, use, def);
|
||||||
live_set_def (stdef, use, def);
|
live_set_def (stdef, use, def);
|
||||||
}
|
}
|
||||||
|
@ -1251,6 +1269,7 @@ flow_live_vars (flowgraph_t *graph)
|
||||||
node->live_vars.in = set_new ();
|
node->live_vars.in = set_new ();
|
||||||
node->live_vars.out = set_new ();
|
node->live_vars.out = set_new ();
|
||||||
}
|
}
|
||||||
|
set_delete (node_statements);
|
||||||
// create in for the exit dummy block using the global vars used by the
|
// create in for the exit dummy block using the global vars used by the
|
||||||
// function
|
// function
|
||||||
use = set_new ();
|
use = set_new ();
|
||||||
|
|
Loading…
Reference in a new issue