From 518c7526d24ed061bc6c505d55f5fb275bec462b Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 14 Feb 2020 13:24:13 -0800 Subject: [PATCH] Fix incorrect register calculation in `RegBank::unit_by_name` --- cranelift/codegen/meta/src/cdsl/regs.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cranelift/codegen/meta/src/cdsl/regs.rs b/cranelift/codegen/meta/src/cdsl/regs.rs index 98a5751f2e..864826ee43 100644 --- a/cranelift/codegen/meta/src/cdsl/regs.rs +++ b/cranelift/codegen/meta/src/cdsl/regs.rs @@ -57,12 +57,12 @@ impl RegBank { // Ultimate try: try to parse a number and use this in the array, eg r15 on x86. if let Ok(as_num) = name_without_prefix.parse::() { assert!( - (as_num - self.first_unit) < self.units, + as_num < self.units, "trying to get {}, but bank only has {} registers!", name, self.units ); - (as_num - self.first_unit) as usize + as_num as usize } else { panic!("invalid register name {}", name); }