emit annotations at Info level, for easier selective perf-debugging

This commit is contained in:
Chris Fallin
2021-05-28 18:35:09 -07:00
parent 789651f947
commit f49167e0fe

View File

@@ -1510,7 +1510,7 @@ impl<'a, F: Function> Env<'a, F> {
OperandPos::Before, OperandPos::Before,
); );
if self.annotations_enabled && log::log_enabled!(log::Level::Debug) { if self.annotations_enabled {
self.annotate( self.annotate(
ProgPoint::after(inst), ProgPoint::after(inst),
format!( format!(
@@ -2105,7 +2105,7 @@ impl<'a, F: Function> Env<'a, F> {
for entry in &list { for entry in &list {
self.ranges[entry.index.index()].bundle = to; self.ranges[entry.index.index()].bundle = to;
if self.annotations_enabled && log::log_enabled!(log::Level::Debug) { if self.annotations_enabled {
self.annotate( self.annotate(
entry.range.from, entry.range.from,
format!( format!(
@@ -2165,7 +2165,7 @@ impl<'a, F: Function> Env<'a, F> {
last_range = Some(entry.range); last_range = Some(entry.range);
if self.ranges[entry.index.index()].bundle == from { if self.ranges[entry.index.index()].bundle == from {
if self.annotations_enabled && log::log_enabled!(log::Level::Debug) { if self.annotations_enabled {
self.annotate( self.annotate(
entry.range.from, entry.range.from,
format!( format!(
@@ -3586,7 +3586,7 @@ impl<'a, F: Function> Env<'a, F> {
); );
debug_assert!(alloc != Allocation::none()); debug_assert!(alloc != Allocation::none());
if self.annotations_enabled && log::log_enabled!(log::Level::Debug) { if self.annotations_enabled {
self.annotate( self.annotate(
range.from, range.from,
format!( format!(
@@ -3767,8 +3767,7 @@ impl<'a, F: Function> Env<'a, F> {
alloc, alloc,
}); });
if self.annotations_enabled && log::log_enabled!(log::Level::Debug) if self.annotations_enabled {
{
self.annotate( self.annotate(
self.cfginfo.block_exit[block.index()], self.cfginfo.block_exit[block.index()],
format!( format!(
@@ -4382,7 +4381,7 @@ impl<'a, F: Function> Env<'a, F> {
self.stats.edits_count = self.edits.len(); self.stats.edits_count = self.edits.len();
// Add debug annotations. // Add debug annotations.
if self.annotations_enabled && log::log_enabled!(log::Level::Debug) { if self.annotations_enabled {
for i in 0..self.edits.len() { for i in 0..self.edits.len() {
let &(pos, _, ref edit) = &self.edits[i]; let &(pos, _, ref edit) = &self.edits[i];
match edit { match edit {
@@ -4496,7 +4495,7 @@ impl<'a, F: Function> Env<'a, F> {
} }
fn annotate(&mut self, progpoint: ProgPoint, s: String) { fn annotate(&mut self, progpoint: ProgPoint, s: String) {
if log::log_enabled!(log::Level::Debug) { if self.annotations_enabled {
self.debug_annotations self.debug_annotations
.entry(progpoint) .entry(progpoint)
.or_insert_with(|| vec![]) .or_insert_with(|| vec![])
@@ -4505,10 +4504,10 @@ impl<'a, F: Function> Env<'a, F> {
} }
fn dump_results(&self) { fn dump_results(&self) {
log::debug!("=== REGALLOC RESULTS ==="); log::info!("=== REGALLOC RESULTS ===");
for block in 0..self.func.blocks() { for block in 0..self.func.blocks() {
let block = Block::new(block); let block = Block::new(block);
log::debug!( log::info!(
"block{}: [succs {:?} preds {:?}]", "block{}: [succs {:?} preds {:?}]",
block.index(), block.index(),
self.func self.func
@@ -4529,7 +4528,7 @@ impl<'a, F: Function> Env<'a, F> {
.map(|v| &v[..]) .map(|v| &v[..])
.unwrap_or(&[]) .unwrap_or(&[])
{ {
log::debug!(" inst{}-pre: {}", inst.index(), annotation); log::info!(" inst{}-pre: {}", inst.index(), annotation);
} }
let ops = self let ops = self
.func .func
@@ -4565,7 +4564,7 @@ impl<'a, F: Function> Env<'a, F> {
} else { } else {
format!(" [clobber: {}]", clobbers.join(", ")) format!(" [clobber: {}]", clobbers.join(", "))
}; };
log::debug!( log::info!(
" inst{}: {} {}{}", " inst{}: {} {}{}",
inst.index(), inst.index(),
opname, opname,
@@ -4578,7 +4577,7 @@ impl<'a, F: Function> Env<'a, F> {
.map(|v| &v[..]) .map(|v| &v[..])
.unwrap_or(&[]) .unwrap_or(&[])
{ {
log::debug!(" inst{}-post: {}", inst.index(), annotation); log::info!(" inst{}-post: {}", inst.index(), annotation);
} }
} }
} }
@@ -4597,7 +4596,7 @@ pub fn run<F: Function>(
env.run()?; env.run()?;
if log::log_enabled!(log::Level::Debug) { if enable_annotations {
env.dump_results(); env.dump_results();
} }