| 20 | } |
| 21 | |
| 22 | bool GcnDominatorTree::dominates(GcnCfgVertex u, GcnCfgVertex v) const |
| 23 | { |
| 24 | bool result = false; |
| 25 | |
| 26 | // Post traverse the dom tree from v to entry, |
| 27 | // if we can find a node equal to u, then u dominates v. |
| 28 | auto node = v; |
| 29 | while (node != GcnControlFlowGraph::null_vertex()) |
| 30 | { |
| 31 | // Note that a vertex dominates itself by definition. |
| 32 | if (u == node) |
| 33 | { |
| 34 | result = true; |
| 35 | break; |
| 36 | } |
| 37 | |
| 38 | // Get immediate dominator of node |
| 39 | node = m_domMap[node]; |
| 40 | } |
| 41 | return result; |
| 42 | } |
| 43 | |
| 44 | void GcnDominatorTree::buildDominatorMap() |
| 45 | { |