From 2fc1f9b9716f8561c94ecdeb8196ac4ce582f318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Tue, 10 Sep 2024 05:00:02 +0200 Subject: [PATCH] llvm: Don't use the optimized jump table construction logic for wasm. --- src/codegen/llvm.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 2f9f9e096b..c8eb37b30a 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -6544,6 +6544,12 @@ pub const FuncGen = struct { const jmp_table: ?SwitchDispatchInfo.JmpTable = jmp_table: { if (!is_dispatch_loop) break :jmp_table null; + + // Workaround for: + // * https://github.com/llvm/llvm-project/blob/56905dab7da50bccfcceaeb496b206ff476127e1/llvm/lib/MC/WasmObjectWriter.cpp#L560 + // * https://github.com/llvm/llvm-project/blob/56905dab7da50bccfcceaeb496b206ff476127e1/llvm/test/MC/WebAssembly/blockaddress.ll + if (zcu.comp.getTarget().isWasm()) break :jmp_table null; + // On a 64-bit target, 1024 pointers in our jump table is about 8K of pointers. This seems just // about acceptable - it won't fill L1d cache on most CPUs. const max_table_len = 1024;