Skip to content

Commit a030620

Browse files
committed
fix up debugging output
1 parent 4a52349 commit a030620

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

zjit/src/backend/lir.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,20 @@ impl fmt::Display for Assembler {
22622262
Target::CodePtr(code_ptr) => write!(f, " {code_ptr:?}")?,
22632263
Target::Label(Label(label_idx)) => write!(f, " {}", label_name(self, *label_idx, &label_counts))?,
22642264
Target::SideExit { reason, .. } => write!(f, " Exit({reason})")?,
2265-
Target::Block(edge) => write!(f, " bb{}", edge.target.0)?,
2265+
Target::Block(edge) => {
2266+
if edge.args.is_empty() {
2267+
write!(f, " bb{}", edge.target.0)?;
2268+
} else {
2269+
write!(f, " bb{}(", edge.target.0)?;
2270+
for (i, arg) in edge.args.iter().enumerate() {
2271+
if i > 0 {
2272+
write!(f, ", ")?;
2273+
}
2274+
write!(f, "{}", arg)?;
2275+
}
2276+
write!(f, ")")?;
2277+
}
2278+
}
22662279
}
22672280
}
22682281

@@ -2278,6 +2291,17 @@ impl fmt::Display for Assembler {
22782291
}
22792292
_ => {}
22802293
}
2294+
} else if let Some(Target::Block(_)) = insn.target() {
2295+
// If the instruction has a Block target, avoid using opnd_iter() for branch args
2296+
// since they're already printed inline with the target. Only print non-target operands.
2297+
match insn {
2298+
Insn::Joz(opnd, _) |
2299+
Insn::Jonz(opnd, _) |
2300+
Insn::LeaJumpTarget { out: opnd, target: _ } => {
2301+
write!(f, ", {opnd}")?;
2302+
}
2303+
_ => {}
2304+
}
22812305
} else if let Insn::ParallelMov { moves } = insn {
22822306
// Print operands with a special syntax for ParallelMov
22832307
moves.iter().try_fold(" ", |prefix, (dst, src)| write!(f, "{prefix}{dst} <- {src}").and(Ok(", ")))?;

0 commit comments

Comments
 (0)