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

Method dominates

cranelift/codegen/src/dominator_tree.rs:251–289  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

249 /// An instruction is considered to dominate itself.
250 /// A block is also considered to dominate itself.
251 pub fn dominates<A, B>(&self, a: A, b: B, layout: &Layout) -> bool
252 where
253 A: Into<ProgramPoint>,
254 B: Into<ProgramPoint>,
255 {
256 let a = a.into();
257 let b = b.into();
258 match a {
259 ProgramPoint::Block(block_a) => match b {
260 ProgramPoint::Block(block_b) => self.block_dominates(block_a, block_b),
261 ProgramPoint::Inst(inst_b) => {
262 let block_b = layout
263 .inst_block(inst_b)
264 .expect("Instruction not in layout.");
265 self.block_dominates(block_a, block_b)
266 }
267 },
268 ProgramPoint::Inst(inst_a) => {
269 let block_a: Block = layout
270 .inst_block(inst_a)
271 .expect("Instruction not in layout.");
272 match b {
273 ProgramPoint::Block(block_b) => {
274 block_a != block_b && self.block_dominates(block_a, block_b)
275 }
276 ProgramPoint::Inst(inst_b) => {
277 let block_b = layout
278 .inst_block(inst_b)
279 .expect("Instruction not in layout.");
280 if block_a == block_b {
281 layout.pp_cmp(a, b) != Ordering::Greater
282 } else {
283 self.block_dominates(block_a, block_b)
284 }
285 }
286 }
287 }
288 }
289 }
290
291 /// Returns `true` if `block_a` dominates `block_b`.
292 ///

Callers 1

process_instMethod · 0.45

Calls 4

inst_blockMethod · 0.80
pp_cmpMethod · 0.80
block_dominatesMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected