service/method-inliner/CFGInliner.cpp
// Insert a new block if needed to make `it` the first instruction of a block.
// return the block that should be run before the callee and the block that
// should contain the callsite as a pair.
Insert a new block if needed to make `it` the first instruction of a block.
return the block that should be run before the callee and the block that
should contain the callsite as a pair.
Insert a new block if needed to make ` it ` the first instruction of a block . return the block that should be run before the callee and the block that should contain the callsite as a pair .
std::pair<Block*, Block*> CFGInliner::maybe_split_block_before(
    ControlFlowGraph* caller, const InstructionIterator& it) {
  always_assert(caller->editable());
  always_assert(!it.block()->empty());
  const IRList::iterator& raw_it = it.unwrap();
  Block* old_block = it.block();
  auto preds = old_block->preds();
  if (raw_it == old_block->get_first_insn() && preds.size() == 1) {
    Block* single_pred_block = preds.at(0)->src();
    if (single_pred_block->succs().size() == 1) {
      return std::make_pair(single_pred_block, old_block);
    }
  }
  auto dummy_end_instruction = new IRInstruction(OPCODE_NOP);
  caller->insert_before(it, dummy_end_instruction);
  auto new_blk = caller->split_block(
      old_block, caller->find_insn(dummy_end_instruction).unwrap());
  return std::make_pair(old_block, new_blk);
}
std :: pair < Block * , Block * > CFGInliner :: maybe_split_block_before ( ControlFlowGraph * caller , const InstructionIterator & it ) { always_assert ( caller -> editable ( ) ) ; always_assert ( ! it . block ( ) -> empty ( ) ) ; const IRList :: iterator & raw_it = it . unwrap ( ) ; Block * old_block = it . block ( ) ; auto preds = old_block -> preds ( ) ; if ( raw_it == old_block -> get_first_insn ( ) && preds . size ( ) == 1 ) { Block * single_pred_block = preds . at ( 0 ) -> src ( ) ; if ( single_pred_block -> succs ( ) . size ( ) == 1 ) { return std :: make_pair ( single_pred_block , old_block ) ; } } auto dummy_end_instruction = new IRInstruction ( OPCODE_NOP ) ; caller -> insert_before ( it , dummy_end_instruction ) ; auto new_blk = caller -> split_block ( old_block , caller -> find_insn ( dummy_end_instruction ) . unwrap ( ) ) ; return std :: make_pair ( old_block , new_blk ) ; }
Insert a new block if needed to make `it` the first instruction of a block.
Insert a new block if needed to make ` it ` the first instruction of a block .
// If we already have a block. // Inject an instruction and then split so 'it' is first of block