Returns `true` if `a` dominates `b`. This means that every control-flow path from the function entry to `b` must go through `a`. Dominance is ill defined for unreachable blocks. This function can always determine dominance for instructions in the same block, but otherwise returns `false` if either block is unreachable. An instruction is considered to dominate itself. A block is also considered
(&self, a: A, b: B, layout: &Layout)
| 108 | /// An instruction is considered to dominate itself. |
| 109 | /// A block is also considered to dominate itself. |
| 110 | pub fn dominates<A, B>(&self, a: A, b: B, layout: &Layout) -> bool |
| 111 | where |
| 112 | A: Into<ProgramPoint>, |
| 113 | B: Into<ProgramPoint>, |
| 114 | { |
| 115 | let a = a.into(); |
| 116 | let b = b.into(); |
| 117 | match a { |
| 118 | ProgramPoint::Block(block_a) => match b { |
| 119 | ProgramPoint::Block(block_b) => self.block_dominates(block_a, block_b), |
| 120 | ProgramPoint::Inst(inst_b) => { |
| 121 | let block_b = layout |
| 122 | .inst_block(inst_b) |
| 123 | .expect("Instruction not in layout."); |
| 124 | self.block_dominates(block_a, block_b) |
| 125 | } |
| 126 | }, |
| 127 | ProgramPoint::Inst(inst_a) => { |
| 128 | let block_a: Block = layout |
| 129 | .inst_block(inst_a) |
| 130 | .expect("Instruction not in layout."); |
| 131 | match b { |
| 132 | ProgramPoint::Block(block_b) => { |
| 133 | block_a != block_b && self.block_dominates(block_a, block_b) |
| 134 | } |
| 135 | ProgramPoint::Inst(inst_b) => { |
| 136 | let block_b = layout |
| 137 | .inst_block(inst_b) |
| 138 | .expect("Instruction not in layout."); |
| 139 | if block_a == block_b { |
| 140 | layout.pp_cmp(a, b) != Ordering::Greater |
| 141 | } else { |
| 142 | self.block_dominates(block_a, block_b) |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | /// Returns `true` if `block_a` dominates `block_b`. |
| 151 | /// |
no test coverage detected