+ for _ in 0..self.u.int_in_range(0..=10)? {
+ self.new_inst_in_last_block(InstKind::Normal, vec![], self.u.arbitrary()?);
+ }
+ let mut succs_and_params = BTreeMap::default();
+ let succ_range = BlockIdx::ENTRY_BLOCK.get() as u16..=(block_count - 1);
+ if !succ_range.is_empty() {
+ for i in 0..self.u.int_in_range(0..=3usize)? {
+ if i > succ_range.len() {
+ break;
+ }
+ let succ = BlockIdx::new(self.u.int_in_range(succ_range)?.into());
+ succs_and_params.insert(succ, vec![]);
+ }
+ }
+ let mut operands = vec![];
+ for _ in 0..self.u.int_in_range(0..=5)? {
+ operands.push(Operand {
+ ssa_val: todo!(),
+ kind_and_constraint: todo!(),
+ stage: todo!(),
+ });
+ }
+ self.new_inst_in_last_block(
+ InstKind::BlockTerm(BlockTermInstKind { succs_and_params }),
+ operands,
+ self.u.arbitrary()?,
+ );
+ }
+ let dominators = dominators::simple_fast(&self.func, BlockIdx::ENTRY_BLOCK);
+ for block_idx in 0..self.func.blocks.len() {
+ let block_idx = BlockIdx::new(block_idx);
+ self.func.blocks[block_idx].immediate_dominator =
+ dominators.immediate_dominator(block_idx);
+ let term_idx = self
+ .func
+ .try_get_block_term_inst_idx(block_idx)
+ .expect("known to have block term inst");
+ let successors = self.func.insts[term_idx]
+ .kind
+ .block_term()
+ .expect("known to have block term inst")
+ .succs_and_params
+ .keys()
+ .copied();
+ for succ in successors {
+ self.func.blocks[succ].preds.insert(block_idx);
+ }
+ for inst_idx in self.func.blocks[block_idx].insts {
+ let inst = &mut self.func.insts[inst_idx];
+ match &mut inst.kind {
+ InstKind::Normal => {
+ let _;
+ todo!()
+ }
+ InstKind::Copy(_) => unreachable!(),
+ InstKind::BlockTerm(block_term_inst_kind) => {
+ for (&succ, params) in &mut block_term_inst_kind.succs_and_params {}
+ }
+ }
+ }