Skip to content

Instantly share code, notes, and snippets.

@bryant
Forked from anonymous/-
Last active November 19, 2017 06:22
Show Gist options
  • Save bryant/386ede314223f21279162c9be301e5f6 to your computer and use it in GitHub Desktop.
Save bryant/386ede314223f21279162c9be301e5f6 to your computer and use it in GitHub Desktop.
GCC's linear-time DF calculation, pasted by Dan Berlin.
static void
compute_dominance_frontiers_1 (bitmap_head *frontiers)
{
edge p;
edge_iterator ei;
basic_block b;
FOR_EACH_BB_FN (b, cfun)
{
if (EDGE_COUNT (b->preds) >= 2)
{
FOR_EACH_EDGE (p, ei, b->preds)
{
basic_block runner = p->src;
basic_block domsb;
if (runner == ENTRY_BLOCK_PTR_FOR_FN (cfun))
continue;
domsb = get_immediate_dominator (CDI_DOMINATORS, b);
while (runner != domsb)
{
if (!bitmap_set_bit (&frontiers[runner->index],
b->index))
break;
runner = get_immediate_dominator (CDI_DOMINATORS,
runner);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment