Inline the callee's layout into the caller's layout. Returns the last inlined block in the layout.
(
func: &mut ir::Function,
call_block: ir::Block,
callee: &ir::Function,
entity_map: &EntityMap,
)
| 1051 | /// |
| 1052 | /// Returns the last inlined block in the layout. |
| 1053 | fn inline_block_layout( |
| 1054 | func: &mut ir::Function, |
| 1055 | call_block: ir::Block, |
| 1056 | callee: &ir::Function, |
| 1057 | entity_map: &EntityMap, |
| 1058 | ) -> ir::Block { |
| 1059 | debug_assert!(func.layout.is_block_inserted(call_block)); |
| 1060 | |
| 1061 | // Iterate over callee blocks in layout order, inserting their associated |
| 1062 | // inlined block into the caller's layout. |
| 1063 | let mut prev_inlined_block = call_block; |
| 1064 | let mut next_callee_block = callee.layout.entry_block(); |
| 1065 | while let Some(callee_block) = next_callee_block { |
| 1066 | debug_assert!(func.layout.is_block_inserted(prev_inlined_block)); |
| 1067 | |
| 1068 | let inlined_block = entity_map.inlined_block(callee_block); |
| 1069 | func.layout |
| 1070 | .insert_block_after(inlined_block, prev_inlined_block); |
| 1071 | |
| 1072 | prev_inlined_block = inlined_block; |
| 1073 | next_callee_block = callee.layout.next_block(callee_block); |
| 1074 | } |
| 1075 | |
| 1076 | debug_assert!(func.layout.is_block_inserted(prev_inlined_block)); |
| 1077 | prev_inlined_block |
| 1078 | } |
| 1079 | |
| 1080 | /// Split the call instruction's block just after the call instruction to create |
| 1081 | /// the point where control-flow joins after the inlined callee "returns". |
no test coverage detected