From 2803bfaf001241a98608c263a824a5f5ec542511 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 28 Nov 2017 17:15:03 +0000 Subject: [WebAssembly] Support bitcasted function addresses with varargs. Generalize FixFunctionBitcasts to handle varargs functions. This in particular fixes the case where clang bitcasts away a varargs when calling a K&R-style function. This avoids interacting with tricky ABI details because it operates at the LLVM IR level before varargs ABI details are exposed. This fixes PR35385. llvm-svn: 319186 --- llvm/lib/MC/WasmObjectWriter.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'llvm/lib/MC/WasmObjectWriter.cpp') diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index 229708425b1..6e9088b9d0d 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -1040,12 +1040,15 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm, for (const MCSymbol &S : Asm.symbols()) { const auto &WS = static_cast(S); - if (WS.isTemporary()) - continue; - + // Register types for all functions, including those with private linkage + // (making them + // because wasm always needs a type signature. if (WS.isFunction()) registerFunctionType(WS); + if (WS.isTemporary()) + continue; + // If the symbol is not defined in this translation unit, import it. if (!WS.isDefined(/*SetUsed=*/false)) { WasmImport Import; -- cgit v1.2.3