Fuzzbug fix: fix some weirdness with BTree iteration inner loop
This commit is contained in:
@@ -2473,38 +2473,41 @@ impl<'a, F: Function> Env<'a, F> {
|
||||
// literally the range `range`.
|
||||
let bundle_ranges = &self.bundles[bundle.index()].ranges;
|
||||
let from_key = LiveRangeKey::from_range(&bundle_ranges.first().unwrap().range);
|
||||
let to_key = LiveRangeKey::from_range(&bundle_ranges.last().unwrap().range);
|
||||
assert!(from_key <= to_key);
|
||||
let mut preg_range_iter = self.pregs[reg.index()]
|
||||
.allocations
|
||||
.btree
|
||||
.range(from_key..=to_key)
|
||||
.range(from_key..)
|
||||
.peekable();
|
||||
log::debug!(
|
||||
"alloc map for {:?}: {:?}",
|
||||
"alloc map for {:?} in range {:?}..: {:?}",
|
||||
reg,
|
||||
from_key,
|
||||
self.pregs[reg.index()].allocations.btree
|
||||
);
|
||||
for entry in bundle_ranges {
|
||||
'ranges: for entry in bundle_ranges {
|
||||
log::debug!(" -> range LR {:?}: {:?}", entry.index, entry.range);
|
||||
let key = LiveRangeKey::from_range(&entry.range);
|
||||
|
||||
'alloc: loop {
|
||||
log::debug!(" -> 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).
|
||||
|
||||
while preg_range_iter.peek().is_some() && *preg_range_iter.peek().unwrap().0 < key {
|
||||
if preg_range_iter.peek().is_some() && *preg_range_iter.peek().unwrap().0 < key {
|
||||
log::debug!(
|
||||
"Skipping PReg range {:?}",
|
||||
preg_range_iter.peek().unwrap().0
|
||||
);
|
||||
preg_range_iter.next();
|
||||
continue 'alloc;
|
||||
}
|
||||
|
||||
// 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!");
|
||||
break;
|
||||
break 'ranges;
|
||||
}
|
||||
|
||||
// If the current PReg range is beyond this range, there is no conflict; continue.
|
||||
@@ -2513,7 +2516,7 @@ impl<'a, F: Function> Env<'a, F> {
|
||||
" -> next PReg allocation is at {:?}; moving to next VReg range",
|
||||
preg_range_iter.peek().unwrap().0
|
||||
);
|
||||
continue;
|
||||
break 'alloc;
|
||||
}
|
||||
|
||||
// Otherwise, there is a conflict.
|
||||
@@ -2537,6 +2540,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");
|
||||
return AllocRegResult::ConflictHighCost;
|
||||
}
|
||||
}
|
||||
@@ -2549,6 +2553,7 @@ impl<'a, F: Function> Env<'a, F> {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if conflicts.len() > 0 {
|
||||
return AllocRegResult::Conflict(conflicts);
|
||||
|
||||
Reference in New Issue
Block a user