[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
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 2297084..6e9088b 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -1040,12 +1040,15 @@
   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;