More descriptive logging to help diagnose irreducible control flow

This commit is contained in:
Chris Fallin 2023-02-12 17:32:06 -08:00
parent ec2a999359
commit 508620289f
2 changed files with 18 additions and 4 deletions

View file

@ -124,7 +124,14 @@ impl<'a, 'b> Context<'a, 'b> {
for (block_rpo, &block) in cfg.rpo.entries() { for (block_rpo, &block) in cfg.rpo.entries() {
for &succ in &body.blocks[block].succs { 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(); let succ_rpo = cfg.rpo_pos[succ].unwrap();
log::trace!(" -> succ rpo {}", succ_rpo); log::trace!(" -> succ rpo {}", succ_rpo);
if succ_rpo <= block_rpo { if succ_rpo <= block_rpo {

View file

@ -78,7 +78,14 @@ impl<'a> Display for FunctionBodyDisplay<'a> {
.iter() .iter()
.map(|(ty, val)| format!("{}: {}", val, ty)) .map(|(ty, val)| format!("{}: {}", val, ty))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
writeln!(f, "{} {}({}):", self.1, block_id, block_params.join(", "))?; writeln!(
f,
"{} {}({}): # {}",
self.1,
block_id,
block_params.join(", "),
block.desc
)?;
writeln!( writeln!(
f, f,
"{} # preds: {}", "{} # preds: {}",
@ -86,7 +93,7 @@ impl<'a> Display for FunctionBodyDisplay<'a> {
block block
.preds .preds
.iter() .iter()
.map(|pred| format!("{}", pred)) .map(|pred| format!("{} ({})", pred, self.0.blocks[*pred].desc))
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join(", ") .join(", ")
)?; )?;
@ -97,7 +104,7 @@ impl<'a> Display for FunctionBodyDisplay<'a> {
block block
.succs .succs
.iter() .iter()
.map(|succ| format!("{}", succ)) .map(|succ| format!("{} ({})", succ, self.0.blocks[*succ].desc))
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join(", ") .join(", ")
)?; )?;