From 508620289ff3ba68addfee82d2d7e806ad388edd Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Sun, 12 Feb 2023 17:32:06 -0800 Subject: [PATCH] More descriptive logging to help diagnose irreducible control flow --- src/backend/stackify.rs | 9 ++++++++- src/ir/display.rs | 13 ++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/backend/stackify.rs b/src/backend/stackify.rs index 67ca6a2..9f49a26 100644 --- a/src/backend/stackify.rs +++ b/src/backend/stackify.rs @@ -124,7 +124,14 @@ impl<'a, 'b> Context<'a, 'b> { for (block_rpo, &block) in cfg.rpo.entries() { for &succ in &body.blocks[block].succs { - log::trace!("block {} rpo {} has succ {}", block, block_rpo, succ); + log::trace!( + "block {} ({}) rpo {} has succ {} ({})", + block, + body.blocks[block].desc, + block_rpo, + succ, + body.blocks[succ].desc, + ); let succ_rpo = cfg.rpo_pos[succ].unwrap(); log::trace!(" -> succ rpo {}", succ_rpo); if succ_rpo <= block_rpo { diff --git a/src/ir/display.rs b/src/ir/display.rs index c717ba0..a6f5a54 100644 --- a/src/ir/display.rs +++ b/src/ir/display.rs @@ -78,7 +78,14 @@ impl<'a> Display for FunctionBodyDisplay<'a> { .iter() .map(|(ty, val)| format!("{}: {}", val, ty)) .collect::>(); - writeln!(f, "{} {}({}):", self.1, block_id, block_params.join(", "))?; + writeln!( + f, + "{} {}({}): # {}", + self.1, + block_id, + block_params.join(", "), + block.desc + )?; writeln!( f, "{} # preds: {}", @@ -86,7 +93,7 @@ impl<'a> Display for FunctionBodyDisplay<'a> { block .preds .iter() - .map(|pred| format!("{}", pred)) + .map(|pred| format!("{} ({})", pred, self.0.blocks[*pred].desc)) .collect::>() .join(", ") )?; @@ -97,7 +104,7 @@ impl<'a> Display for FunctionBodyDisplay<'a> { block .succs .iter() - .map(|succ| format!("{}", succ)) + .map(|succ| format!("{} ({})", succ, self.0.blocks[*succ].desc)) .collect::>() .join(", ") )?;