From 3f13d97d275c806ea6616071566d8c4f875f18a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Wed, 20 May 2020 00:00:00 +0000 Subject: [PATCH] liveness: Log information about used variables --- src/librustc_passes/liveness.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs index ece78d02512..03ec8243662 100644 --- a/src/librustc_passes/liveness.rs +++ b/src/librustc_passes/liveness.rs @@ -357,7 +357,7 @@ fn visit_fn<'tcx>( sp: Span, id: hir::HirId, ) { - debug!("visit_fn"); + debug!("visit_fn {:?}", id); // swap in a new set of IR maps for this function body: let def_id = ir.tcx.hir().local_def_id(id); @@ -777,12 +777,12 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn write_vars(&self, wr: &mut dyn Write, ln: LiveNode, mut test: F) -> io::Result<()> where - F: FnMut(usize) -> LiveNode, + F: FnMut(usize) -> bool, { let node_base_idx = self.idx(ln, Variable(0)); for var_idx in 0..self.ir.num_vars { let idx = node_base_idx + var_idx; - if test(idx).is_valid() { + if test(idx) { write!(wr, " {:?}", Variable(var_idx as u32))?; } } @@ -795,9 +795,12 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { { let wr = &mut wr as &mut dyn Write; write!(wr, "[ln({:?}) of kind {:?} reads", ln.get(), self.ir.lnk(ln)); - self.write_vars(wr, ln, |idx| self.rwu_table.get_reader(idx)); + self.write_vars(wr, ln, |idx| self.rwu_table.get_reader(idx).is_valid()); write!(wr, " writes"); - self.write_vars(wr, ln, |idx| self.rwu_table.get_writer(idx)); + self.write_vars(wr, ln, |idx| self.rwu_table.get_writer(idx).is_valid()); + write!(wr, " uses"); + self.write_vars(wr, ln, |idx| self.rwu_table.get_used(idx)); + write!(wr, " precedes {:?}]", self.successors[ln.get()]); } String::from_utf8(wr).unwrap()