| 1062 | } |
| 1063 | |
| 1064 | bool DomTree::dominates(const BasicBlock *a, const BasicBlock *b) const { |
| 1065 | auto *dom_a = &doms.at(a); |
| 1066 | auto *dom_b = &doms.at(b); |
| 1067 | // walk up the dominator tree of 'b' until we find 'a' or the function's entry |
| 1068 | while (true) { |
| 1069 | if (dom_b == dom_a) |
| 1070 | return true; |
| 1071 | if (dom_b == dom_b->dominator) |
| 1072 | break; |
| 1073 | dom_b = dom_b->dominator; |
| 1074 | } |
| 1075 | return false; |
| 1076 | } |
| 1077 | |
| 1078 | void DomTree::printDot(ostream &os) const { |
| 1079 | os << "digraph {\n" |