5template<
bool forward>
void DomTreeBase<forward>::create() {
7 idoms_[cfg().entry()] = cfg().entry();
10 for (
auto n : cfg().reverse_post_order().subspan(1)) {
11 for (
auto pred : cfg().preds(n)) {
12 if (cfg().index(pred) < cfg().index(n)) {
21 for (
bool todo =
true; todo;) {
24 for (
auto n : cfg().reverse_post_order().subspan(1)) {
25 const CFNode* new_idom =
nullptr;
26 for (
auto pred : cfg().preds(n)) new_idom = new_idom ? least_common_ancestor(new_idom, pred) : pred;
29 if (idom(n) != new_idom) {
36 for (
auto n : cfg().reverse_post_order().subspan(1)) children_[idom(n)].push_back(n);
41 for (
auto child : children(n)) depth(child, i + 1);
47 while (index(i) != index(j)) {
48 while (index(i) < index(j)) j = idom(j);
49 while (index(j) < index(i)) i = idom(i);
int depth(const CFNode *n) const
const CFNode * least_common_ancestor(const CFNode *i, const CFNode *j) const
Returns the least common ancestor of i and j.