cranelift: Move most debug-level logs to the trace level
Cranelift crates have historically been much more verbose with debug-level
logging than most other crates in the Rust ecosystem. We log things like how
many parameters a basic block has, the color of virtual registers during
regalloc, etc. Even for Cranelift hackers, these things are largely only useful
when hacking specifically on Cranelift and looking at a particular test case,
not even when using some Cranelift embedding (such as Wasmtime).
Most of the time, when people want logging for their Rust programs, they do
something like:
RUST_LOG=debug cargo run
This means that they get all that mostly not useful debug logging out of
Cranelift. So they might want to disable logging for Cranelift, or change it to
a higher log level:
RUST_LOG=debug,cranelift=info cargo run
The problem is that this is already more annoying to type that `RUST_LOG=debug`,
and that Cranelift isn't one single crate, so you actually have to play
whack-a-mole with naming all the Cranelift crates off the top of your head,
something more like this:
RUST_LOG=debug,cranelift=info,cranelift_codegen=info,cranelift_wasm=info,...
Therefore, we're changing most of the `debug!` logs into `trace!` logs: anything
that is very Cranelift-internal, unlikely to be useful/meaningful to the
"average" Cranelift embedder, or prints a message for each instruction visited
during a pass. On the other hand, things that just report a one line statistic
for a whole pass, for example, are left as `debug!`. The more verbose the log
messages are, the higher the bar they must clear to be `debug!` rather than
`trace!`.
This commit is contained in:
@@ -22,7 +22,6 @@ use core::cmp;
|
||||
use core::fmt;
|
||||
use core::iter;
|
||||
use core::slice;
|
||||
use log::debug;
|
||||
|
||||
// # Implementation
|
||||
//
|
||||
@@ -116,7 +115,7 @@ impl Coalescing {
|
||||
virtregs: &mut VirtRegs,
|
||||
) {
|
||||
let _tt = timing::ra_cssa();
|
||||
debug!("Coalescing for:\n{}", func.display(isa));
|
||||
log::trace!("Coalescing for:\n{}", func.display(isa));
|
||||
self.preorder.compute(domtree, &func.layout);
|
||||
let mut context = Context {
|
||||
isa,
|
||||
@@ -185,7 +184,7 @@ impl<'a> Context<'a> {
|
||||
continue;
|
||||
}
|
||||
|
||||
debug!(
|
||||
log::trace!(
|
||||
" - checking {} params at back-edge {}: {}",
|
||||
num_params,
|
||||
pred_block,
|
||||
@@ -225,7 +224,7 @@ impl<'a> Context<'a> {
|
||||
if Some(def_block) == self.func.layout.entry_block()
|
||||
&& self.func.signature.params[def_num].location.is_stack()
|
||||
{
|
||||
debug!("-> isolating function stack parameter {}", arg);
|
||||
log::trace!("-> isolating function stack parameter {}", arg);
|
||||
let new_arg = self.isolate_arg(pred_block, pred_inst, argnum, arg);
|
||||
self.virtregs.union(param, new_arg);
|
||||
continue;
|
||||
@@ -294,7 +293,7 @@ impl<'a> Context<'a> {
|
||||
let inst = pos.built_inst();
|
||||
self.liveness.move_def_locally(param, inst);
|
||||
|
||||
debug!(
|
||||
log::trace!(
|
||||
"-> inserted {}, following {}({}: {})",
|
||||
pos.display_inst(inst),
|
||||
block,
|
||||
@@ -364,7 +363,7 @@ impl<'a> Context<'a> {
|
||||
|
||||
pos.func.dfg.inst_variable_args_mut(pred_inst)[argnum] = copy;
|
||||
|
||||
debug!(
|
||||
log::trace!(
|
||||
"-> inserted {}, before {}: {}",
|
||||
pos.display_inst(inst),
|
||||
pred_block,
|
||||
@@ -380,7 +379,7 @@ impl<'a> Context<'a> {
|
||||
/// closure of the relation formed by block parameter-argument pairs found by `union_find_block()`.
|
||||
fn finish_union_find(&mut self) {
|
||||
self.virtregs.finish_union_find(None);
|
||||
debug!("After union-find phase:{}", self.virtregs);
|
||||
log::trace!("After union-find phase:{}", self.virtregs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +410,7 @@ impl<'a> Context<'a> {
|
||||
fn check_vreg(&mut self, vreg: VirtReg) -> bool {
|
||||
// Order the values according to the dominator pre-order of their definition.
|
||||
let values = self.virtregs.sort_values(vreg, self.func, self.preorder);
|
||||
debug!("Checking {} = {}", vreg, DisplayList(values));
|
||||
log::trace!("Checking {} = {}", vreg, DisplayList(values));
|
||||
|
||||
// Now push the values in order to the dominator forest.
|
||||
// This gives us the closest dominating value def for each of the values.
|
||||
@@ -432,7 +431,7 @@ impl<'a> Context<'a> {
|
||||
// `value`, we only have to check if it overlaps the definition.
|
||||
if self.liveness[parent.value].overlaps_def(node.def, node.block, &self.func.layout) {
|
||||
// The two values are interfering, so they can't be in the same virtual register.
|
||||
debug!("-> interference: {} overlaps def of {}", parent, value);
|
||||
log::trace!("-> interference: {} overlaps def of {}", parent, value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -456,7 +455,7 @@ impl<'a> Context<'a> {
|
||||
self.cfg,
|
||||
self.preorder,
|
||||
);
|
||||
debug!(
|
||||
log::trace!(
|
||||
"Synthesizing {} from {} branches and params {}",
|
||||
vreg,
|
||||
self.vcopies.branches.len(),
|
||||
@@ -544,7 +543,7 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
|
||||
let _vreg = self.virtregs.unify(self.values);
|
||||
debug!("-> merged into {} = {}", _vreg, DisplayList(self.values));
|
||||
log::trace!("-> merged into {} = {}", _vreg, DisplayList(self.values));
|
||||
true
|
||||
}
|
||||
|
||||
@@ -566,7 +565,7 @@ impl<'a> Context<'a> {
|
||||
// registers and the filtered virtual copies.
|
||||
let v0 = self.virtregs.congruence_class(¶m);
|
||||
let v1 = self.virtregs.congruence_class(&arg);
|
||||
debug!(
|
||||
log::trace!(
|
||||
" - set 0: {}\n - set 1: {}",
|
||||
DisplayList(v0),
|
||||
DisplayList(v1)
|
||||
@@ -618,7 +617,7 @@ impl<'a> Context<'a> {
|
||||
if node.set_id != parent.set_id
|
||||
&& self.liveness[parent.value].reaches_use(inst, node.block, &self.func.layout)
|
||||
{
|
||||
debug!(
|
||||
log::trace!(
|
||||
" - interference: {} overlaps vcopy at {}:{}",
|
||||
parent,
|
||||
node.block,
|
||||
@@ -643,7 +642,7 @@ impl<'a> Context<'a> {
|
||||
&& self.liveness[parent.value].overlaps_def(node.def, node.block, &self.func.layout)
|
||||
{
|
||||
// The two values are interfering.
|
||||
debug!(" - interference: {} overlaps def of {}", parent, node.value);
|
||||
log::trace!(" - interference: {} overlaps def of {}", parent, node.value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user