Merge pull request #20 from cfallin/fuzzbug-fix
Fix fuzzbug related to bundle priority ordering.
This commit is contained in:
@@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Allocation, AllocationKind, Block, Edit, Function, Inst, InstPosition, Operand,
|
Allocation, AllocationKind, Block, Edit, Function, Inst, InstPosition, Operand,
|
||||||
OperandConstraint, OperandKind, OperandPos, Output, PReg, ProgPoint, RegClass, VReg,
|
OperandConstraint, OperandKind, OperandPos, Output, PReg, ProgPoint, VReg,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::collections::{HashMap, HashSet, VecDeque};
|
use std::collections::{HashMap, HashSet, VecDeque};
|
||||||
|
|||||||
@@ -185,6 +185,11 @@ pub struct LiveBundle {
|
|||||||
pub spill_weight_and_props: u32,
|
pub spill_weight_and_props: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const BUNDLE_MAX_SPILL_WEIGHT: u32 = (1 << 29) - 1;
|
||||||
|
pub const MINIMAL_FIXED_BUNDLE_SPILL_WEIGHT: u32 = BUNDLE_MAX_SPILL_WEIGHT;
|
||||||
|
pub const MINIMAL_BUNDLE_SPILL_WEIGHT: u32 = BUNDLE_MAX_SPILL_WEIGHT - 1;
|
||||||
|
pub const BUNDLE_MAX_NORMAL_SPILL_WEIGHT: u32 = BUNDLE_MAX_SPILL_WEIGHT - 2;
|
||||||
|
|
||||||
impl LiveBundle {
|
impl LiveBundle {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn set_cached_spill_weight_and_props(
|
pub fn set_cached_spill_weight_and_props(
|
||||||
@@ -194,7 +199,7 @@ impl LiveBundle {
|
|||||||
fixed: bool,
|
fixed: bool,
|
||||||
stack: bool,
|
stack: bool,
|
||||||
) {
|
) {
|
||||||
debug_assert!(spill_weight < ((1 << 29) - 1));
|
debug_assert!(spill_weight <= BUNDLE_MAX_SPILL_WEIGHT);
|
||||||
self.spill_weight_and_props = spill_weight
|
self.spill_weight_and_props = spill_weight
|
||||||
| (if minimal { 1 << 31 } else { 0 })
|
| (if minimal { 1 << 31 } else { 0 })
|
||||||
| (if fixed { 1 << 30 } else { 0 })
|
| (if fixed { 1 << 30 } else { 0 })
|
||||||
|
|||||||
@@ -13,11 +13,15 @@
|
|||||||
//! Main allocation loop that processes bundles.
|
//! Main allocation loop that processes bundles.
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
spill_weight_from_constraint, CodeRange, Env, LiveBundleIndex, LiveBundleVec, LiveRangeFlag,
|
spill_weight_from_constraint, Env, LiveBundleIndex, LiveBundleVec, LiveRangeFlag,
|
||||||
LiveRangeIndex, LiveRangeKey, LiveRangeList, LiveRangeListEntry, PRegIndex, RegTraversalIter,
|
LiveRangeIndex, LiveRangeKey, LiveRangeList, LiveRangeListEntry, PRegIndex, RegTraversalIter,
|
||||||
Requirement, SpillWeight, UseList,
|
Requirement, SpillWeight, UseList,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
ion::data_structures::{
|
||||||
|
CodeRange, BUNDLE_MAX_NORMAL_SPILL_WEIGHT, MINIMAL_BUNDLE_SPILL_WEIGHT,
|
||||||
|
MINIMAL_FIXED_BUNDLE_SPILL_WEIGHT,
|
||||||
|
},
|
||||||
Allocation, Function, Inst, InstPosition, OperandConstraint, OperandKind, PReg, ProgPoint,
|
Allocation, Function, Inst, InstPosition, OperandConstraint, OperandKind, PReg, ProgPoint,
|
||||||
RegAllocError,
|
RegAllocError,
|
||||||
};
|
};
|
||||||
@@ -302,11 +306,11 @@ impl<'a, F: Function> Env<'a, F> {
|
|||||||
|
|
||||||
let spill_weight = if minimal {
|
let spill_weight = if minimal {
|
||||||
if fixed {
|
if fixed {
|
||||||
log::trace!(" -> fixed and minimal: spill weight 2000000");
|
log::trace!(" -> fixed and minimal");
|
||||||
2_000_000
|
MINIMAL_FIXED_BUNDLE_SPILL_WEIGHT
|
||||||
} else {
|
} else {
|
||||||
log::trace!(" -> non-fixed and minimal: spill weight 1000000");
|
log::trace!(" -> non-fixed and minimal");
|
||||||
1_000_000
|
MINIMAL_BUNDLE_SPILL_WEIGHT
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut total = SpillWeight::zero();
|
let mut total = SpillWeight::zero();
|
||||||
@@ -326,7 +330,7 @@ impl<'a, F: Function> Env<'a, F> {
|
|||||||
self.bundles[bundle.index()].prio,
|
self.bundles[bundle.index()].prio,
|
||||||
final_weight
|
final_weight
|
||||||
);
|
);
|
||||||
final_weight
|
std::cmp::min(BUNDLE_MAX_NORMAL_SPILL_WEIGHT, final_weight)
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user