Guard trace! behind cfg!(debug_assertions)

Even if the trace log level is disabled, the presence of the trace!
macro still has a significant impact on performance because it is
present in the inner loops of the allocator.

Removing the trace! calls at compile-time reduces instruction count by
~7%.
This commit is contained in:
Amanieu d'Antras
2022-01-11 13:30:13 +00:00
parent 2d9d5dd82b
commit ee4de54240
11 changed files with 237 additions and 239 deletions

View File

@@ -20,7 +20,7 @@ use crate::{Allocation, Function, SpillSlot};
impl<'a, F: Function> Env<'a, F> {
pub fn try_allocating_regs_for_spilled_bundles(&mut self) {
log::trace!("allocating regs for spilled bundles");
trace!("allocating regs for spilled bundles");
for i in 0..self.spilled_bundles.len() {
let bundle = self.spilled_bundles[i]; // don't borrow self
@@ -38,7 +38,7 @@ impl<'a, F: Function> Env<'a, F> {
for preg in
RegTraversalIter::new(self.env, class, hint, PReg::invalid(), bundle.index(), None)
{
log::trace!("trying bundle {:?} to preg {:?}", bundle, preg);
trace!("trying bundle {:?} to preg {:?}", bundle, preg);
let preg_idx = PRegIndex::new(preg.index());
if let AllocRegResult::Allocated(_) =
self.try_to_allocate_bundle_to_reg(bundle, preg_idx, None)
@@ -49,7 +49,7 @@ impl<'a, F: Function> Env<'a, F> {
}
}
if !success {
log::trace!(
trace!(
"spilling bundle {:?}: marking spillset {:?} as required",
bundle,
self.bundles[bundle.index()].spillset
@@ -87,14 +87,14 @@ impl<'a, F: Function> Env<'a, F> {
for i in 0..self.spillsets[spillset.index()].vregs.len() {
// don't borrow self
let vreg = self.spillsets[spillset.index()].vregs[i];
log::trace!(
trace!(
"spillslot {:?} alloc'ed to spillset {:?}: vreg {:?}",
spillslot,
spillset,
vreg,
);
for entry in &self.vregs[vreg.index()].ranges {
log::trace!(
trace!(
"spillslot {:?} getting range {:?} from LR {:?} from vreg {:?}",
spillslot,
entry.range,
@@ -111,7 +111,7 @@ impl<'a, F: Function> Env<'a, F> {
pub fn allocate_spillslots(&mut self) {
for spillset in 0..self.spillsets.len() {
log::trace!("allocate spillslot: {}", spillset);
trace!("allocate spillslot: {}", spillset);
let spillset = SpillSetIndex::new(spillset);
if !self.spillsets[spillset.index()].required {
continue;
@@ -196,7 +196,7 @@ impl<'a, F: Function> Env<'a, F> {
self.spillslots[i].alloc = self.allocate_spillslot(self.spillslots[i].class);
}
log::trace!("spillslot allocator done");
trace!("spillslot allocator done");
}
pub fn allocate_spillslot(&mut self, class: RegClass) -> Allocation {