static void checkreach(Cfg *cfg) { Bitset *reach, *kill; size_t i, j, k; Reaching *r; Node *n, *m; Bb *bb; r = reaching(cfg); // dumpcfg(cfg, stdout); for (i = 0; i < cfg->nbb; i++) { bb = cfg->bb[i]; if (!bb) continue; reach = bsdup(r->in[i]); kill = mkbs(); for (j = 0; j < bb->nnl; j++) { n = bb->nl[j]; if (exprop(n) == Oundef) { bsput(reach, n->nid); } else { m = assignee(n); if (m) for (k = 0; k < r->ndefs[m->expr.did]; k++) bsput(kill, r->defs[m->expr.did][k]); checkundef(n, r, reach, kill); } } bsfree(reach); bsfree(kill); } }
static void genkill(Bb *bb, size_t **defs, size_t *ndefs, Bitset *gen, Bitset *kill) { size_t i, j, did; Node *n; for (i = 0; i < bb->nnl; i++) { n = assignee(bb->nl[i]); if (!n) continue; did = n->expr.did; for (j = 0; j < ndefs[did]; j++) { bsput(kill, defs[did][j]); bsdel(gen, defs[did][j]); } bsput(gen, bb->nl[i]->nid); bsdel(kill, bb->nl[i]->nid); } }
static void collectdefs(Cfg *cfg, size_t **defs, size_t *ndefs) { size_t i, j, did; Node *n; Bb *bb; for (i = 0; i < cfg->nbb; i++) { bb = cfg->bb[i]; if (!bb) continue; for (j = 0; j < bb->nnl; j++) { n = assignee(bb->nl[j]); if (n && exprop(n) == Ovar) { did = n->expr.did; ndefs[did]++; defs[did] = xrealloc(defs[did], ndefs[did] * sizeof(size_t)); defs[did][ndefs[did] - 1] = bb->nl[j]->nid; } } } }