diff --git a/cranelift/codegen/src/regalloc/affinity.rs b/cranelift/codegen/src/regalloc/affinity.rs index b7fa3090ca..efcc4dabfa 100644 --- a/cranelift/codegen/src/regalloc/affinity.rs +++ b/cranelift/codegen/src/regalloc/affinity.rs @@ -92,10 +92,8 @@ impl Affinity { // to change anything. if constraint.kind != ConstraintKind::Stack && !constraint.regclass.has_subclass(rc) { - // If the register classes don't overlap, `intersect` returns `Unassigned`, and - // we just keep our previous affinity. + // If the register classes overlap, try to shrink our preferred register class. if let Some(subclass) = constraint.regclass.intersect_index(reginfo.rc(rc)) { - // This constraint shrinks our preferred register class. *self = Self::Reg(subclass); } } diff --git a/cranelift/codegen/src/regalloc/liveness.rs b/cranelift/codegen/src/regalloc/liveness.rs index 1b9784a198..f195645809 100644 --- a/cranelift/codegen/src/regalloc/liveness.rs +++ b/cranelift/codegen/src/regalloc/liveness.rs @@ -389,7 +389,6 @@ impl Liveness { // The liveness computation needs to visit all uses, but the order doesn't matter. // TODO: Perhaps this traversal of the function could be combined with a dead code // elimination pass if we visit a post-order of the dominator tree? - // TODO: Resolve value aliases while we're visiting instructions? for ebb in func.layout.ebbs() { // Make sure we have created live ranges for dead EBB parameters. // TODO: If these parameters are really dead, we could remove them, except for the @@ -436,11 +435,9 @@ impl Liveness { impl Index for Liveness { type Output = LiveRange; - fn index(&self, index: Value) -> &LiveRange { - match self.ranges.get(index) { - Some(lr) => lr, - None => panic!("{} has no live range", index), - } + self.ranges + .get(index) + .unwrap_or_else(|| panic!("{} has no live range", index)) } }