Skip to content

Commit 97d0894

Browse files
committed
Detect when limits prevent allocation
In `Env::process_bundle`, we check if allocation _must_ fail and return a `RegAllocError::TooManyLiveRegs`. This change extends the current logic to understand how limit constraints affect this calculation.
1 parent 4b0c5ff commit 97d0894

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/ion/process.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ impl<'a, F: Function> Env<'a, F> {
10361036

10371037
let fixed_preg = match req {
10381038
Requirement::FixedReg(preg) | Requirement::FixedStack(preg) => Some(preg),
1039-
Requirement::Register => None,
1039+
Requirement::Register | Requirement::Limit(..) => None,
10401040
Requirement::Stack => {
10411041
// If we must be on the stack, mark our spillset
10421042
// as required immediately.
@@ -1200,7 +1200,7 @@ impl<'a, F: Function> Env<'a, F> {
12001200
|| lowest_cost_evict_conflict_cost.is_none()
12011201
|| lowest_cost_evict_conflict_cost.unwrap() >= our_spill_weight)
12021202
{
1203-
if let Requirement::Register = req {
1203+
if matches!(req, Requirement::Register | Requirement::Limit(_)) {
12041204
// Check if this is a too-many-live-registers situation.
12051205
let range = self.ctx.bundles[bundle].ranges[0].range;
12061206
trace!("checking for too many live regs");
@@ -1240,6 +1240,15 @@ impl<'a, F: Function> Env<'a, F> {
12401240
fixed_assigned += 1;
12411241
}
12421242
}
1243+
1244+
// We also need to discard any registers that do not fit
1245+
// under the limit--we cannot allocate to them.
1246+
if let Requirement::Limit(limit) = req {
1247+
if preg.hw_enc() >= limit as usize {
1248+
continue;
1249+
}
1250+
}
1251+
12431252
total_regs += 1;
12441253
}
12451254
trace!(

0 commit comments

Comments
 (0)