MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / omits_destination_for_void_calls

Function omits_destination_for_void_calls

tests/integration/rv64_codegen.rs:263–289  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

261
262#[test]
263fn omits_destination_for_void_calls() {
264 let mut program = IrProgram::new("test");
265 let mut func = IrFunction::new("cleanup", int32());
266
267 let mut entry = IrBlock::new("entry");
268 entry.push_instruction(IrInstruction::Alloc {
269 dest: IrRegister::Named("ptr".into()),
270 ty: IrType::Pointer(Box::new(int32())),
271 count: None,
272 });
273 entry.push_instruction(IrInstruction::Call {
274 dest: None,
275 function: "free".into(),
276 args: vec![IrValue::Register(IrRegister::Named("ptr".into()))],
277 });
278 entry.set_terminator(IrTerminator::Return(Some(IrValue::Integer(0))));
279 func.push_block(entry);
280 program.push_function(func);
281
282 let asm = compile(&program);
283
284 assert!(asm.contains("free"), "expected call target to be emitted, got:\n{asm}");
285 assert!(
286 !asm.contains("sd a0") && !asm.contains("sd a0"),
287 "expected no destination store for void call, got:\n{asm}"
288 );
289}

Callers

nothing calls this directly

Calls 6

compileFunction · 0.85
push_blockMethod · 0.80
push_functionMethod · 0.80
int32Function · 0.70
push_instructionMethod · 0.45
set_terminatorMethod · 0.45

Tested by

no test coverage detected