diff --git a/src/ir/mod.rs b/src/ir/mod.rs index 4626c14..3a0df1f 100644 --- a/src/ir/mod.rs +++ b/src/ir/mod.rs @@ -192,7 +192,11 @@ pub struct Block { #[derive(Debug, Clone, PartialEq, Eq)] pub enum Instruction { Nop, - // TODO: Explain what this is, why this is needed. + /// A value, used for "simple copy". + /// + /// This is only used during phi elimination for Asmgen. You can ignore this before that. In + /// particular, you will need this instruction to properly generate assembly for `lost_copy.c` + /// and `swap.c`. Value { value: Operand, }, diff --git a/src/tests.rs b/src/tests.rs index a2cf847..b69f8f4 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,5 +1,5 @@ use std::fs::{self, File}; -use std::io::{Read, Write, stderr}; +use std::io::{self, Read, Write}; use std::path::Path; use std::process::{Command, Stdio}; use std::time::Duration; @@ -193,10 +193,13 @@ pub fn test_irgen(path: &Path) { // be nullified. So, we truncate the result value to byte size one more time here. println!("clang (expected): {}, kecc: {}", status as u8, value as u8); if status as u8 != value as u8 { - stderr().lock().write_fmt(format_args!( + let mut stderr = io::stderr().lock(); + stderr.write_fmt(format_args!( "[irgen] Failed to correctly generate {path:?}.\n\n [incorrect ir]" )); - write(&ir, &mut stderr()).unwrap(); + write(&ir, &mut stderr).unwrap(); + drop(stderr); + panic!("[irgen]"); } } @@ -277,23 +280,20 @@ pub fn test_opt, P2: AsRef, O: Optimize