Index: wasm/InputFiles.cpp =================================================================== --- wasm/InputFiles.cpp +++ wasm/InputFiles.cpp @@ -172,7 +172,7 @@ uint32_t ObjFile::getGlobalValue(const WasmSymbol &Sym) const { const WasmGlobal &Global = getWasmObj()->globals()[Sym.ElementIndex - NumGlobalImports]; - assert(Global.Type == llvm::wasm::WASM_TYPE_I32); + assert(Global.Type.Type == llvm::wasm::WASM_TYPE_I32); return Global.InitExpr.Value.Int32; } @@ -273,7 +273,7 @@ } Symbols.push_back(S); - if (WasmSym.isFunction()) { + if (WasmSym.isTypeFunction()) { FunctionSymbols[WasmSym.ElementIndex] = S; if (WasmSym.HasAltIndex) FunctionSymbols[WasmSym.AltIndex] = S; @@ -301,7 +301,7 @@ Symbol *ObjFile::createDefined(const WasmSymbol &Sym, Symbol::Kind Kind, InputChunk *Chunk, uint32_t Address) { Symbol *S; - if (Sym.isLocal()) { + if (Sym.isBindingLocal()) { S = make(Sym.Name, true); S->update(Kind, this, Sym.Flags, Chunk, Address); return S; Index: wasm/Writer.cpp =================================================================== --- wasm/Writer.cpp +++ wasm/Writer.cpp @@ -236,8 +236,8 @@ writeUleb128(OS, DefinedGlobals.size(), "global count"); for (const Symbol *Sym : DefinedGlobals) { WasmGlobal Global; - Global.Type = WASM_TYPE_I32; - Global.Mutable = Sym == Config->StackPointerSymbol; + Global.Type.Type = WASM_TYPE_I32; + Global.Type.Mutable = Sym == Config->StackPointerSymbol; Global.InitExpr.Opcode = WASM_OPCODE_I32_CONST; Global.InitExpr.Value.Int32 = Sym->getVirtualAddress(); writeGlobal(OS, Global); Index: wasm/WriterUtils.h =================================================================== --- wasm/WriterUtils.h +++ wasm/WriterUtils.h @@ -27,6 +27,17 @@ return !(LHS == RHS); } +// Used for general comparison +inline bool operator==(const llvm::wasm::WasmGlobalType &LHS, + const llvm::wasm::WasmGlobalType &RHS) { + return LHS.Type == RHS.Type && LHS.Mutable == RHS.Mutable; +} + +inline bool operator!=(const llvm::wasm::WasmGlobalType &LHS, + const llvm::wasm::WasmGlobalType &RHS) { + return !(LHS == RHS); +} + namespace lld { namespace wasm { @@ -60,6 +71,8 @@ void writeLimits(raw_ostream &OS, const llvm::wasm::WasmLimits &Limits); +void writeGlobalType(raw_ostream &OS, const llvm::wasm::WasmGlobalType &Type); + void writeGlobal(raw_ostream &OS, const llvm::wasm::WasmGlobal &Global); void writeImport(raw_ostream &OS, const llvm::wasm::WasmImport &Import); Index: wasm/WriterUtils.cpp =================================================================== --- wasm/WriterUtils.cpp +++ wasm/WriterUtils.cpp @@ -123,9 +123,13 @@ writeUleb128(OS, Limits.Maximum, "limits max"); } +void wasm::writeGlobalType(raw_ostream &OS, const WasmGlobalType &Type) { + writeValueType(OS, Type.Type, "global type"); + writeUleb128(OS, Type.Mutable, "global mutable"); +} + void wasm::writeGlobal(raw_ostream &OS, const WasmGlobal &Global) { - writeValueType(OS, Global.Type, "global type"); - writeUleb128(OS, Global.Mutable, "global mutable"); + writeGlobalType(OS, Global.Type); writeInitExpr(OS, Global.InitExpr); } @@ -138,8 +142,7 @@ writeUleb128(OS, Import.SigIndex, "import sig index"); break; case WASM_EXTERNAL_GLOBAL: - writeValueType(OS, Import.Global.Type, "import global type"); - writeUleb128(OS, Import.Global.Mutable, "import global mutable"); + writeGlobalType(OS, Import.Global); break; case WASM_EXTERNAL_MEMORY: writeLimits(OS, Import.Memory);