Create inlined blocks in the caller for every block in the callee.
(
allocs: &mut InliningAllocs,
func: &mut ir::Function,
callee: &ir::Function,
)
| 1392 | |
| 1393 | /// Create inlined blocks in the caller for every block in the callee. |
| 1394 | fn create_blocks( |
| 1395 | allocs: &mut InliningAllocs, |
| 1396 | func: &mut ir::Function, |
| 1397 | callee: &ir::Function, |
| 1398 | ) -> u32 { |
| 1399 | let offset = func.dfg.blocks.len(); |
| 1400 | let offset = u32::try_from(offset).unwrap(); |
| 1401 | |
| 1402 | func.dfg.blocks.reserve(callee.dfg.blocks.len()); |
| 1403 | for callee_block in callee.dfg.blocks.iter() { |
| 1404 | let caller_block = func.dfg.blocks.add(); |
| 1405 | trace!("Callee {callee_block:?} = inlined {caller_block:?}"); |
| 1406 | |
| 1407 | if callee.layout.is_cold(callee_block) { |
| 1408 | func.layout.set_cold(caller_block); |
| 1409 | } |
| 1410 | |
| 1411 | // Note: the entry block does not need parameters because the only |
| 1412 | // predecessor is the call block and we associate the callee's |
| 1413 | // parameters with the caller's arguments directly. |
| 1414 | if callee.layout.entry_block() != Some(callee_block) { |
| 1415 | for callee_param in callee.dfg.blocks[callee_block].params(&callee.dfg.value_lists) { |
| 1416 | let ty = callee.dfg.value_type(*callee_param); |
| 1417 | let caller_param = func.dfg.append_block_param(caller_block, ty); |
| 1418 | |
| 1419 | allocs.set_inlined_value(callee, *callee_param, caller_param); |
| 1420 | } |
| 1421 | } |
| 1422 | } |
| 1423 | |
| 1424 | offset |
| 1425 | } |
| 1426 | |
| 1427 | /// Copy and translate global values from the callee into the caller. |
| 1428 | fn create_global_values(func: &mut ir::Function, callee: &ir::Function) -> CodegenResult<u32> { |
no test coverage detected