summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/WasmObjectWriter.cpp
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2017-11-28 17:15:03 +0000
committerDan Gohman <dan433584@gmail.com>2017-11-28 17:15:03 +0000
commit2803bfaf001241a98608c263a824a5f5ec542511 (patch)
tree3d7c1d9c5f61f94c44f1ebb0ef158dd5de9dd8dc /llvm/lib/MC/WasmObjectWriter.cpp
parente123aba94ead1673e8672e0fdd7ef9a75d1b205c (diff)
downloadbcm5719-llvm-2803bfaf001241a98608c263a824a5f5ec542511.tar.gz
bcm5719-llvm-2803bfaf001241a98608c263a824a5f5ec542511.zip
[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
Diffstat (limited to 'llvm/lib/MC/WasmObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/WasmObjectWriter.cpp9
1 files changed, 6 insertions, 3 deletions
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<const MCSymbolWasm &>(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;
OpenPOWER on IntegriCloud