Checks that the specified block can be encoded as a basic block. On error, returns the first invalid instruction and an error message.
(&self, block: Block)
| 308 | /// |
| 309 | /// On error, returns the first invalid instruction and an error message. |
| 310 | pub fn is_block_basic(&self, block: Block) -> Result<(), (Inst, &'static str)> { |
| 311 | let dfg = &self.dfg; |
| 312 | let inst_iter = self.layout.block_insts(block); |
| 313 | |
| 314 | // Ignore all instructions prior to the first branch. |
| 315 | let mut inst_iter = inst_iter.skip_while(|&inst| !dfg.insts[inst].opcode().is_branch()); |
| 316 | |
| 317 | if let Some(_branch) = inst_iter.next() { |
| 318 | if let Some(next) = inst_iter.next() { |
| 319 | return Err((next, "post-terminator instruction")); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | Ok(()) |
| 324 | } |
| 325 | |
| 326 | /// Returns an iterator over the blocks succeeding the given block. |
| 327 | pub fn block_successors(&self, block: Block) -> impl DoubleEndedIterator<Item = Block> + '_ { |
no test coverage detected