()
| 261 | |
| 262 | #[test] |
| 263 | fn 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 | } |
nothing calls this directly
no test coverage detected