[WebAssembly] Refactor WasmSignature and use it for MCSymbolWasm
MCContext does not destroy MCSymbols on shutdown. So, rather than putting
SmallVectors (which may heap-allocate) inside MCSymbolWasm, use unowned pointer
to a WasmSignature instead. The signatures are now owned by the AsmPrinter.
Also uses WasmSignature instead of param and result vectors in TargetStreamer,
and leaves some TODOs for further simplification.
Differential Revision: https://reviews.llvm.org/D52580
llvm-svn: 343733
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 2c28f01..cbbe161 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -58,6 +58,7 @@
// The signature of a wasm function, in a struct capable of being used as a
// DenseMap key.
+// TODO: Consider using WasmSignature directly instead.
struct WasmFunctionType {
// Support empty and tombstone instances, needed by DenseMap.
enum { Plain, Empty, Tombstone } State;
@@ -1049,8 +1050,10 @@
WasmFunctionType F;
const MCSymbolWasm *ResolvedSym = ResolveSymbol(Symbol);
- F.Returns = ResolvedSym->getReturns();
- F.Params = ResolvedSym->getParams();
+ if (auto *Sig = ResolvedSym->getSignature()) {
+ F.Returns = Sig->Returns;
+ F.Params = Sig->Params;
+ }
auto Pair =
FunctionTypeIndices.insert(std::make_pair(F, FunctionTypes.size()));