MCPcopy Create free account
hub / github.com/MultiFuzz/MultiFuzz / push_with_resize

Function push_with_resize

hail-fuzz/src/load_resizer.rs:210–237  ·  view source on GitHub ↗

Pushes the resized version of `stmt` to `block`.

(block: &mut pcode::Block, stmt: pcode::Instruction, metadata: LoadMetadata)

Source from the content-addressed store, hash-verified

208
209/// Pushes the resized version of `stmt` to `block`.
210fn push_with_resize(block: &mut pcode::Block, stmt: pcode::Instruction, metadata: LoadMetadata) {
211 let output = stmt.output;
212 let new_size = metadata.required_bytes();
213 if new_size == 0 {
214 // If there were any loads that ended up zero bytes in size, then we replace them
215 // with a copy from a constant. However, emit warning since this could be an
216 // indicator of an error.
217 tracing::warn!("removed zero sized load");
218 block.push(pcode::Value::Const(0, output.size).copy_to(output));
219 }
220 else if output.size > new_size {
221 tracing::info!(
222 "adjusting load {stmt:?}: {} -> {new_size} (bits: {}..={})",
223 output.size,
224 metadata.min_bit,
225 metadata.max_bit,
226 );
227 // Replace the old load, with a load to a smaller temporary.
228 let tmp = block.alloc_tmp(new_size);
229 block.push((tmp, stmt.op, stmt.inputs));
230 // Copy a zero extended value to the correct destination.
231 block.push((output, pcode::Op::ZeroExtend, tmp));
232 }
233 else {
234 // Load was unmodified.
235 block.push(stmt);
236 }
237}
238
239struct LocalLifter {
240 code: icicle_vm::cpu::BlockTable,

Callers 1

resize_loadsMethod · 0.85

Calls 1

required_bytesMethod · 0.45

Tested by

no test coverage detected