()
| 160 | |
| 161 | #[test] |
| 162 | fn keeps_pointer_stack_values_64_bit() { |
| 163 | let mut program = IrProgram::new("test"); |
| 164 | let mut func = IrFunction::new("ptrs", int32()); |
| 165 | |
| 166 | let mut entry = IrBlock::new("entry"); |
| 167 | entry.push_instruction(IrInstruction::HeapAlloc { |
| 168 | dest: IrRegister::Named("heap".into()), |
| 169 | ty: int32(), |
| 170 | count: None, |
| 171 | }); |
| 172 | entry.push_instruction(IrInstruction::Alloc { |
| 173 | dest: IrRegister::Named("holder".into()), |
| 174 | ty: IrType::Pointer(Box::new(int32())), |
| 175 | count: None, |
| 176 | }); |
| 177 | entry.push_instruction(IrInstruction::Store { |
| 178 | ty: IrType::Pointer(Box::new(int32())), |
| 179 | value: IrValue::Register(IrRegister::Named("heap".into())), |
| 180 | ptr: IrRegister::Named("holder".into()), |
| 181 | offset: None, |
| 182 | }); |
| 183 | entry.push_instruction(IrInstruction::Load { |
| 184 | dest: IrRegister::Named("alias".into()), |
| 185 | ty: IrType::Pointer(Box::new(int32())), |
| 186 | ptr: IrRegister::Named("holder".into()), |
| 187 | offset: None, |
| 188 | }); |
| 189 | entry.set_terminator(IrTerminator::Return(Some(IrValue::Integer(0)))); |
| 190 | func.push_block(entry); |
| 191 | program.push_function(func); |
| 192 | |
| 193 | let asm = compile(&program); |
| 194 | |
| 195 | assert!(asm.contains("\tsd") || asm.contains("sd "), "expected pointer store to use sd, got:\n{asm}"); |
| 196 | assert!(asm.contains("\tld") || asm.contains("ld "), "expected pointer load to use ld, got:\n{asm}"); |
| 197 | } |
| 198 | |
| 199 | #[test] |
| 200 | fn heap_alloc_zeroes_memory_and_skips_null() { |
nothing calls this directly
no test coverage detected