Skip to content

Commit 31995fa

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 031ca47 commit 31995fa

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
@@ -1042,7 +1042,7 @@ impl<'a, F: Function> Env<'a, F> {
10421042

10431043
let fixed_preg = match req {
10441044
Requirement::FixedReg(preg) | Requirement::FixedStack(preg) => Some(preg),
1045-
Requirement::Register => None,
1045+
Requirement::Register | Requirement::Limit(..) => None,
10461046
Requirement::Stack => {
10471047
// If we must be on the stack, mark our spillset
10481048
// as required immediately.
@@ -1204,7 +1204,7 @@ impl<'a, F: Function> Env<'a, F> {
12041204
|| lowest_cost_evict_conflict_cost.is_none()
12051205
|| lowest_cost_evict_conflict_cost.unwrap() >= our_spill_weight)
12061206
{
1207-
if let Requirement::Register = req {
1207+
if matches!(req, Requirement::Register | Requirement::Limit(_)) {
12081208
// Check if this is a too-many-live-registers situation.
12091209
let range = self.ctx.bundles[bundle].ranges[0].range;
12101210
trace!("checking for too many live regs");
@@ -1244,6 +1244,15 @@ impl<'a, F: Function> Env<'a, F> {
12441244
fixed_assigned += 1;
12451245
}
12461246
}
1247+
1248+
// We also need to discard any registers that do not fit
1249+
// under the limit--we cannot allocate to them.
1250+
if let Requirement::Limit(limit) = req {
1251+
if preg.hw_enc() >= limit as usize {
1252+
continue;
1253+
}
1254+
}
1255+
12471256
total_regs += 1;
12481257
}
12491258
trace!(

0 commit comments

Comments
 (0)