diff --git a/src/bitvec.rs b/src/bitvec.rs index 46a56ff..5c2cc2f 100644 --- a/src/bitvec.rs +++ b/src/bitvec.rs @@ -177,7 +177,7 @@ impl<'a> std::iter::Iterator for AdaptiveMapIter<'a> { /// A conceptually infinite-length bitvector that allows bitwise operations and /// iteration over set bits efficiently. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct BitVec { elems: AdaptiveMap, } @@ -275,6 +275,13 @@ impl Iterator for SetBitsIter { } } +impl std::fmt::Debug for BitVec { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + let vals = self.iter().collect::>(); + write!(f, "{:?}", vals) + } +} + #[cfg(test)] mod test { use super::BitVec; diff --git a/src/fuzzing/func.rs b/src/fuzzing/func.rs index 5e8bff8..ae8dcce 100644 --- a/src/fuzzing/func.rs +++ b/src/fuzzing/func.rs @@ -130,7 +130,7 @@ impl Function for Func { &self.reftype_vregs[..] } - fn is_move(&self, insn: Inst) -> Option<(VReg, VReg)> { + fn is_move(&self, _: Inst) -> Option<(VReg, VReg)> { None } diff --git a/src/ion/mod.rs b/src/ion/mod.rs index a93ded7..0a5a816 100644 --- a/src/ion/mod.rs +++ b/src/ion/mod.rs @@ -267,7 +267,6 @@ struct Env<'a, F: Function> { env: &'a MachineEnv, cfginfo: CFGInfo, liveins: Vec, - livein_parents: Vec>, /// Blockparam outputs: from-vreg, (end of) from-block, (start of) /// to-block, to-vreg. The field order is significant: these are sorted so /// that a scan over vregs, then blocks in each range, can scan in @@ -664,7 +663,6 @@ impl<'a, F: Function> Env<'a, F> { cfginfo, liveins: vec![], - livein_parents: vec![], blockparam_outs: vec![], blockparam_ins: vec![], blockparam_allocs: vec![], @@ -1016,23 +1014,13 @@ impl<'a, F: Function> Env<'a, F> { } fn is_live_in(&mut self, block: Block, vreg: VRegIndex) -> bool { - if self.liveins[block.index()].get(vreg.index()) { - return true; - } - for &parent in &self.livein_parents[block.index()] { - if self.liveins[parent.index()].get(vreg.index()) { - self.liveins[block.index()].set(vreg.index(), true); - return true; - } - } - false + self.liveins[block.index()].get(vreg.index()) } fn compute_liveness(&mut self) { // Create initial LiveIn bitsets. for _ in 0..self.func.blocks() { self.liveins.push(BitVec::new()); - self.livein_parents.push(vec![]); } let mut num_ranges = 0; @@ -1428,7 +1416,7 @@ impl<'a, F: Function> Env<'a, F> { ); log::debug!(" -> loop range {:?}", loop_range); for &loopblock in loop_blocks { - self.livein_parents[loopblock.index()].push(block); + self.liveins[loopblock.index()].or(&live); } for vreg in live.iter() { log::debug!( diff --git a/src/lib.rs b/src/lib.rs index 0232813..437e6ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -779,11 +779,25 @@ pub enum InstPosition { } /// A program point: a single point before or after a given instruction. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct ProgPoint { bits: u32, } +impl std::fmt::Debug for ProgPoint { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!( + f, + "progpoint{}{}", + self.inst().index(), + match self.pos() { + InstPosition::Before => "-pre", + InstPosition::After => "-post", + } + ) + } +} + impl ProgPoint { pub fn new(inst: Inst, pos: InstPosition) -> Self { let bits = ((inst.0 as u32) << 1) | (pos as u8 as u32);