Streamline log enablement (#64)

* Remove log_enabled statements around annotate calls, which are already guarded against annotations_enabled

* Use a trace_enabled!() macro that follows the same logic as trace!() to find if additional traces have been enabled or not
This commit is contained in:
Benjamin Bouvier
2022-07-20 19:44:31 +02:00
committed by GitHub
parent 8bede950d0
commit a33b044d6c
3 changed files with 23 additions and 24 deletions

View File

@@ -97,7 +97,7 @@ impl<'a, F: Function> Env<'a, F> {
self.fixup_multi_fixed_vregs();
self.merge_vreg_bundles();
self.queue_bundles();
if log::log_enabled!(log::Level::Trace) {
if trace_enabled!() {
self.dump_state();
}
Ok(())

View File

@@ -435,8 +435,7 @@ impl<'a, F: Function> Env<'a, F> {
alloc,
);
#[cfg(debug_assertions)]
{
if log::log_enabled!(log::Level::Trace) {
if self.annotations_enabled {
self.annotate(
self.cfginfo.block_entry[block.index()],
format!(
@@ -449,7 +448,6 @@ impl<'a, F: Function> Env<'a, F> {
);
}
}
}
blockparam_in_idx += 1;
}
@@ -831,17 +829,12 @@ impl<'a, F: Function> Env<'a, F> {
);
if input_alloc != output_alloc {
#[cfg(debug_assertions)]
{
if log::log_enabled!(log::Level::Trace) {
if self.annotations_enabled {
self.annotate(
ProgPoint::before(inst),
format!(
" reuse-input-copy: {} -> {}",
input_alloc, output_alloc
),
format!(" reuse-input-copy: {} -> {}", input_alloc, output_alloc),
);
}
}
let input_operand = self.func.inst_operands(inst)[input_idx];
self.insert_move(
ProgPoint::before(inst),

View File

@@ -22,6 +22,12 @@ macro_rules! trace {
};
}
macro_rules! trace_enabled {
() => {
cfg!(feature = "trace-log")
};
}
pub(crate) mod cfg;
pub(crate) mod domtree;
pub mod indexset;