MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / create_blocks

Function create_blocks

cranelift/codegen/src/inline.rs:1394–1425  ·  view source on GitHub ↗

Create inlined blocks in the caller for every block in the callee.

(
    allocs: &mut InliningAllocs,
    func: &mut ir::Function,
    callee: &ir::Function,
)

Source from the content-addressed store, hash-verified

1392
1393/// Create inlined blocks in the caller for every block in the callee.
1394fn 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.
1428fn create_global_values(func: &mut ir::Function, callee: &ir::Function) -> CodegenResult<u32> {

Callers 1

create_entitiesFunction · 0.85

Calls 12

set_coldMethod · 0.80
set_inlined_valueMethod · 0.80
lenMethod · 0.45
unwrapMethod · 0.45
reserveMethod · 0.45
iterMethod · 0.45
addMethod · 0.45
is_coldMethod · 0.45
entry_blockMethod · 0.45
paramsMethod · 0.45
value_typeMethod · 0.45
append_block_paramMethod · 0.45

Tested by

no test coverage detected