[lld] [llvm] [WebAssembly] Use 64-bit table when targeting wasm64 (PR #92042)
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Mon May 13 15:31:32 PDT 2024
https://github.com/sbc100 created https://github.com/llvm/llvm-project/pull/92042
See https://github.com/WebAssembly/memory64/issues/51
>From 5a3761d898c3f26675afe6385f3d22cd60e38f43 Mon Sep 17 00:00:00 2001
From: Sam Clegg <sbc at chromium.org>
Date: Mon, 13 May 2024 14:42:34 -0700
Subject: [PATCH] [WebAssembly] Use 64-bit table when targeting wasm64
See https://github.com/WebAssembly/memory64/issues/51
---
lld/test/wasm/shared64.s | 1 +
lld/wasm/Writer.cpp | 2 ++
llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp | 12 ------------
3 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/lld/test/wasm/shared64.s b/lld/test/wasm/shared64.s
index 3401faed8610c..2148d464f4158 100644
--- a/lld/test/wasm/shared64.s
+++ b/lld/test/wasm/shared64.s
@@ -154,6 +154,7 @@ get_local_func_address:
# CHECK-NEXT: Index: 0
# CHECK-NEXT: ElemType: FUNCREF
# CHECK-NEXT: Limits:
+# CHECK-NEXT: Flags: [ IS_64 ]
# CHECK-NEXT: Minimum: 0x2
# CHECK-NEXT: - Module: env
# CHECK-NEXT: Field: __stack_pointer
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 55eff995fb8a1..91d1113df6a3c 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -939,6 +939,8 @@ static void finalizeIndirectFunctionTable() {
limits.Flags |= WASM_LIMITS_FLAG_HAS_MAX;
limits.Maximum = limits.Minimum;
}
+ if (config->is64.value_or(false))
+ limits.Flags |= WASM_LIMITS_FLAG_IS_64;
WasmSym::indirectFunctionTable->setLimits(limits);
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
index 1c62290704fe4..26e13948bc9a6 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
@@ -885,18 +885,6 @@ bool WebAssemblyFastISel::selectCall(const Instruction *I) {
Table->setNoStrip();
MIB.addImm(0);
}
- // See if we must truncate the function pointer.
- // CALL_INDIRECT takes an i32, but in wasm64 we represent function pointers
- // as 64-bit for uniformity with other pointer types.
- // See also: WebAssemblyISelLowering.cpp: LowerCallResults
- if (Subtarget->hasAddr64()) {
- auto Wrap = BuildMI(*FuncInfo.MBB, std::prev(FuncInfo.InsertPt), MIMD,
- TII.get(WebAssembly::I32_WRAP_I64));
- Register Reg32 = createResultReg(&WebAssembly::I32RegClass);
- Wrap.addReg(Reg32, RegState::Define);
- Wrap.addReg(CalleeReg);
- CalleeReg = Reg32;
- }
}
for (unsigned ArgReg : Args)
More information about the llvm-commits
mailing list