Convert all log::debug to log::trace.

This commit is contained in:
Chris Fallin
2021-08-12 12:05:19 -07:00
parent 38323e0c27
commit 3e1e0f39b6
14 changed files with 282 additions and 251 deletions

View File

@@ -10,7 +10,7 @@ use regalloc2::fuzzing::func::Func;
fuzz_target!(|func: Func| {
let _ = env_logger::try_init();
log::debug!("func:\n{:?}", func);
log::trace!("func:\n{:?}", func);
let env = regalloc2::fuzzing::func::machine_env();
let _out = regalloc2::fuzzing::ion::run(&func, &env, false).expect("regalloc did not succeed");
});

View File

@@ -38,7 +38,7 @@ impl Arbitrary for TestCase {
fuzz_target!(|testcase: TestCase| {
let func = testcase.func;
let _ = env_logger::try_init();
log::debug!("func:\n{:?}", func);
log::trace!("func:\n{:?}", func);
let env = regalloc2::fuzzing::func::machine_env();
let out = regalloc2::fuzzing::ion::run(&func, &env, true).expect("regalloc did not succeed");

View File

@@ -66,8 +66,8 @@
#![allow(dead_code)]
use crate::{
Allocation, AllocationKind, Block, Edit, Function, Inst, InstPosition, Operand, OperandKind,
OperandConstraint, OperandPos, Output, PReg, ProgPoint, SpillSlot, VReg,
Allocation, AllocationKind, Block, Edit, Function, Inst, InstPosition, Operand,
OperandConstraint, OperandKind, OperandPos, Output, PReg, ProgPoint, SpillSlot, VReg,
};
use std::collections::{HashMap, HashSet, VecDeque};
@@ -75,8 +75,6 @@ use std::default::Default;
use std::hash::Hash;
use std::result::Result;
use log::debug;
/// A set of errors detected by the regalloc checker.
#[derive(Clone, Debug)]
pub struct CheckerErrors {
@@ -182,7 +180,7 @@ impl CheckerValue {
CheckerValue::Reg(r1, ref1)
}
_ => {
log::debug!("{:?} and {:?} meet to Conflicted", self, other);
log::trace!("{:?} and {:?} meet to Conflicted", self, other);
CheckerValue::Conflicted
}
}
@@ -313,9 +311,12 @@ impl CheckerState {
.get(alloc)
.cloned()
.unwrap_or(Default::default());
debug!(
log::trace!(
"checker: checkinst {:?}: op {:?}, alloc {:?}, checker value {:?}",
checkinst, op, alloc, val
checkinst,
op,
alloc,
val
);
self.check_val(inst, *op, *alloc, val, allocs)?;
}
@@ -328,9 +329,11 @@ impl CheckerState {
.get(&alloc)
.cloned()
.unwrap_or(Default::default());
debug!(
log::trace!(
"checker: checkinst {:?}: safepoint slot {}, checker value {:?}",
checkinst, slot, val
checkinst,
slot,
val
);
match val {
@@ -359,9 +362,12 @@ impl CheckerState {
.get(&from)
.cloned()
.unwrap_or(Default::default());
debug!(
log::trace!(
"checker: checkinst {:?} updating: move {:?} -> {:?} val {:?}",
checkinst, from, into, val
checkinst,
from,
into,
val
);
self.allocations.insert(into, val);
}
@@ -529,7 +535,7 @@ impl<'a, F: Function> Checker<'a, F> {
/// Build the list of checker instructions based on the given func
/// and allocation results.
pub fn prepare(&mut self, out: &Output) {
debug!("checker: out = {:?}", out);
log::trace!("checker: out = {:?}", out);
// Preprocess safepoint stack-maps into per-inst vecs.
let mut safepoint_slots: HashMap<Inst, Vec<SpillSlot>> = HashMap::new();
for &(progpoint, slot) in &out.safepoint_slots {
@@ -574,7 +580,7 @@ impl<'a, F: Function> Checker<'a, F> {
allocs,
clobbers,
};
debug!("checker: adding inst {:?}", checkinst);
log::trace!("checker: adding inst {:?}", checkinst);
self.bb_insts.get_mut(&block).unwrap().push(checkinst);
}
@@ -591,7 +597,7 @@ impl<'a, F: Function> Checker<'a, F> {
if edit_pos < pos {
continue;
}
debug!("checker: adding edit {:?} at pos {:?}", edit, pos);
log::trace!("checker: adding edit {:?} at pos {:?}", edit, pos);
match edit {
&Edit::Move { from, to, to_vreg } => {
self.bb_insts
@@ -640,10 +646,10 @@ impl<'a, F: Function> Checker<'a, F> {
let block = queue.pop_front().unwrap();
queue_set.remove(&block);
let mut state = self.bb_in.get(&block).cloned().unwrap();
debug!("analyze: block {} has state {:?}", block.index(), state);
log::trace!("analyze: block {} has state {:?}", block.index(), state);
for inst in self.bb_insts.get(&block).unwrap() {
state.update(inst, self);
debug!("analyze: inst {:?} -> state {:?}", inst, state);
log::trace!("analyze: inst {:?} -> state {:?}", inst, state);
}
for &succ in self.f.block_succs(block) {
@@ -652,7 +658,7 @@ impl<'a, F: Function> Checker<'a, F> {
new_state.meet_with(cur_succ_in);
let changed = &new_state != cur_succ_in;
if changed {
debug!(
log::trace!(
"analyze: block {} state changed from {:?} to {:?}; pushing onto queue",
succ.index(),
cur_succ_in,
@@ -677,12 +683,12 @@ impl<'a, F: Function> Checker<'a, F> {
let mut state = input.clone();
for inst in self.bb_insts.get(block).unwrap() {
if let Err(e) = state.check(InstPosition::Before, inst) {
debug!("Checker error: {:?}", e);
log::trace!("Checker error: {:?}", e);
errors.push(e);
}
state.update(inst, self);
if let Err(e) = state.check(InstPosition::After, inst) {
debug!("Checker error: {:?}", e);
log::trace!("Checker error: {:?}", e);
errors.push(e);
}
}
@@ -701,20 +707,20 @@ impl<'a, F: Function> Checker<'a, F> {
self.analyze();
let result = self.find_errors();
debug!("=== CHECKER RESULT ===");
log::trace!("=== CHECKER RESULT ===");
fn print_state(state: &CheckerState) {
let mut s = vec![];
for (alloc, state) in &state.allocations {
s.push(format!("{} := {}", alloc, state));
}
debug!(" {{ {} }}", s.join(", "))
log::trace!(" {{ {} }}", s.join(", "))
}
for vreg in self.f.reftype_vregs() {
debug!(" REF: {}", vreg);
log::trace!(" REF: {}", vreg);
}
for bb in 0..self.f.blocks() {
let bb = Block::new(bb);
debug!("block{}:", bb.index());
log::trace!("block{}:", bb.index());
let insts = self.bb_insts.get(&bb).unwrap();
let mut state = self.bb_in.get(&bb).unwrap().clone();
print_state(&state);
@@ -726,7 +732,7 @@ impl<'a, F: Function> Checker<'a, F> {
ref allocs,
ref clobbers,
} => {
debug!(
log::trace!(
" inst{}: {:?} ({:?}) clobbers:{:?}",
inst.index(),
operands,
@@ -735,7 +741,7 @@ impl<'a, F: Function> Checker<'a, F> {
);
}
&CheckerInst::Move { from, into } => {
debug!(" {} -> {}", from, into);
log::trace!(" {} -> {}", from, into);
}
&CheckerInst::BlockParams {
ref vregs,
@@ -746,17 +752,17 @@ impl<'a, F: Function> Checker<'a, F> {
for (vreg, alloc) in vregs.iter().zip(allocs.iter()) {
args.push(format!("{}:{}", vreg, alloc));
}
debug!(" blockparams: {}", args.join(", "));
log::trace!(" blockparams: {}", args.join(", "));
}
&CheckerInst::DefAlloc { alloc, vreg } => {
debug!(" defalloc: {}:{}", vreg, alloc);
log::trace!(" defalloc: {}:{}", vreg, alloc);
}
&CheckerInst::Safepoint { ref slots, .. } => {
let mut slotargs = vec![];
for &slot in slots {
slotargs.push(format!("{}", slot));
}
debug!(" safepoint: {}", slotargs.join(", "));
log::trace!(" safepoint: {}", slotargs.join(", "));
}
}
state.update(inst, &self);

View File

@@ -5,7 +5,7 @@
use crate::{
domtree, postorder, Allocation, Block, Function, Inst, InstRange, MachineEnv, Operand,
OperandKind, OperandConstraint, OperandPos, PReg, RegClass, VReg,
OperandConstraint, OperandKind, OperandPos, PReg, RegClass, VReg,
};
use arbitrary::Result as ArbitraryResult;
@@ -407,7 +407,12 @@ impl Func {
} else {
OperandPos::After
};
let mut operands = vec![Operand::new(vreg, def_constraint, OperandKind::Def, def_pos)];
let mut operands = vec![Operand::new(
vreg,
def_constraint,
OperandKind::Def,
def_pos,
)];
let mut allocations = vec![Allocation::none()];
for _ in 0..u.int_in_range(0..=3)? {
let vreg = if avail.len() > 0
@@ -456,8 +461,12 @@ impl Func {
);
// Make sure reused input is a Reg.
let op = operands[reused];
operands[reused] =
Operand::new(op.vreg(), OperandConstraint::Reg, op.kind(), OperandPos::Before);
operands[reused] = Operand::new(
op.vreg(),
OperandConstraint::Reg,
op.kind(),
OperandPos::Before,
);
} else if opts.fixed_regs && bool::arbitrary(u)? {
let mut fixed = vec![];
for _ in 0..u.int_in_range(0..=operands.len() - 1)? {

View File

@@ -5,16 +5,16 @@ use crate::{Block, Function, ProgPoint};
impl<'a, F: Function> Env<'a, F> {
pub fn dump_state(&self) {
log::debug!("Bundles:");
log::trace!("Bundles:");
for (i, b) in self.bundles.iter().enumerate() {
log::debug!(
log::trace!(
"bundle{}: spillset={:?} alloc={:?}",
i,
b.spillset,
b.allocation
);
for entry in &b.ranges {
log::debug!(
log::trace!(
" * range {:?} -- {:?}: range{}",
entry.range.from,
entry.range.to,
@@ -22,11 +22,11 @@ impl<'a, F: Function> Env<'a, F> {
);
}
}
log::debug!("VRegs:");
log::trace!("VRegs:");
for (i, v) in self.vregs.iter().enumerate() {
log::debug!("vreg{}:", i);
log::trace!("vreg{}:", i);
for entry in &v.ranges {
log::debug!(
log::trace!(
" * range {:?} -- {:?}: range{}",
entry.range.from,
entry.range.to,
@@ -34,9 +34,9 @@ impl<'a, F: Function> Env<'a, F> {
);
}
}
log::debug!("Ranges:");
log::trace!("Ranges:");
for (i, r) in self.ranges.iter().enumerate() {
log::debug!(
log::trace!(
"range{}: range={:?} vreg={:?} bundle={:?} weight={}",
i,
r.range,
@@ -45,7 +45,7 @@ impl<'a, F: Function> Env<'a, F> {
r.uses_spill_weight(),
);
for u in &r.uses {
log::debug!(" * use at {:?} (slot {}): {:?}", u.pos, u.slot, u.operand);
log::trace!(" * use at {:?} (slot {}): {:?}", u.pos, u.slot, u.operand);
}
}
}

View File

@@ -20,7 +20,7 @@ use super::{
};
use crate::bitvec::BitVec;
use crate::{
Allocation, Block, Function, Inst, InstPosition, Operand, OperandKind, OperandConstraint,
Allocation, Block, Function, Inst, InstPosition, Operand, OperandConstraint, OperandKind,
OperandPos, PReg, ProgPoint, RegAllocError, VReg,
};
use fxhash::FxHashSet;
@@ -29,7 +29,11 @@ use std::collections::{HashSet, VecDeque};
use std::convert::TryFrom;
#[inline(always)]
pub fn spill_weight_from_constraint(constraint: OperandConstraint, loop_depth: usize, is_def: bool) -> u32 {
pub fn spill_weight_from_constraint(
constraint: OperandConstraint,
loop_depth: usize,
is_def: bool,
) -> u32 {
// A bonus of 1000 for one loop level, 4000 for two loop levels,
// 16000 for three loop levels, etc. Avoids exponentiation.
// Bound `loop_depth` at 2 so that `hot_bonus` is at most 16000.
@@ -127,7 +131,7 @@ impl<'a, F: Function> Env<'a, F> {
///
/// Returns the liverange that contains the given range.
pub fn add_liverange_to_vreg(&mut self, vreg: VRegIndex, range: CodeRange) -> LiveRangeIndex {
log::debug!("add_liverange_to_vreg: vreg {:?} range {:?}", vreg, range);
log::trace!("add_liverange_to_vreg: vreg {:?} range {:?}", vreg, range);
// Invariant: as we are building liveness information, we
// *always* process instructions bottom-to-top, and as a
@@ -187,11 +191,14 @@ impl<'a, F: Function> Env<'a, F> {
let constraint = operand.constraint();
let block = self.cfginfo.insn_block[u.pos.inst().index()];
let loop_depth = self.cfginfo.approx_loop_depth[block.index()] as usize;
let weight =
spill_weight_from_constraint(constraint, loop_depth, operand.kind() != OperandKind::Use);
let weight = spill_weight_from_constraint(
constraint,
loop_depth,
operand.kind() != OperandKind::Use,
);
u.weight = u16::try_from(weight).expect("weight too large for u16 field");
log::debug!(
log::trace!(
"insert use {:?} into lr {:?} with weight {}",
u,
into,
@@ -206,7 +213,7 @@ impl<'a, F: Function> Env<'a, F> {
// Update stats.
self.ranges[into.index()].uses_spill_weight_and_flags += weight;
log::debug!(
log::trace!(
" -> now range has weight {}",
self.ranges[into.index()].uses_spill_weight(),
);
@@ -226,7 +233,7 @@ impl<'a, F: Function> Env<'a, F> {
}
pub fn add_liverange_to_preg(&mut self, range: CodeRange, reg: PReg) {
log::debug!("adding liverange to preg: {:?} to {}", range, reg);
log::trace!("adding liverange to preg: {:?} to {}", range, reg);
let preg_idx = PRegIndex::new(reg.index());
self.pregs[preg_idx.index()]
.allocations
@@ -259,12 +266,12 @@ impl<'a, F: Function> Env<'a, F> {
let block = workqueue.pop_front().unwrap();
workqueue_set.remove(&block);
log::debug!("computing liveins for block{}", block.index());
log::trace!("computing liveins for block{}", block.index());
self.stats.livein_iterations += 1;
let mut live = self.liveouts[block.index()].clone();
log::debug!(" -> initial liveout set: {:?}", live);
log::trace!(" -> initial liveout set: {:?}", live);
for inst in self.func.block_insns(block).rev().iter() {
if let Some((src, dst)) = self.func.is_move(inst) {
@@ -276,7 +283,7 @@ impl<'a, F: Function> Env<'a, F> {
for op in self.func.inst_operands(inst) {
if op.pos() == *pos {
let was_live = live.get(op.vreg().vreg());
log::debug!("op {:?} was_live = {}", op, was_live);
log::trace!("op {:?} was_live = {}", op, was_live);
match op.kind() {
OperandKind::Use | OperandKind::Mod => {
live.set(op.vreg().vreg(), true);
@@ -302,7 +309,7 @@ impl<'a, F: Function> Env<'a, F> {
}
}
log::debug!("computed liveins at block{}: {:?}", block.index(), live);
log::trace!("computed liveins at block{}: {:?}", block.index(), live);
self.liveins[block.index()] = live;
}
@@ -314,7 +321,7 @@ impl<'a, F: Function> Env<'a, F> {
.next()
.is_some()
{
log::debug!(
log::trace!(
"non-empty liveins to entry block: {:?}",
self.liveins[self.func.entry_block().index()]
);
@@ -354,7 +361,7 @@ impl<'a, F: Function> Env<'a, F> {
from: self.cfginfo.block_entry[block.index()],
to: self.cfginfo.block_exit[block.index()].next(),
};
log::debug!(
log::trace!(
"vreg {:?} live at end of block --> create range {:?}",
VRegIndex::new(vreg),
range
@@ -426,7 +433,7 @@ impl<'a, F: Function> Env<'a, F> {
// We can completely skip the move if it is
// trivial (vreg to same vreg).
if src.vreg() != dst.vreg() {
log::debug!(" -> move inst{}: src {} -> dst {}", inst.index(), src, dst);
log::trace!(" -> move inst{}: src {} -> dst {}", inst.index(), src, dst);
assert_eq!(src.class(), dst.class());
assert_eq!(src.kind(), OperandKind::Use);
@@ -488,7 +495,7 @@ impl<'a, F: Function> Env<'a, F> {
else if self.vregs[src.vreg().vreg()].is_pinned
|| self.vregs[dst.vreg().vreg()].is_pinned
{
log::debug!(
log::trace!(
" -> exactly one of src/dst is pinned; converting to ghost use"
);
let (preg, vreg, pinned_vreg, kind, pos, progpoint) =
@@ -516,7 +523,7 @@ impl<'a, F: Function> Env<'a, F> {
let constraint = OperandConstraint::FixedReg(preg);
let operand = Operand::new(vreg, constraint, kind, pos);
log::debug!(
log::trace!(
concat!(
" -> preg {:?} vreg {:?} kind {:?} ",
"pos {:?} progpoint {:?} constraint {:?} operand {:?}"
@@ -543,9 +550,9 @@ impl<'a, F: Function> Env<'a, F> {
VRegIndex::new(vreg.vreg()),
CodeRange { from, to },
);
log::debug!(" -> dead; created LR");
log::trace!(" -> dead; created LR");
}
log::debug!(" -> LR {:?}", lr);
log::trace!(" -> LR {:?}", lr);
self.insert_use_into_liverange(
lr,
@@ -579,7 +586,7 @@ impl<'a, F: Function> Env<'a, F> {
// (this is the last use), start it
// before.
if kind == OperandKind::Def {
log::debug!(" -> src on pinned vreg {:?}", pinned_vreg);
log::trace!(" -> src on pinned vreg {:?}", pinned_vreg);
// The *other* vreg is a def, so the pinned-vreg
// mention is a use. If already live,
// end the existing LR just *after*
@@ -593,7 +600,7 @@ impl<'a, F: Function> Env<'a, F> {
if live.get(pinned_vreg.vreg()) {
let pinned_lr = vreg_ranges[pinned_vreg.vreg()];
let orig_start = self.ranges[pinned_lr.index()].range.from;
log::debug!(
log::trace!(
" -> live with LR {:?}; truncating to start at {:?}",
pinned_lr,
progpoint.next()
@@ -607,7 +614,7 @@ impl<'a, F: Function> Env<'a, F> {
},
);
vreg_ranges[pinned_vreg.vreg()] = new_lr;
log::debug!(" -> created LR {:?} with remaining range from {:?} to {:?}", new_lr, orig_start, progpoint);
log::trace!(" -> created LR {:?} with remaining range from {:?} to {:?}", new_lr, orig_start, progpoint);
// Add an edit right now to indicate that at
// this program point, the given
@@ -641,7 +648,7 @@ impl<'a, F: Function> Env<'a, F> {
);
vreg_ranges[pinned_vreg.vreg()] = new_lr;
live.set(pinned_vreg.vreg(), true);
log::debug!(
log::trace!(
" -> was not live; created new LR {:?}",
new_lr
);
@@ -661,7 +668,7 @@ impl<'a, F: Function> Env<'a, F> {
);
}
} else {
log::debug!(" -> dst on pinned vreg {:?}", pinned_vreg);
log::trace!(" -> dst on pinned vreg {:?}", pinned_vreg);
// The *other* vreg is a use, so the pinned-vreg
// mention is a def. Truncate its LR
// just *after* the `progpoint`
@@ -669,7 +676,7 @@ impl<'a, F: Function> Env<'a, F> {
if live.get(pinned_vreg.vreg()) {
let pinned_lr = vreg_ranges[pinned_vreg.vreg()];
self.ranges[pinned_lr.index()].range.from = progpoint.next();
log::debug!(
log::trace!(
" -> was live with LR {:?}; truncated start to {:?}",
pinned_lr,
progpoint.next()
@@ -769,14 +776,14 @@ impl<'a, F: Function> Env<'a, F> {
VRegIndex::new(dst.vreg().vreg()),
CodeRange { from, to },
);
log::debug!(" -> invalid LR for def; created {:?}", dst_lr);
log::trace!(" -> invalid LR for def; created {:?}", dst_lr);
}
log::debug!(" -> has existing LR {:?}", dst_lr);
log::trace!(" -> has existing LR {:?}", dst_lr);
// Trim the LR to start here.
if self.ranges[dst_lr.index()].range.from
== self.cfginfo.block_entry[block.index()]
{
log::debug!(" -> started at block start; trimming to {:?}", pos);
log::trace!(" -> started at block start; trimming to {:?}", pos);
self.ranges[dst_lr.index()].range.from = pos;
}
self.ranges[dst_lr.index()].set_flag(LiveRangeFlag::StartsAtDef);
@@ -803,7 +810,7 @@ impl<'a, F: Function> Env<'a, F> {
vreg_ranges[src.vreg().vreg()]
};
log::debug!(" -> src LR {:?}", src_lr);
log::trace!(" -> src LR {:?}", src_lr);
// Add to live-set.
let src_is_dead_after_move = !live.get(src.vreg().vreg());
@@ -863,7 +870,7 @@ impl<'a, F: Function> Env<'a, F> {
continue;
}
log::debug!(
log::trace!(
"processing inst{} operand at {:?}: {:?}",
inst.index(),
pos,
@@ -872,14 +879,14 @@ impl<'a, F: Function> Env<'a, F> {
match operand.kind() {
OperandKind::Def | OperandKind::Mod => {
log::debug!("Def of {} at {:?}", operand.vreg(), pos);
log::trace!("Def of {} at {:?}", operand.vreg(), pos);
// Fill in vreg's actual data.
self.vreg_regs[operand.vreg().vreg()] = operand.vreg();
// Get or create the LiveRange.
let mut lr = vreg_ranges[operand.vreg().vreg()];
log::debug!(" -> has existing LR {:?}", lr);
log::trace!(" -> has existing LR {:?}", lr);
// If there was no liverange (dead def), create a trivial one.
if !live.get(operand.vreg().vreg()) {
let from = match operand.kind() {
@@ -896,7 +903,7 @@ impl<'a, F: Function> Env<'a, F> {
VRegIndex::new(operand.vreg().vreg()),
CodeRange { from, to },
);
log::debug!(" -> invalid; created {:?}", lr);
log::trace!(" -> invalid; created {:?}", lr);
vreg_ranges[operand.vreg().vreg()] = lr;
live.set(operand.vreg().vreg(), true);
}
@@ -913,7 +920,7 @@ impl<'a, F: Function> Env<'a, F> {
if self.ranges[lr.index()].range.from
== self.cfginfo.block_entry[block.index()]
{
log::debug!(
log::trace!(
" -> started at block start; trimming to {:?}",
pos
);
@@ -945,7 +952,7 @@ impl<'a, F: Function> Env<'a, F> {
}
assert!(lr.is_valid());
log::debug!("Use of {:?} at {:?} -> {:?}", operand, pos, lr,);
log::trace!("Use of {:?} at {:?} -> {:?}", operand, pos, lr,);
self.insert_use_into_liverange(lr, Use::new(operand, pos, i as u8));
@@ -957,11 +964,11 @@ impl<'a, F: Function> Env<'a, F> {
}
if self.func.is_safepoint(inst) {
log::debug!("inst{} is safepoint", inst.index());
log::trace!("inst{} is safepoint", inst.index());
self.safepoints.push(inst);
for vreg in live.iter() {
if let Some(safepoints) = self.safepoints_per_vreg.get_mut(&vreg) {
log::debug!("vreg v{} live at safepoint inst{}", vreg, inst.index());
log::trace!("vreg v{} live at safepoint inst{}", vreg, inst.index());
safepoints.insert(inst);
}
}
@@ -1054,7 +1061,7 @@ impl<'a, F: Function> Env<'a, F> {
OperandPos::Before,
);
log::debug!(
log::trace!(
"Safepoint-induced stack use of {:?} at {:?} -> {:?}",
operand,
pos,
@@ -1095,7 +1102,7 @@ impl<'a, F: Function> Env<'a, F> {
for range_idx in 0..self.vregs[vreg].ranges.len() {
let entry = self.vregs[vreg].ranges[range_idx];
let range = entry.index;
log::debug!(
log::trace!(
"multi-fixed-reg cleanup: vreg {:?} range {:?}",
VRegIndex::new(vreg),
range,
@@ -1119,7 +1126,7 @@ impl<'a, F: Function> Env<'a, F> {
if let OperandConstraint::FixedReg(preg) = op.constraint() {
let vreg_idx = VRegIndex::new(op.vreg().vreg());
let preg_idx = PRegIndex::new(preg.index());
log::debug!(
log::trace!(
"at pos {:?}, vreg {:?} has fixed constraint to preg {:?}",
pos,
vreg_idx,
@@ -1129,7 +1136,7 @@ impl<'a, F: Function> Env<'a, F> {
{
let orig_preg = first_preg[idx];
if orig_preg != preg_idx {
log::debug!(" -> duplicate; switching to constraint Reg");
log::trace!(" -> duplicate; switching to constraint Reg");
fixups.push((pos, orig_preg, preg_idx, slot));
*op = Operand::new(
op.vreg(),
@@ -1137,7 +1144,7 @@ impl<'a, F: Function> Env<'a, F> {
op.kind(),
op.pos(),
);
log::debug!(
log::trace!(
" -> extra clobber {} at inst{}",
preg,
pos.inst().index()
@@ -1182,8 +1189,8 @@ impl<'a, F: Function> Env<'a, F> {
self.prog_move_srcs.sort_unstable_by_key(|(pos, _)| *pos);
self.prog_move_dsts.sort_unstable_by_key(|(pos, _)| *pos);
log::debug!("prog_move_srcs = {:?}", self.prog_move_srcs);
log::debug!("prog_move_dsts = {:?}", self.prog_move_dsts);
log::trace!("prog_move_srcs = {:?}", self.prog_move_srcs);
log::trace!("prog_move_dsts = {:?}", self.prog_move_dsts);
self.stats.initial_liverange_count = self.ranges.len();
self.stats.blockparam_ins_count = self.blockparam_ins.len();

View File

@@ -26,7 +26,7 @@ impl<'a, F: Function> Env<'a, F> {
// Merge bundle into self -- trivial merge.
return true;
}
log::debug!(
log::trace!(
"merging from bundle{} to bundle{}",
from.index(),
to.index()
@@ -36,7 +36,7 @@ impl<'a, F: Function> Env<'a, F> {
let from_rc = self.spillsets[self.bundles[from.index()].spillset.index()].class;
let to_rc = self.spillsets[self.bundles[to.index()].spillset.index()].class;
if from_rc != to_rc {
log::debug!(" -> mismatching reg classes");
log::trace!(" -> mismatching reg classes");
return false;
}
@@ -44,7 +44,7 @@ impl<'a, F: Function> Env<'a, F> {
if !self.bundles[from.index()].allocation.is_none()
|| !self.bundles[to.index()].allocation.is_none()
{
log::debug!("one of the bundles is already assigned (pinned)");
log::trace!("one of the bundles is already assigned (pinned)");
return false;
}
@@ -71,7 +71,7 @@ impl<'a, F: Function> Env<'a, F> {
while idx_from < ranges_from.len() && idx_to < ranges_to.len() {
range_count += 1;
if range_count > 200 {
log::debug!(
log::trace!(
"reached merge complexity (range_count = {}); exiting",
range_count
);
@@ -85,7 +85,7 @@ impl<'a, F: Function> Env<'a, F> {
idx_from += 1;
} else {
// Overlap -- cannot merge.
log::debug!(
log::trace!(
" -> overlap between {:?} and {:?}, exiting",
ranges_from[idx_from].index,
ranges_to[idx_to].index
@@ -104,12 +104,12 @@ impl<'a, F: Function> Env<'a, F> {
.compute_requirement(from)
.merge(self.compute_requirement(to));
if req == Requirement::Conflict {
log::debug!(" -> conflicting requirements; aborting merge");
log::trace!(" -> conflicting requirements; aborting merge");
return false;
}
}
log::debug!(" -> committing to merge");
log::trace!(" -> committing to merge");
// If we reach here, then the bundles do not overlap -- merge
// them! We do this with a merge-sort-like scan over both
@@ -117,13 +117,13 @@ impl<'a, F: Function> Env<'a, F> {
// `to` when we're done.
if ranges_from.is_empty() {
// `from` bundle is empty -- trivial merge.
log::debug!(" -> from bundle{} is empty; trivial merge", from.index());
log::trace!(" -> from bundle{} is empty; trivial merge", from.index());
return true;
}
if ranges_to.is_empty() {
// `to` bundle is empty -- just move the list over from
// `from` and set `bundle` up-link on all ranges.
log::debug!(" -> to bundle{} is empty; trivial merge", to.index());
log::trace!(" -> to bundle{} is empty; trivial merge", to.index());
let list = std::mem::replace(&mut self.bundles[from.index()].ranges, smallvec![]);
for entry in &list {
self.ranges[entry.index.index()].bundle = to;
@@ -153,7 +153,7 @@ impl<'a, F: Function> Env<'a, F> {
return true;
}
log::debug!(
log::trace!(
"merging: ranges_from = {:?} ranges_to = {:?}",
ranges_from,
ranges_to
@@ -174,7 +174,7 @@ impl<'a, F: Function> Env<'a, F> {
.sort_unstable_by_key(|entry| entry.range.from);
if self.annotations_enabled {
log::debug!("merging: merged = {:?}", self.bundles[to.index()].ranges);
log::trace!("merging: merged = {:?}", self.bundles[to.index()].ranges);
let mut last_range = None;
for i in 0..self.bundles[to.index()].ranges.len() {
let entry = self.bundles[to.index()].ranges[i];
@@ -196,7 +196,7 @@ impl<'a, F: Function> Env<'a, F> {
);
}
log::debug!(
log::trace!(
" -> merged result for bundle{}: range{}",
to.index(),
entry.index.index(),
@@ -229,7 +229,7 @@ impl<'a, F: Function> Env<'a, F> {
pub fn merge_vreg_bundles(&mut self) {
// Create a bundle for every vreg, initially.
log::debug!("merge_vreg_bundles: creating vreg bundles");
log::trace!("merge_vreg_bundles: creating vreg bundles");
for vreg in 0..self.vregs.len() {
let vreg = VRegIndex::new(vreg);
if self.vregs[vreg.index()].ranges.is_empty() {
@@ -255,9 +255,9 @@ impl<'a, F: Function> Env<'a, F> {
let bundle = self.create_bundle();
self.bundles[bundle.index()].ranges = self.vregs[vreg.index()].ranges.clone();
log::debug!("vreg v{} gets bundle{}", vreg.index(), bundle.index());
log::trace!("vreg v{} gets bundle{}", vreg.index(), bundle.index());
for entry in &self.bundles[bundle.index()].ranges {
log::debug!(
log::trace!(
" -> with LR range{}: {:?}",
entry.index.index(),
entry.range
@@ -318,7 +318,7 @@ impl<'a, F: Function> Env<'a, F> {
continue;
}
log::debug!(
log::trace!(
"trying to merge reused-input def: src {} to dst {}",
src_vreg,
dst_vreg
@@ -337,7 +337,7 @@ impl<'a, F: Function> Env<'a, F> {
// Attempt to merge blockparams with their inputs.
for i in 0..self.blockparam_outs.len() {
let (from_vreg, _, _, to_vreg) = self.blockparam_outs[i];
log::debug!(
log::trace!(
"trying to merge blockparam v{} with input v{}",
to_vreg.index(),
from_vreg.index()
@@ -347,7 +347,7 @@ impl<'a, F: Function> Env<'a, F> {
let from_bundle =
self.ranges[self.vregs[from_vreg.index()].ranges[0].index.index()].bundle;
assert!(from_bundle.is_valid());
log::debug!(
log::trace!(
" -> from bundle{} to bundle{}",
from_bundle.index(),
to_bundle.index()
@@ -358,10 +358,10 @@ impl<'a, F: Function> Env<'a, F> {
// Attempt to merge move srcs/dsts.
for i in 0..self.prog_move_merges.len() {
let (src, dst) = self.prog_move_merges[i];
log::debug!("trying to merge move src LR {:?} to dst LR {:?}", src, dst);
log::trace!("trying to merge move src LR {:?} to dst LR {:?}", src, dst);
let src = self.resolve_merged_lr(src);
let dst = self.resolve_merged_lr(dst);
log::debug!(
log::trace!(
"resolved LR-construction merging chains: move-merge is now src LR {:?} to dst LR {:?}",
src,
dst
@@ -397,7 +397,7 @@ impl<'a, F: Function> Env<'a, F> {
}
}
log::debug!("done merging bundles");
log::trace!("done merging bundles");
}
pub fn resolve_merged_lr(&self, mut lr: LiveRangeIndex) -> LiveRangeIndex {
@@ -421,14 +421,14 @@ impl<'a, F: Function> Env<'a, F> {
pub fn queue_bundles(&mut self) {
for bundle in 0..self.bundles.len() {
log::debug!("enqueueing bundle{}", bundle);
log::trace!("enqueueing bundle{}", bundle);
if self.bundles[bundle].ranges.is_empty() {
log::debug!(" -> no ranges; skipping");
log::trace!(" -> no ranges; skipping");
continue;
}
let bundle = LiveBundleIndex::new(bundle);
let prio = self.compute_bundle_prio(bundle);
log::debug!(" -> prio {}", prio);
log::trace!(" -> prio {}", prio);
self.bundles[bundle.index()].prio = prio;
self.recompute_bundle_properties(bundle);
self.allocation_queue

View File

@@ -20,10 +20,9 @@ use super::{
use crate::moves::ParallelMoves;
use crate::{
Allocation, Block, Edit, Function, Inst, InstPosition, OperandKind, OperandConstraint, OperandPos,
ProgPoint, RegClass, VReg,
Allocation, Block, Edit, Function, Inst, InstPosition, OperandConstraint, OperandKind,
OperandPos, ProgPoint, RegClass, VReg,
};
use log::debug;
use smallvec::{smallvec, SmallVec};
use std::fmt::Debug;
@@ -45,9 +44,12 @@ impl<'a, F: Function> Env<'a, F> {
to_alloc: Allocation,
to_vreg: Option<VReg>,
) {
debug!(
log::trace!(
"insert_move: pos {:?} prio {:?} from_alloc {:?} to_alloc {:?}",
pos, prio, from_alloc, to_alloc
pos,
prio,
from_alloc,
to_alloc
);
match (from_alloc.as_reg(), to_alloc.as_reg()) {
(Some(from), Some(to)) => {
@@ -75,16 +77,16 @@ impl<'a, F: Function> Env<'a, F> {
}
pub fn get_alloc_for_range(&self, range: LiveRangeIndex) -> Allocation {
log::debug!("get_alloc_for_range: {:?}", range);
log::trace!("get_alloc_for_range: {:?}", range);
let bundle = self.ranges[range.index()].bundle;
log::debug!(" -> bundle: {:?}", bundle);
log::trace!(" -> bundle: {:?}", bundle);
let bundledata = &self.bundles[bundle.index()];
log::debug!(" -> allocation {:?}", bundledata.allocation);
log::trace!(" -> allocation {:?}", bundledata.allocation);
if bundledata.allocation != Allocation::none() {
bundledata.allocation
} else {
log::debug!(" -> spillset {:?}", bundledata.spillset);
log::debug!(
log::trace!(" -> spillset {:?}", bundledata.spillset);
log::trace!(
" -> spill slot {:?}",
self.spillsets[bundledata.spillset.index()].slot
);
@@ -93,9 +95,9 @@ impl<'a, F: Function> Env<'a, F> {
}
pub fn apply_allocations_and_insert_moves(&mut self) {
log::debug!("apply_allocations_and_insert_moves");
log::debug!("blockparam_ins: {:?}", self.blockparam_ins);
log::debug!("blockparam_outs: {:?}", self.blockparam_outs);
log::trace!("apply_allocations_and_insert_moves");
log::trace!("blockparam_ins: {:?}", self.blockparam_ins);
log::trace!("blockparam_outs: {:?}", self.blockparam_outs);
// Now that all splits are done, we can pay the cost once to
// sort VReg range lists and update with the final ranges.
@@ -191,7 +193,7 @@ impl<'a, F: Function> Env<'a, F> {
.map(|preg| Allocation::reg(preg))
.unwrap_or_else(|| self.get_alloc_for_range(entry.index));
let range = entry.range;
log::debug!(
log::trace!(
"apply_allocations: vreg {:?} LR {:?} with range {:?} has alloc {:?} (pinned {:?})",
vreg,
entry.index,
@@ -258,7 +260,7 @@ impl<'a, F: Function> Env<'a, F> {
&& !self.is_start_of_block(range.from)
&& !first_is_def
{
log::debug!(
log::trace!(
"prev LR {} abuts LR {} in same block; moving {} -> {} for v{}",
prev.index(),
entry.index.index(),
@@ -292,9 +294,9 @@ impl<'a, F: Function> Env<'a, F> {
if range.to < self.cfginfo.block_exit[block.index()].next() {
break;
}
log::debug!("examining block with end in range: block{}", block.index());
log::trace!("examining block with end in range: block{}", block.index());
for &succ in self.func.block_succs(block) {
log::debug!(
log::trace!(
" -> has succ block {} with entry {:?}",
succ.index(),
self.cfginfo.block_entry[succ.index()]
@@ -302,9 +304,9 @@ impl<'a, F: Function> Env<'a, F> {
if range.contains_point(self.cfginfo.block_entry[succ.index()]) {
continue;
}
log::debug!(" -> out of this range, requires half-move if live");
log::trace!(" -> out of this range, requires half-move if live");
if self.is_live_in(succ, vreg) {
log::debug!(" -> live at input to succ, adding halfmove");
log::trace!(" -> live at input to succ, adding halfmove");
half_moves.push(HalfMove {
key: half_move_key(block, succ, vreg, HalfMoveKind::Source),
alloc,
@@ -315,7 +317,7 @@ impl<'a, F: Function> Env<'a, F> {
// Scan forward in `blockparam_outs`, adding all
// half-moves for outgoing values to blockparams
// in succs.
log::debug!(
log::trace!(
"scanning blockparam_outs for v{} block{}: blockparam_out_idx = {}",
vreg.index(),
block.index(),
@@ -328,7 +330,7 @@ impl<'a, F: Function> Env<'a, F> {
break;
}
if (from_vreg, from_block) == (vreg, block) {
log::debug!(
log::trace!(
" -> found: from v{} block{} to v{} block{}",
from_vreg.index(),
from_block.index(),
@@ -380,7 +382,7 @@ impl<'a, F: Function> Env<'a, F> {
}
// Add half-moves for blockparam inputs.
log::debug!(
log::trace!(
"scanning blockparam_ins at vreg {} block {}: blockparam_in_idx = {}",
vreg.index(),
block.index(),
@@ -402,7 +404,7 @@ impl<'a, F: Function> Env<'a, F> {
),
alloc,
});
log::debug!(
log::trace!(
"match: blockparam_in: v{} in block{} from block{} into {}",
to_vreg.index(),
to_block.index(),
@@ -433,7 +435,7 @@ impl<'a, F: Function> Env<'a, F> {
continue;
}
log::debug!(
log::trace!(
"scanning preds at vreg {} block {} for ends outside the range",
vreg.index(),
block.index()
@@ -442,7 +444,7 @@ impl<'a, F: Function> Env<'a, F> {
// Now find any preds whose ends are not in the
// same range, and insert appropriate moves.
for &pred in self.func.block_preds(block) {
log::debug!(
log::trace!(
"pred block {} has exit {:?}",
pred.index(),
self.cfginfo.block_exit[pred.index()]
@@ -450,7 +452,7 @@ impl<'a, F: Function> Env<'a, F> {
if range.contains_point(self.cfginfo.block_exit[pred.index()]) {
continue;
}
log::debug!(" -> requires half-move");
log::trace!(" -> requires half-move");
half_moves.push(HalfMove {
key: half_move_key(pred, block, vreg, HalfMoveKind::Dest),
alloc,
@@ -479,7 +481,7 @@ impl<'a, F: Function> Env<'a, F> {
// Scan over def/uses and apply allocations.
for use_idx in 0..self.ranges[entry.index.index()].uses.len() {
let usedata = self.ranges[entry.index.index()].uses[use_idx];
log::debug!("applying to use: {:?}", usedata);
log::trace!("applying to use: {:?}", usedata);
debug_assert!(range.contains_point(usedata.pos));
let inst = usedata.pos.inst();
let slot = usedata.slot;
@@ -508,7 +510,7 @@ impl<'a, F: Function> Env<'a, F> {
// covers only prev inst's After; so includes move
// srcs to (exclusive) inst.
let move_src_end = (vreg, range.to.inst());
log::debug!(
log::trace!(
"vreg {:?} range {:?}: looking for program-move sources from {:?} to {:?}",
vreg,
range,
@@ -518,13 +520,13 @@ impl<'a, F: Function> Env<'a, F> {
while prog_move_src_idx < self.prog_move_srcs.len()
&& self.prog_move_srcs[prog_move_src_idx].0 < move_src_start
{
log::debug!(" -> skipping idx {}", prog_move_src_idx);
log::trace!(" -> skipping idx {}", prog_move_src_idx);
prog_move_src_idx += 1;
}
while prog_move_src_idx < self.prog_move_srcs.len()
&& self.prog_move_srcs[prog_move_src_idx].0 < move_src_end
{
log::debug!(
log::trace!(
" -> setting idx {} ({:?}) to alloc {:?}",
prog_move_src_idx,
self.prog_move_srcs[prog_move_src_idx].0,
@@ -551,7 +553,7 @@ impl<'a, F: Function> Env<'a, F> {
} else {
(vreg, range.to.inst().next())
};
log::debug!(
log::trace!(
"vreg {:?} range {:?}: looking for program-move dests from {:?} to {:?}",
vreg,
range,
@@ -561,13 +563,13 @@ impl<'a, F: Function> Env<'a, F> {
while prog_move_dst_idx < self.prog_move_dsts.len()
&& self.prog_move_dsts[prog_move_dst_idx].0 < move_dst_start
{
log::debug!(" -> skipping idx {}", prog_move_dst_idx);
log::trace!(" -> skipping idx {}", prog_move_dst_idx);
prog_move_dst_idx += 1;
}
while prog_move_dst_idx < self.prog_move_dsts.len()
&& self.prog_move_dsts[prog_move_dst_idx].0 < move_dst_end
{
log::debug!(
log::trace!(
" -> setting idx {} ({:?}) to alloc {:?}",
prog_move_dst_idx,
self.prog_move_dsts[prog_move_dst_idx].0,
@@ -585,7 +587,7 @@ impl<'a, F: Function> Env<'a, F> {
// from-vreg) tuple, find the from-alloc and all the
// to-allocs, and insert moves on the block edge.
half_moves.sort_unstable_by_key(|h| h.key);
log::debug!("halfmoves: {:?}", half_moves);
log::trace!("halfmoves: {:?}", half_moves);
self.stats.halfmoves_count = half_moves.len();
let mut i = 0;
@@ -608,7 +610,7 @@ impl<'a, F: Function> Env<'a, F> {
}
let last_dest = i;
log::debug!(
log::trace!(
"halfmove match: src {:?} dests {:?}",
src,
&half_moves[first_dest..last_dest]
@@ -687,7 +689,7 @@ impl<'a, F: Function> Env<'a, F> {
for (progpoint, from_preg, to_preg, slot) in
std::mem::replace(&mut self.multi_fixed_reg_fixups, vec![])
{
log::debug!(
log::trace!(
"multi-fixed-move constraint at {:?} from p{} to p{}",
progpoint,
from_preg.index(),
@@ -761,7 +763,7 @@ impl<'a, F: Function> Env<'a, F> {
input_reused.push(input_idx);
let input_alloc = self.get_alloc(inst, input_idx);
let output_alloc = self.get_alloc(inst, output_idx);
log::debug!(
log::trace!(
"reuse-input inst {:?}: output {} has alloc {:?}, input {} has alloc {:?}",
inst,
output_idx,
@@ -808,7 +810,7 @@ impl<'a, F: Function> Env<'a, F> {
for (&((_, from_inst), from_alloc), &((to_vreg, to_inst), to_alloc)) in
prog_move_srcs.iter().zip(prog_move_dsts.iter())
{
log::debug!(
log::trace!(
"program move at inst {:?}: alloc {:?} -> {:?} (v{})",
from_inst,
from_alloc,
@@ -947,10 +949,10 @@ impl<'a, F: Function> Env<'a, F> {
// that can be done one at a time.
let scratch = self.env.scratch_by_class[regclass as u8 as usize];
let mut parallel_moves = ParallelMoves::new(Allocation::reg(scratch));
log::debug!("parallel moves at pos {:?} prio {:?}", pos, prio);
log::trace!("parallel moves at pos {:?} prio {:?}", pos, prio);
for m in moves {
if (m.from_alloc != m.to_alloc) || m.to_vreg.is_some() {
log::debug!(" {} -> {}", m.from_alloc, m.to_alloc,);
log::trace!(" {} -> {}", m.from_alloc, m.to_alloc,);
parallel_moves.add(m.from_alloc, m.to_alloc, m.to_vreg);
}
}
@@ -981,7 +983,7 @@ impl<'a, F: Function> Env<'a, F> {
let mut scratch_used_yet = false;
for (src, dst, to_vreg) in resolved {
log::debug!(" resolved: {} -> {} ({:?})", src, dst, to_vreg);
log::trace!(" resolved: {} -> {} ({:?})", src, dst, to_vreg);
let action = redundant_moves.process_move(src, dst, to_vreg);
if !action.elide {
if dst == Allocation::reg(scratch) {
@@ -1058,10 +1060,10 @@ impl<'a, F: Function> Env<'a, F> {
);
}
} else {
log::debug!(" -> redundant move elided");
log::trace!(" -> redundant move elided");
}
if let Some((alloc, vreg)) = action.def_alloc {
log::debug!(
log::trace!(
" -> converted to DefAlloc: alloc {} vreg {}",
alloc,
vreg
@@ -1072,7 +1074,7 @@ impl<'a, F: Function> Env<'a, F> {
}
for m in &self_moves {
log::debug!(
log::trace!(
"self move at pos {:?} prio {:?}: {} -> {} to_vreg {:?}",
pos,
prio,
@@ -1083,7 +1085,7 @@ impl<'a, F: Function> Env<'a, F> {
let action = redundant_moves.process_move(m.from_alloc, m.to_alloc, m.to_vreg);
assert!(action.elide);
if let Some((alloc, vreg)) = action.def_alloc {
log::debug!(" -> DefAlloc: alloc {} vreg {}", alloc, vreg);
log::trace!(" -> DefAlloc: alloc {} vreg {}", alloc, vreg);
self.add_edit(pos, prio, Edit::DefAlloc { alloc, vreg });
}
}

View File

@@ -19,7 +19,7 @@ use super::{
Requirement, UseList,
};
use crate::{
Allocation, Function, Inst, InstPosition, OperandKind, OperandConstraint, PReg, ProgPoint,
Allocation, Function, Inst, InstPosition, OperandConstraint, OperandKind, PReg, ProgPoint,
RegAllocError,
};
use fxhash::FxHashSet;
@@ -56,7 +56,7 @@ impl<'a, F: Function> Env<'a, F> {
// `AllocRegResult::ConflictHighCost`.
max_allowable_cost: Option<u32>,
) -> AllocRegResult {
log::debug!("try_to_allocate_bundle_to_reg: {:?} -> {:?}", bundle, reg);
log::trace!("try_to_allocate_bundle_to_reg: {:?} -> {:?}", bundle, reg);
let mut conflicts = smallvec![];
let mut conflict_set = FxHashSet::default();
let mut max_conflict_weight = 0;
@@ -83,7 +83,7 @@ impl<'a, F: Function> Env<'a, F> {
.btree
.range(from_key..)
.peekable();
log::debug!(
log::trace!(
"alloc map for {:?} in range {:?}..: {:?}",
reg,
from_key,
@@ -92,19 +92,19 @@ impl<'a, F: Function> Env<'a, F> {
let mut first_conflict: Option<ProgPoint> = None;
'ranges: for entry in bundle_ranges {
log::debug!(" -> range LR {:?}: {:?}", entry.index, entry.range);
log::trace!(" -> range LR {:?}: {:?}", entry.index, entry.range);
let key = LiveRangeKey::from_range(&entry.range);
let mut skips = 0;
'alloc: loop {
log::debug!(" -> PReg range {:?}", preg_range_iter.peek());
log::trace!(" -> PReg range {:?}", preg_range_iter.peek());
// Advance our BTree traversal until it is >= this bundle
// range (i.e., skip PReg allocations in the BTree that
// are completely before this bundle range).
if preg_range_iter.peek().is_some() && *preg_range_iter.peek().unwrap().0 < key {
log::debug!(
log::trace!(
"Skipping PReg range {:?}",
preg_range_iter.peek().unwrap().0
);
@@ -129,13 +129,13 @@ impl<'a, F: Function> Env<'a, F> {
// If there are no more PReg allocations, we're done!
if preg_range_iter.peek().is_none() {
log::debug!(" -> no more PReg allocations; so no conflict possible!");
log::trace!(" -> no more PReg allocations; so no conflict possible!");
break 'ranges;
}
// If the current PReg range is beyond this range, there is no conflict; continue.
if *preg_range_iter.peek().unwrap().0 > key {
log::debug!(
log::trace!(
" -> next PReg allocation is at {:?}; moving to next VReg range",
preg_range_iter.peek().unwrap().0
);
@@ -147,13 +147,13 @@ impl<'a, F: Function> Env<'a, F> {
assert_eq!(preg_key, key); // Assert that this range overlaps.
let preg_range = preg_range_iter.next().unwrap().1;
log::debug!(" -> btree contains range {:?} that overlaps", preg_range);
log::trace!(" -> btree contains range {:?} that overlaps", preg_range);
if preg_range.is_valid() {
log::debug!(" -> from vreg {:?}", self.ranges[preg_range.index()].vreg);
log::trace!(" -> from vreg {:?}", self.ranges[preg_range.index()].vreg);
// range from an allocated bundle: find the bundle and add to
// conflicts list.
let conflict_bundle = self.ranges[preg_range.index()].bundle;
log::debug!(" -> conflict bundle {:?}", conflict_bundle);
log::trace!(" -> conflict bundle {:?}", conflict_bundle);
if !conflict_set.contains(&conflict_bundle) {
conflicts.push(conflict_bundle);
conflict_set.insert(conflict_bundle);
@@ -164,7 +164,7 @@ impl<'a, F: Function> Env<'a, F> {
if max_allowable_cost.is_some()
&& max_conflict_weight > max_allowable_cost.unwrap()
{
log::debug!(" -> reached high cost, retrying early");
log::trace!(" -> reached high cost, retrying early");
return AllocRegResult::ConflictHighCost;
}
}
@@ -176,7 +176,7 @@ impl<'a, F: Function> Env<'a, F> {
)));
}
} else {
log::debug!(" -> conflict with fixed reservation");
log::trace!(" -> conflict with fixed reservation");
// range from a direct use of the PReg (due to clobber).
return AllocRegResult::ConflictWithFixed(
max_conflict_weight,
@@ -192,7 +192,7 @@ impl<'a, F: Function> Env<'a, F> {
// We can allocate! Add our ranges to the preg's BTree.
let preg = self.pregs[reg.index()].reg;
log::debug!(" -> bundle {:?} assigned to preg {:?}", bundle, preg);
log::trace!(" -> bundle {:?} assigned to preg {:?}", bundle, preg);
self.bundles[bundle.index()].allocation = Allocation::reg(preg);
for entry in &self.bundles[bundle.index()].ranges {
self.pregs[reg.index()]
@@ -205,7 +205,7 @@ impl<'a, F: Function> Env<'a, F> {
}
pub fn evict_bundle(&mut self, bundle: LiveBundleIndex) {
log::debug!(
log::trace!(
"evicting bundle {:?}: alloc {:?}",
bundle,
self.bundles[bundle.index()].allocation
@@ -213,7 +213,7 @@ impl<'a, F: Function> Env<'a, F> {
let preg = match self.bundles[bundle.index()].allocation.as_reg() {
Some(preg) => preg,
None => {
log::debug!(
log::trace!(
" -> has no allocation! {:?}",
self.bundles[bundle.index()].allocation
);
@@ -223,14 +223,14 @@ impl<'a, F: Function> Env<'a, F> {
let preg_idx = PRegIndex::new(preg.index());
self.bundles[bundle.index()].allocation = Allocation::none();
for entry in &self.bundles[bundle.index()].ranges {
log::debug!(" -> removing LR {:?} from reg {:?}", entry.index, preg_idx);
log::trace!(" -> removing LR {:?} from reg {:?}", entry.index, preg_idx);
self.pregs[preg_idx.index()]
.allocations
.btree
.remove(&LiveRangeKey::from_range(&entry.range));
}
let prio = self.bundles[bundle.index()].prio;
log::debug!(" -> prio {}; back into queue", prio);
log::trace!(" -> prio {}; back into queue", prio);
self.allocation_queue
.insert(bundle, prio as usize, PReg::invalid());
}
@@ -240,22 +240,22 @@ impl<'a, F: Function> Env<'a, F> {
}
pub fn maximum_spill_weight_in_bundle_set(&self, bundles: &LiveBundleVec) -> u32 {
log::debug!("maximum_spill_weight_in_bundle_set: {:?}", bundles);
log::trace!("maximum_spill_weight_in_bundle_set: {:?}", bundles);
let m = bundles
.iter()
.map(|&b| {
let w = self.bundles[b.index()].cached_spill_weight();
log::debug!("bundle{}: {}", b.index(), w);
log::trace!("bundle{}: {}", b.index(), w);
w
})
.max()
.unwrap_or(0);
log::debug!(" -> max: {}", m);
log::trace!(" -> max: {}", m);
m
}
pub fn recompute_bundle_properties(&mut self, bundle: LiveBundleIndex) {
log::debug!("recompute bundle properties: bundle {:?}", bundle);
log::trace!("recompute bundle properties: bundle {:?}", bundle);
let minimal;
let mut fixed = false;
@@ -267,18 +267,18 @@ impl<'a, F: Function> Env<'a, F> {
self.bundles[bundle.index()].prio = self.compute_bundle_prio(bundle);
if first_range_data.vreg.is_invalid() {
log::debug!(" -> no vreg; minimal and fixed");
log::trace!(" -> no vreg; minimal and fixed");
minimal = true;
fixed = true;
} else {
for u in &first_range_data.uses {
log::debug!(" -> use: {:?}", u);
log::trace!(" -> use: {:?}", u);
if let OperandConstraint::FixedReg(_) = u.operand.constraint() {
log::debug!(" -> fixed use at {:?}: {:?}", u.pos, u.operand);
log::trace!(" -> fixed use at {:?}: {:?}", u.pos, u.operand);
fixed = true;
}
if let OperandConstraint::Stack = u.operand.constraint() {
log::debug!(" -> stack use at {:?}: {:?}", u.pos, u.operand);
log::trace!(" -> stack use at {:?}: {:?}", u.pos, u.operand);
stack = true;
}
if stack && fixed {
@@ -289,7 +289,7 @@ impl<'a, F: Function> Env<'a, F> {
// that it could cover just one ProgPoint,
// i.e. X.Before..X.After, or two ProgPoints,
// i.e. X.Before..X+1.Before.
log::debug!(" -> first range has range {:?}", first_range_data.range);
log::trace!(" -> first range has range {:?}", first_range_data.range);
let bundle_start = self.bundles[bundle.index()]
.ranges
.first()
@@ -298,22 +298,22 @@ impl<'a, F: Function> Env<'a, F> {
.from;
let bundle_end = self.bundles[bundle.index()].ranges.last().unwrap().range.to;
minimal = bundle_start.inst() == bundle_end.prev().inst();
log::debug!(" -> minimal: {}", minimal);
log::trace!(" -> minimal: {}", minimal);
}
let spill_weight = if minimal {
if fixed {
log::debug!(" -> fixed and minimal: spill weight 2000000");
log::trace!(" -> fixed and minimal: spill weight 2000000");
2_000_000
} else {
log::debug!(" -> non-fixed and minimal: spill weight 1000000");
log::trace!(" -> non-fixed and minimal: spill weight 1000000");
1_000_000
}
} else {
let mut total = 0;
for entry in &self.bundles[bundle.index()].ranges {
let range_data = &self.ranges[entry.index.index()];
log::debug!(
log::trace!(
" -> uses spill weight: +{}",
range_data.uses_spill_weight()
);
@@ -321,7 +321,7 @@ impl<'a, F: Function> Env<'a, F> {
}
if self.bundles[bundle.index()].prio > 0 {
log::debug!(
log::trace!(
" -> dividing by prio {}; final weight {}",
self.bundles[bundle.index()].prio,
total / self.bundles[bundle.index()].prio
@@ -349,7 +349,7 @@ impl<'a, F: Function> Env<'a, F> {
let mut w = 0;
for u in &rangedata.uses {
w += u.weight as u32;
log::debug!("range{}: use {:?}", range.index(), u);
log::trace!("range{}: use {:?}", range.index(), u);
}
rangedata.set_uses_spill_weight(w);
if rangedata.uses.len() > 0 && rangedata.uses[0].operand.kind() == OperandKind::Def {
@@ -413,7 +413,7 @@ impl<'a, F: Function> Env<'a, F> {
reg_hint: PReg,
) {
self.stats.splits += 1;
log::debug!(
log::trace!(
"split bundle {:?} at {:?} and requeue with reg hint (for first part) {:?}",
bundle,
split_at,
@@ -451,7 +451,7 @@ impl<'a, F: Function> Env<'a, F> {
break 'outer;
}
}
log::debug!(" -> first use loc is {:?}", first_use);
log::trace!(" -> first use loc is {:?}", first_use);
split_at = match first_use {
Some(pos) => {
if pos.inst() == bundle_start.inst() {
@@ -471,7 +471,7 @@ impl<'a, F: Function> Env<'a, F> {
.next(),
),
};
log::debug!(
log::trace!(
"split point is at bundle start; advancing to {:?}",
split_at
);
@@ -493,7 +493,7 @@ impl<'a, F: Function> Env<'a, F> {
// which LR we need to split down the middle, then update the
// current bundle, create a new one, and (re)-queue both.
log::debug!(" -> LRs: {:?}", self.bundles[bundle.index()].ranges);
log::trace!(" -> LRs: {:?}", self.bundles[bundle.index()].ranges);
let mut last_lr_in_old_bundle_idx = 0; // last LR-list index in old bundle
let mut first_lr_in_new_bundle_idx = 0; // first LR-list index in new bundle
@@ -508,11 +508,11 @@ impl<'a, F: Function> Env<'a, F> {
}
}
log::debug!(
log::trace!(
" -> last LR in old bundle: LR {:?}",
self.bundles[bundle.index()].ranges[last_lr_in_old_bundle_idx]
);
log::debug!(
log::trace!(
" -> first LR in new bundle: LR {:?}",
self.bundles[bundle.index()].ranges[first_lr_in_new_bundle_idx]
);
@@ -539,7 +539,7 @@ impl<'a, F: Function> Env<'a, F> {
to: new_lr_list[0].range.to,
});
self.ranges[new_lr.index()].vreg = self.ranges[orig_lr.index()].vreg;
log::debug!(" -> splitting LR {:?} into {:?}", orig_lr, new_lr);
log::trace!(" -> splitting LR {:?} into {:?}", orig_lr, new_lr);
let first_use = self.ranges[orig_lr.index()]
.uses
.iter()
@@ -576,7 +576,7 @@ impl<'a, F: Function> Env<'a, F> {
}
let new_bundle = self.create_bundle();
log::debug!(" -> creating new bundle {:?}", new_bundle);
log::trace!(" -> creating new bundle {:?}", new_bundle);
self.bundles[new_bundle.index()].spillset = spillset;
for entry in &new_lr_list {
self.ranges[entry.index.index()].bundle = new_bundle;
@@ -598,7 +598,7 @@ impl<'a, F: Function> Env<'a, F> {
let spill = self
.get_or_create_spill_bundle(bundle, /* create_if_absent = */ true)
.unwrap();
log::debug!(
log::trace!(
" -> bundle {:?} range {:?}: no uses; moving to spill bundle {:?}",
bundle,
entry.index,
@@ -643,13 +643,13 @@ impl<'a, F: Function> Env<'a, F> {
range,
index: empty_lr,
});
log::debug!(
log::trace!(
" -> bundle {:?} range {:?}: last use implies split point {:?}",
bundle,
entry.index,
split
);
log::debug!(
log::trace!(
" -> moving trailing empty region to new spill bundle {:?} with new LR {:?}",
spill,
empty_lr
@@ -668,7 +668,7 @@ impl<'a, F: Function> Env<'a, F> {
let spill = self
.get_or_create_spill_bundle(new_bundle, /* create_if_absent = */ true)
.unwrap();
log::debug!(
log::trace!(
" -> bundle {:?} range {:?}: no uses; moving to spill bundle {:?}",
new_bundle,
entry.index,
@@ -713,13 +713,13 @@ impl<'a, F: Function> Env<'a, F> {
range,
index: empty_lr,
});
log::debug!(
log::trace!(
" -> bundle {:?} range {:?}: first use implies split point {:?}",
bundle,
entry.index,
first_use,
);
log::debug!(
log::trace!(
" -> moving leading empty region to new spill bundle {:?} with new LR {:?}",
spill,
empty_lr
@@ -754,7 +754,7 @@ impl<'a, F: Function> Env<'a, F> {
} else {
self.spillsets[self.bundles[bundle.index()].spillset.index()].reg_hint
};
log::debug!("process_bundle: bundle {:?} hint {:?}", bundle, hint_reg,);
log::trace!("process_bundle: bundle {:?} hint {:?}", bundle, hint_reg,);
if let Requirement::Conflict = req {
// We have to split right away. We'll find a point to
@@ -797,7 +797,7 @@ impl<'a, F: Function> Env<'a, F> {
let mut attempts = 0;
loop {
attempts += 1;
log::debug!("attempt {}, req {:?}", attempts, req);
log::trace!("attempt {}, req {:?}", attempts, req);
debug_assert!(attempts < 100 * self.func.insts());
let (class, fixed_preg) = match req {
@@ -851,7 +851,7 @@ impl<'a, F: Function> Env<'a, F> {
) {
self.stats.process_bundle_reg_probes_any += 1;
let preg_idx = PRegIndex::new(preg.index());
log::debug!("trying preg {:?}", preg_idx);
log::trace!("trying preg {:?}", preg_idx);
let scan_limit_cost = match (
lowest_cost_evict_conflict_cost,
@@ -863,13 +863,13 @@ impl<'a, F: Function> Env<'a, F> {
match self.try_to_allocate_bundle_to_reg(bundle, preg_idx, scan_limit_cost) {
AllocRegResult::Allocated(alloc) => {
self.stats.process_bundle_reg_success_any += 1;
log::debug!(" -> allocated to any {:?}", preg_idx);
log::trace!(" -> allocated to any {:?}", preg_idx);
self.spillsets[self.bundles[bundle.index()].spillset.index()].reg_hint =
alloc.as_reg().unwrap();
return Ok(());
}
AllocRegResult::Conflict(bundles, first_conflict_point) => {
log::debug!(
log::trace!(
" -> conflict with bundles {:?}, first conflict at {:?}",
bundles,
first_conflict_point
@@ -901,7 +901,7 @@ impl<'a, F: Function> Env<'a, F> {
}
}
AllocRegResult::ConflictWithFixed(max_cost, point) => {
log::debug!(" -> conflict with fixed alloc; cost of other bundles up to point is {}, conflict at {:?}", max_cost, point);
log::trace!(" -> conflict with fixed alloc; cost of other bundles up to point is {}, conflict at {:?}", max_cost, point);
let loop_depth = self.cfginfo.approx_loop_depth
[self.cfginfo.insn_block[point.inst().index()].index()];
@@ -932,12 +932,12 @@ impl<'a, F: Function> Env<'a, F> {
// any with current bundle assignments. Hence, we will need
// to either split or attempt to evict some bundles.
log::debug!(
log::trace!(
" -> lowest cost evict: set {:?}, cost {:?}",
lowest_cost_evict_conflict_set,
lowest_cost_evict_conflict_cost,
);
log::debug!(
log::trace!(
" -> lowest cost split: cost {:?}, point {:?}, reg {:?}",
lowest_cost_split_conflict_cost,
lowest_cost_split_conflict_point,
@@ -951,7 +951,7 @@ impl<'a, F: Function> Env<'a, F> {
);
let our_spill_weight = self.bundle_spill_weight(bundle);
log::debug!(" -> our spill weight: {}", our_spill_weight);
log::trace!(" -> our spill weight: {}", our_spill_weight);
// We detect the "too-many-live-registers" case here and
// return an error cleanly, rather than panicking, because
@@ -966,7 +966,7 @@ impl<'a, F: Function> Env<'a, F> {
if let Requirement::Register(class) = req {
// Check if this is a too-many-live-registers situation.
let range = self.bundles[bundle.index()].ranges[0].range;
log::debug!("checking for too many live regs");
log::trace!("checking for too many live regs");
let mut min_bundles_assigned = 0;
let mut fixed_assigned = 0;
let mut total_regs = 0;
@@ -974,7 +974,7 @@ impl<'a, F: Function> Env<'a, F> {
.iter()
.chain(self.env.non_preferred_regs_by_class[class as u8 as usize].iter())
{
log::debug!(" -> PR {:?}", preg);
log::trace!(" -> PR {:?}", preg);
let start = LiveRangeKey::from_range(&CodeRange {
from: range.from.prev(),
to: range.from.prev(),
@@ -989,19 +989,19 @@ impl<'a, F: Function> Env<'a, F> {
}
if lr.is_valid() {
if self.minimal_bundle(self.ranges[lr.index()].bundle) {
log::debug!(" -> min bundle {:?}", lr);
log::trace!(" -> min bundle {:?}", lr);
min_bundles_assigned += 1;
} else {
log::debug!(" -> non-min bundle {:?}", lr);
log::trace!(" -> non-min bundle {:?}", lr);
}
} else {
log::debug!(" -> fixed bundle");
log::trace!(" -> fixed bundle");
fixed_assigned += 1;
}
}
total_regs += 1;
}
log::debug!(
log::trace!(
" -> total {}, fixed {}, min {}",
total_regs,
fixed_assigned,
@@ -1033,7 +1033,7 @@ impl<'a, F: Function> Env<'a, F> {
|| lowest_cost_evict_conflict_cost.is_none()
|| our_spill_weight <= lowest_cost_evict_conflict_cost.unwrap())
{
log::debug!(
log::trace!(
" -> deciding to split: our spill weight is {}",
self.bundle_spill_weight(bundle)
);
@@ -1066,7 +1066,7 @@ impl<'a, F: Function> Env<'a, F> {
// Evict all bundles in `conflicting bundles` and try again.
self.stats.evict_bundle_event += 1;
for &bundle in &lowest_cost_evict_conflict_set.unwrap() {
log::debug!(" -> evicting {:?}", bundle);
log::trace!(" -> evicting {:?}", bundle);
self.evict_bundle(bundle);
self.stats.evict_bundle_count += 1;
}

View File

@@ -40,13 +40,13 @@ impl RedundantMoveEliminator {
.map(|&p| p)
.unwrap_or(RedundantMoveState::None);
log::debug!(
log::trace!(
" -> redundant move tracker: from {} to {} to_vreg {:?}",
from,
to,
to_vreg
);
log::debug!(
log::trace!(
" -> from_state {:?} to_state {:?}",
from_state,
to_state
@@ -67,29 +67,29 @@ impl RedundantMoveEliminator {
RedundantMoveState::Orig(r) => Some(r),
_ => None,
};
log::debug!(" -> src_vreg {:?}", src_vreg);
log::trace!(" -> src_vreg {:?}", src_vreg);
let dst_vreg = to_vreg.or(src_vreg);
log::debug!(" -> dst_vreg {:?}", dst_vreg);
log::trace!(" -> dst_vreg {:?}", dst_vreg);
let existing_dst_vreg = match to_state {
RedundantMoveState::Copy(_, opt_r) => opt_r,
RedundantMoveState::Orig(r) => Some(r),
_ => None,
};
log::debug!(" -> existing_dst_vreg {:?}", existing_dst_vreg);
log::trace!(" -> existing_dst_vreg {:?}", existing_dst_vreg);
let elide = match (from_state, to_state) {
(_, RedundantMoveState::Copy(orig_alloc, _)) if orig_alloc == from => true,
(RedundantMoveState::Copy(new_alloc, _), _) if new_alloc == to => true,
_ => false,
};
log::debug!(" -> elide {}", elide);
log::trace!(" -> elide {}", elide);
let def_alloc = if dst_vreg != existing_dst_vreg && dst_vreg.is_some() {
Some((to, dst_vreg.unwrap()))
} else {
None
};
log::debug!(" -> def_alloc {:?}", def_alloc);
log::trace!(" -> def_alloc {:?}", def_alloc);
// Invalidate all existing copies of `to` if `to` actually changed value.
if !elide {
@@ -100,7 +100,7 @@ impl RedundantMoveEliminator {
if from.is_reg() || to.is_reg() {
self.allocs
.insert(to, RedundantMoveState::Copy(from, dst_vreg));
log::debug!(
log::trace!(
" -> create mapping {} -> {:?}",
to,
RedundantMoveState::Copy(from, dst_vreg)
@@ -115,16 +115,16 @@ impl RedundantMoveEliminator {
}
pub fn clear(&mut self) {
log::debug!(" redundant move eliminator cleared");
log::trace!(" redundant move eliminator cleared");
self.allocs.clear();
self.reverse_allocs.clear();
}
pub fn clear_alloc(&mut self, alloc: Allocation) {
log::debug!(" redundant move eliminator: clear {:?}", alloc);
log::trace!(" redundant move eliminator: clear {:?}", alloc);
if let Some(ref mut existing_copies) = self.reverse_allocs.get_mut(&alloc) {
for to_inval in existing_copies.iter() {
log::debug!(" -> clear existing copy: {:?}", to_inval);
log::trace!(" -> clear existing copy: {:?}", to_inval);
if let Some(val) = self.allocs.get_mut(to_inval) {
match val {
RedundantMoveState::Copy(_, Some(vreg)) => {

View File

@@ -66,7 +66,9 @@ impl Requirement {
pub fn from_operand(op: Operand) -> Requirement {
match op.constraint() {
OperandConstraint::FixedReg(preg) => Requirement::Fixed(preg),
OperandConstraint::Reg | OperandConstraint::Reuse(_) => Requirement::Register(op.class()),
OperandConstraint::Reg | OperandConstraint::Reuse(_) => {
Requirement::Register(op.class())
}
OperandConstraint::Stack => Requirement::Stack(op.class()),
_ => Requirement::Any(op.class()),
}
@@ -76,17 +78,17 @@ impl Requirement {
impl<'a, F: Function> Env<'a, F> {
pub fn compute_requirement(&self, bundle: LiveBundleIndex) -> Requirement {
let mut req = Requirement::Unknown;
log::debug!("compute_requirement: {:?}", bundle);
log::trace!("compute_requirement: {:?}", bundle);
for entry in &self.bundles[bundle.index()].ranges {
log::debug!(" -> LR {:?}", entry.index);
log::trace!(" -> LR {:?}", entry.index);
for u in &self.ranges[entry.index.index()].uses {
log::debug!(" -> use {:?}", u);
log::trace!(" -> use {:?}", u);
let r = Requirement::from_operand(u.operand);
req = req.merge(r);
log::debug!(" -> req {:?}", req);
log::trace!(" -> req {:?}", req);
}
}
log::debug!(" -> final: {:?}", req);
log::trace!(" -> final: {:?}", req);
req
}
}

View File

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

View File

@@ -31,10 +31,10 @@ impl<'a, F: Function> Env<'a, F> {
// safepoints; and for each safepoint in the current range,
// emit the allocation into the `safepoint_slots` list.
log::debug!("safepoints_per_vreg = {:?}", self.safepoints_per_vreg);
log::trace!("safepoints_per_vreg = {:?}", self.safepoints_per_vreg);
for vreg in self.func.reftype_vregs() {
log::debug!("generating safepoint info for vreg {}", vreg);
log::trace!("generating safepoint info for vreg {}", vreg);
let vreg = VRegIndex::new(vreg.vreg());
let mut safepoints: Vec<ProgPoint> = self
.safepoints_per_vreg
@@ -44,19 +44,19 @@ impl<'a, F: Function> Env<'a, F> {
.map(|&inst| ProgPoint::before(inst))
.collect();
safepoints.sort_unstable();
log::debug!(" -> live over safepoints: {:?}", safepoints);
log::trace!(" -> live over safepoints: {:?}", safepoints);
let mut safepoint_idx = 0;
for entry in &self.vregs[vreg.index()].ranges {
let range = entry.range;
let alloc = self.get_alloc_for_range(entry.index);
log::debug!(" -> range {:?}: alloc {}", range, alloc);
log::trace!(" -> range {:?}: alloc {}", range, alloc);
while safepoint_idx < safepoints.len() && safepoints[safepoint_idx] < range.to {
if safepoints[safepoint_idx] < range.from {
safepoint_idx += 1;
continue;
}
log::debug!(" -> covers safepoint {:?}", safepoints[safepoint_idx]);
log::trace!(" -> covers safepoint {:?}", safepoints[safepoint_idx]);
let slot = alloc
.as_stack()
@@ -68,6 +68,6 @@ impl<'a, F: Function> Env<'a, F> {
}
self.safepoint_slots.sort_unstable();
log::debug!("final safepoint slots info: {:?}", self.safepoint_slots);
log::trace!("final safepoint slots info: {:?}", self.safepoint_slots);
}
}

View File

@@ -228,7 +228,12 @@ pub struct Operand {
impl Operand {
#[inline(always)]
pub fn new(vreg: VReg, constraint: OperandConstraint, kind: OperandKind, pos: OperandPos) -> Self {
pub fn new(
vreg: VReg,
constraint: OperandConstraint,
kind: OperandKind,
pos: OperandPos,
) -> Self {
let (preg_field, constraint_field): (u32, u32) = match constraint {
OperandConstraint::Any => (0, 0),
OperandConstraint::Reg => (0, 1),