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

Function cloning

cranelift/codegen/src/ir/dfg.rs:1787–1805  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1785
1786 #[test]
1787 fn cloning() {
1788 use crate::ir::InstBuilder;
1789
1790 let mut func = Function::new();
1791 let mut sig = Signature::new(crate::isa::CallConv::SystemV);
1792 sig.params.push(ir::AbiParam::new(types::I32));
1793 let sig = func.import_signature(sig);
1794 let block0 = func.dfg.make_block();
1795 let mut pos = FuncCursor::new(&mut func);
1796 pos.insert_block(block0);
1797 let v1 = pos.ins().iconst(types::I32, 0);
1798 let v2 = pos.ins().iconst(types::I32, 1);
1799 let call_inst = pos.ins().call_indirect(sig, v1, &[v1]);
1800 let func = pos.func;
1801
1802 let call_inst_dup = func.dfg.clone_inst(call_inst);
1803 func.dfg.inst_args_mut(call_inst)[0] = v2;
1804 assert_eq!(v1, func.dfg.inst_args(call_inst_dup)[0]);
1805 }
1806}

Callers

nothing calls this directly

Calls 9

make_blockMethod · 0.80
call_indirectMethod · 0.80
clone_instMethod · 0.80
inst_args_mutMethod · 0.80
newFunction · 0.50
pushMethod · 0.45
import_signatureMethod · 0.45
insert_blockMethod · 0.45
insMethod · 0.45

Tested by

no test coverage detected