MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / common_dominator

Method common_dominator

cranelift/codegen/src/dominator_tree/simple.rs:172–192  ·  view source on GitHub ↗

Compute the common dominator of two basic blocks. Both basic blocks are assumed to be reachable.

(&self, mut a: Block, mut b: Block)

Source from the content-addressed store, hash-verified

170 ///
171 /// Both basic blocks are assumed to be reachable.
172 fn common_dominator(&self, mut a: Block, mut b: Block) -> Block {
173 loop {
174 match self.rpo_cmp_block(a, b) {
175 Ordering::Less => {
176 // `a` comes before `b` in the RPO. Move `b` up.
177 let idom = self.nodes[b].idom.expect("Unreachable basic block?");
178 b = idom;
179 }
180 Ordering::Greater => {
181 // `b` comes before `a` in the RPO. Move `a` up.
182 let idom = self.nodes[a].idom.expect("Unreachable basic block?");
183 a = idom;
184 }
185 Ordering::Equal => break,
186 }
187 }
188
189 debug_assert_eq!(a, b, "Unreachable block passed to common_dominator?");
190
191 a
192 }
193}
194
195impl SimpleDominatorTree {

Callers 1

compute_idomMethod · 0.80

Calls 2

rpo_cmp_blockMethod · 0.80
expectMethod · 0.45

Tested by

no test coverage detected