diff --git a/src/backend/localify.rs b/src/backend/localify.rs index 4a95427..aa23ac3 100644 --- a/src/backend/localify.rs +++ b/src/backend/localify.rs @@ -242,6 +242,16 @@ impl<'a> Context<'a> { let mut freelist: HashMap> = HashMap::new(); for i in 0..self.points { + // Process ends. (Ends are exclusive, so we do them + // first; another range can grab the local at the same + // point index in this same iteration.) + if let Some(expiring) = expiring.remove(&i) { + for (ty, local) in expiring { + log::trace!(" -> expiring {} of type {} back to freelist", local, ty); + freelist.entry(ty).or_insert_with(|| vec![]).push(local); + } + } + // Process starts. while range_idx < ranges.len() && ranges[range_idx].1.start == i { let (value, range) = ranges[range_idx].clone(); @@ -279,16 +289,6 @@ impl<'a> Context<'a> { } self.results.values[value] = allocs; } - - // Process ends. (Ends are exclusive, so we do them - // first; another range can grab the local at the same - // point index in this same iteration.) - if let Some(expiring) = expiring.remove(&i) { - for (ty, local) in expiring { - log::trace!(" -> expiring {} of type {} back to freelist", local, ty); - freelist.entry(ty).or_insert_with(|| vec![]).push(local); - } - } } }