Index: wasm/Driver.cpp =================================================================== --- wasm/Driver.cpp +++ wasm/Driver.cpp @@ -458,7 +458,7 @@ InputGlobal *StackPointer = make(Global, nullptr); StackPointer->Live = true; - static WasmSignature NullSignature = {{}, WASM_TYPE_NORESULT}; + static WasmSignature NullSignature = {{}, {}}; // Add synthetic symbols before any others WasmSym::CallCtors = Symtab->addSyntheticFunction( Index: wasm/Writer.cpp =================================================================== --- wasm/Writer.cpp +++ wasm/Writer.cpp @@ -991,7 +991,7 @@ const WasmLinkingData &L = File->getWasmObj()->linkingData(); for (const WasmInitFunc &F : L.InitFunctions) { FunctionSymbol *Sym = File->getFunctionSymbol(F.Symbol); - if (*Sym->FunctionType != WasmSignature{{}, WASM_TYPE_NORESULT}) + if (*Sym->FunctionType != WasmSignature{{}, {}}) error("invalid signature for init func: " + toString(*Sym)); InitFunctions.emplace_back(WasmInitEntry{Sym, F.Priority}); } Index: wasm/WriterUtils.h =================================================================== --- wasm/WriterUtils.h +++ wasm/WriterUtils.h @@ -35,7 +35,7 @@ void writeU32(raw_ostream &OS, uint32_t Number, const Twine &Msg); -void writeValueType(raw_ostream &OS, uint8_t Type, const Twine &Msg); +void writeValueType(raw_ostream &OS, llvm::wasm::ValType Type, const Twine &Msg); void writeSig(raw_ostream &OS, const llvm::wasm::WasmSignature &Sig); Index: wasm/WriterUtils.cpp =================================================================== --- wasm/WriterUtils.cpp +++ wasm/WriterUtils.cpp @@ -73,21 +73,20 @@ support::endian::write(OS, Number, support::little); } -void wasm::writeValueType(raw_ostream &OS, uint8_t Type, const Twine &Msg) { - writeU8(OS, Type, Msg + "[type: " + valueTypeToString(Type) + "]"); +void wasm::writeValueType(raw_ostream &OS, ValType Type, const Twine &Msg) { + auto T = static_cast(Type); + writeU8(OS, T, Msg + "[type: " + valueTypeToString(T) + "]"); } void wasm::writeSig(raw_ostream &OS, const WasmSignature &Sig) { writeU8(OS, WASM_TYPE_FUNC, "signature type"); - writeUleb128(OS, Sig.ParamTypes.size(), "param Count"); - for (uint8_t ParamType : Sig.ParamTypes) { + writeUleb128(OS, Sig.Params.size(), "param Count"); + for (auto ParamType : Sig.Params) { writeValueType(OS, ParamType, "param type"); } - if (Sig.ReturnType == WASM_TYPE_NORESULT) { - writeUleb128(OS, 0, "result Count"); - } else { - writeUleb128(OS, 1, "result Count"); - writeValueType(OS, Sig.ReturnType, "result type"); + writeUleb128(OS, Sig.Returns.size(), "result Count"); + if (Sig.Returns.size()) { + writeValueType(OS, Sig.Returns[0], "result type"); } } @@ -117,7 +116,7 @@ } void wasm::writeGlobalType(raw_ostream &OS, const WasmGlobalType &Type) { - writeValueType(OS, Type.Type, "global type"); + writeValueType(OS, ValType(Type.Type), "global type"); writeU8(OS, Type.Mutable, "global mutable"); } @@ -195,16 +194,16 @@ std::string lld::toString(const WasmSignature &Sig) { SmallString<128> S("("); - for (uint32_t Type : Sig.ParamTypes) { + for (ValType Type : Sig.Params) { if (S.size() != 1) S += ", "; - S += toString(static_cast(Type)); + S += toString(Type); } S += ") -> "; - if (Sig.ReturnType == WASM_TYPE_NORESULT) + if (Sig.Returns.size() == 0) S += "void"; else - S += toString(static_cast(Sig.ReturnType)); + S += toString(Sig.Returns[0]); return S.str(); }