From ac7d9f9e90ca8699e5da96c2f7b90d69e5dd8f8a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 16 Dec 2024 09:41:24 -0800 Subject: [PATCH] Fix table64 addressing on 32-bit --- crates/cranelift/src/translate/table.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/cranelift/src/translate/table.rs b/crates/cranelift/src/translate/table.rs index 9fa7ce8e39ba..cd6ae8bfb97a 100644 --- a/crates/cranelift/src/translate/table.rs +++ b/crates/cranelift/src/translate/table.rs @@ -82,8 +82,10 @@ impl TableData { } // Convert `index` to `addr_ty`. - if index_ty != addr_ty { + if addr_ty.bytes() > index_ty.bytes() { index = pos.ins().uextend(addr_ty, index); + } else if addr_ty.bytes() < index_ty.bytes() { + index = pos.ins().ireduce(addr_ty, index); } // Add the table base address base