Index: test/wasm/Inputs/globals.yaml =================================================================== --- test/wasm/Inputs/globals.yaml +++ test/wasm/Inputs/globals.yaml @@ -8,7 +8,7 @@ ReturnType: I64 ParamTypes: - Type: FUNCTION - FunctionTypes: [ 0 ] + FunctionSignatures: [ 0 ] - Type: GLOBAL Globals: - Index: 0 Index: test/wasm/Inputs/undefined-globals.yaml =================================================================== --- test/wasm/Inputs/undefined-globals.yaml +++ test/wasm/Inputs/undefined-globals.yaml @@ -20,7 +20,7 @@ GlobalType: I64 GlobalMutable: true - Type: FUNCTION - FunctionTypes: [ 0 ] + FunctionSignatures: [ 0 ] - Type: CODE Functions: - Index: 0 Index: test/wasm/alias.ll =================================================================== --- test/wasm/alias.ll +++ test/wasm/alias.ll @@ -22,7 +22,7 @@ ; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0 ] +; CHECK-NEXT: FunctionSignatures: [ 0, 0 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC Index: test/wasm/call-indirect.ll =================================================================== --- test/wasm/call-indirect.ll +++ test/wasm/call-indirect.ll @@ -57,7 +57,7 @@ ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - I32 ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 3, 0, 3, 1, 3, 4 ] +; CHECK-NEXT: FunctionSignatures: [ 3, 0, 3, 1, 3, 4 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC Index: test/wasm/function-imports-first.ll =================================================================== --- test/wasm/function-imports-first.ll +++ test/wasm/function-imports-first.ll @@ -24,7 +24,7 @@ ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - F32 ; CHECK: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0, 1 ] +; CHECK-NEXT: FunctionSignatures: [ 0, 0, 1 ] ; CHECK: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 Index: test/wasm/function-imports.ll =================================================================== --- test/wasm/function-imports.ll +++ test/wasm/function-imports.ll @@ -25,7 +25,7 @@ ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - F32 ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 0 ] +; CHECK-NEXT: FunctionSignatures: [ 0, 1, 0 ] ; CHECK: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK: - Index: 0 Index: test/wasm/function-index.test =================================================================== --- test/wasm/function-index.test +++ test/wasm/function-index.test @@ -15,4 +15,4 @@ CHECK: ParamTypes: CHECK: - F64 CHECK: - Type: FUNCTION -CHECK: FunctionTypes: [ 0, 1 ] +CHECK: FunctionSignatures: [ 0, 1 ] Index: test/wasm/local-symbols.ll =================================================================== --- test/wasm/local-symbols.ll +++ test/wasm/local-symbols.ll @@ -33,7 +33,7 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 0 ] +; CHECK-NEXT: FunctionSignatures: [ 0, 1, 0 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC Index: test/wasm/locals-duplicate.test =================================================================== --- test/wasm/locals-duplicate.test +++ test/wasm/locals-duplicate.test @@ -16,8 +16,8 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -; CHECK-NEXT: 1, 1, 1 ] +; CHECK-NEXT: FunctionSignatures: [ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +; CHECK-NEXT: 1, 1, 1, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC @@ -249,8 +249,8 @@ ; RELOC-NEXT: ReturnType: I32 ; RELOC-NEXT: ParamTypes: ; RELOC-NEXT: - Type: FUNCTION -; RELOC-NEXT: FunctionTypes: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -; RELOC-NEXT: 0, 0 ] +; RELOC-NEXT: FunctionSignatures: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +; RELOC-NEXT: 0, 0, 0 ] ; RELOC-NEXT: - Type: TABLE ; RELOC-NEXT: Tables: ; RELOC-NEXT: - ElemType: ANYFUNC Index: test/wasm/relocatable.ll =================================================================== --- test/wasm/relocatable.ll +++ test/wasm/relocatable.ll @@ -60,7 +60,7 @@ ; CHECK-NEXT: Kind: FUNCTION ; CHECK-NEXT: SigIndex: 1 ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 2, 1, 1 ] +; CHECK-NEXT: FunctionSignatures: [ 2, 1, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC Index: test/wasm/stack-pointer.ll =================================================================== --- test/wasm/stack-pointer.ll +++ test/wasm/stack-pointer.ll @@ -28,7 +28,7 @@ ; CHECK-NEXT: GlobalType: I32 ; CHECK-NEXT: GlobalMutable: true ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0 ] +; CHECK-NEXT: FunctionSignatures: [ 0 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC Index: test/wasm/undefined-weak-call.ll =================================================================== --- test/wasm/undefined-weak-call.ll +++ test/wasm/undefined-weak-call.ll @@ -42,7 +42,7 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0, 0, 1, 2 ] +; CHECK-NEXT: FunctionSignatures: [ 0, 0, 0, 1, 2 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC Index: test/wasm/weak-alias-overide.ll =================================================================== --- test/wasm/weak-alias-overide.ll +++ test/wasm/weak-alias-overide.ll @@ -32,7 +32,7 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 0, 1, 1, 1, 1, 1 ] +; CHECK-NEXT: FunctionSignatures: [ 0, 1, 0, 1, 1, 1, 1, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC Index: test/wasm/weak-alias.ll =================================================================== --- test/wasm/weak-alias.ll +++ test/wasm/weak-alias.ll @@ -29,7 +29,7 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0, 1, 1, 1, 1, 1 ] +; CHECK-NEXT: FunctionSignatures: [ 0, 0, 1, 1, 1, 1, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC @@ -167,7 +167,7 @@ ; RELOC-NEXT: GlobalType: I32 ; RELOC-NEXT: GlobalMutable: true ; RELOC-NEXT: - Type: FUNCTION -; RELOC-NEXT: FunctionTypes: [ 0, 1, 1, 1, 1, 1 ] +; RELOC-NEXT: FunctionSignatures: [ 0, 1, 1, 1, 1, 1 ] ; RELOC-NEXT: - Type: TABLE ; RELOC-NEXT: Tables: ; RELOC-NEXT: - ElemType: ANYFUNC Index: test/wasm/weak-symbols.ll =================================================================== --- test/wasm/weak-symbols.ll +++ test/wasm/weak-symbols.ll @@ -29,7 +29,7 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0, 1, 1, 1 ] +; CHECK-NEXT: FunctionSignatures: [ 0, 0, 1, 1, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC Index: test/wasm/weak-undefined.ll =================================================================== --- test/wasm/weak-undefined.ll +++ test/wasm/weak-undefined.ll @@ -40,7 +40,7 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 0 ] +; CHECK-NEXT: FunctionSignatures: [ 0, 1, 1, 0 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC Index: wasm/Driver.cpp =================================================================== --- wasm/Driver.cpp +++ wasm/Driver.cpp @@ -305,8 +305,8 @@ // It is possible for undefined functions not to have a signature (eg. if // added via "--undefined"), but weak undefined ones do have a signature. - assert(FuncSym->FunctionType); - const WasmSignature &Sig = *FuncSym->FunctionType; + assert(FuncSym->FunctionSig); + const WasmSignature &Sig = *FuncSym->FunctionSig; // Add a synthetic dummy for weak undefined functions. These dummies will // be GC'd if not used as the target of any "call" instructions. Index: wasm/InputChunks.cpp =================================================================== --- wasm/InputChunks.cpp +++ wasm/InputChunks.cpp @@ -52,7 +52,7 @@ uint32_t Offset = Rel.Offset - getInputSectionOffset(); const uint8_t *Loc = data().data() + Offset; switch (Rel.Type) { - case R_WEBASSEMBLY_TYPE_INDEX_LEB: + case R_WEBASSEMBLY_SIGNATURE_INDEX_LEB: case R_WEBASSEMBLY_FUNCTION_INDEX_LEB: case R_WEBASSEMBLY_GLOBAL_INDEX_LEB: case R_WEBASSEMBLY_MEMORY_ADDR_LEB: @@ -108,7 +108,7 @@ << "\n"); switch (Rel.Type) { - case R_WEBASSEMBLY_TYPE_INDEX_LEB: + case R_WEBASSEMBLY_SIGNATURE_INDEX_LEB: case R_WEBASSEMBLY_FUNCTION_INDEX_LEB: case R_WEBASSEMBLY_GLOBAL_INDEX_LEB: case R_WEBASSEMBLY_MEMORY_ADDR_LEB: @@ -177,7 +177,7 @@ static unsigned writeCompressedReloc(uint8_t *Buf, const WasmRelocation &Rel, uint32_t Value) { switch (Rel.Type) { - case R_WEBASSEMBLY_TYPE_INDEX_LEB: + case R_WEBASSEMBLY_SIGNATURE_INDEX_LEB: case R_WEBASSEMBLY_FUNCTION_INDEX_LEB: case R_WEBASSEMBLY_GLOBAL_INDEX_LEB: case R_WEBASSEMBLY_MEMORY_ADDR_LEB: @@ -192,7 +192,7 @@ static unsigned getRelocWidthPadded(const WasmRelocation &Rel) { switch (Rel.Type) { - case R_WEBASSEMBLY_TYPE_INDEX_LEB: + case R_WEBASSEMBLY_SIGNATURE_INDEX_LEB: case R_WEBASSEMBLY_FUNCTION_INDEX_LEB: case R_WEBASSEMBLY_GLOBAL_INDEX_LEB: case R_WEBASSEMBLY_MEMORY_ADDR_LEB: Index: wasm/InputFiles.h =================================================================== --- wasm/InputFiles.h +++ wasm/InputFiles.h @@ -112,8 +112,8 @@ const WasmSection *DataSection = nullptr; // Maps input type indices to output type indices - std::vector TypeMap; - std::vector TypeIsUsed; + std::vector SigMap; + std::vector SigIsUsed; // Maps function indices to table indices std::vector TableEntries; std::vector UsedComdats; Index: wasm/InputFiles.cpp =================================================================== --- wasm/InputFiles.cpp +++ wasm/InputFiles.cpp @@ -64,9 +64,9 @@ // relocation and returns relocated index (i.e. translates from the input // symbol/type space to the output symbol/type space). uint32_t ObjFile::calcNewIndex(const WasmRelocation &Reloc) const { - if (Reloc.Type == R_WEBASSEMBLY_TYPE_INDEX_LEB) { - assert(TypeIsUsed[Reloc.Index]); - return TypeMap[Reloc.Index]; + if (Reloc.Type == R_WEBASSEMBLY_SIGNATURE_INDEX_LEB) { + assert(SigIsUsed[Reloc.Index]); + return SigMap[Reloc.Index]; } return Symbols[Reloc.Index]->getOutputSymbolIndex(); } @@ -116,7 +116,7 @@ return 0; case R_WEBASSEMBLY_SECTION_OFFSET_I32: return Reloc.Addend; - case R_WEBASSEMBLY_TYPE_INDEX_LEB: + case R_WEBASSEMBLY_SIGNATURE_INDEX_LEB: return Reloc.Index; case R_WEBASSEMBLY_FUNCTION_INDEX_LEB: case R_WEBASSEMBLY_GLOBAL_INDEX_LEB: { @@ -141,8 +141,8 @@ if (Sym->isLive()) return Sym->getVirtualAddress() + Reloc.Addend; return 0; - case R_WEBASSEMBLY_TYPE_INDEX_LEB: - return TypeMap[Reloc.Index]; + case R_WEBASSEMBLY_SIGNATURE_INDEX_LEB: + return SigMap[Reloc.Index]; case R_WEBASSEMBLY_FUNCTION_INDEX_LEB: return getFunctionSymbol(Reloc.Index)->getFunctionIndex(); case R_WEBASSEMBLY_GLOBAL_INDEX_LEB: @@ -239,8 +239,8 @@ SectionIndex++; } - TypeMap.resize(getWasmObj()->types().size()); - TypeIsUsed.resize(getWasmObj()->types().size(), false); + SigMap.resize(getWasmObj()->signatures().size()); + SigIsUsed.resize(getWasmObj()->signatures().size(), false); ArrayRef Comdats = WasmObj->linkingData().Comdats; UsedComdats.resize(Comdats.size()); @@ -254,13 +254,13 @@ // Populate `Functions`. ArrayRef Funcs = WasmObj->functions(); - ArrayRef FuncTypes = WasmObj->functionTypes(); - ArrayRef Types = WasmObj->types(); + ArrayRef FuncSigIndices = WasmObj->functionSigIndices(); + ArrayRef Sigs = WasmObj->signatures(); Functions.reserve(Funcs.size()); for (size_t I = 0, E = Funcs.size(); I != E; ++I) Functions.emplace_back( - make(Types[FuncTypes[I]], &Funcs[I], this)); + make(Sigs[FuncSigIndices[I]], &Funcs[I], this)); setRelocs(Functions, CodeSection); // Populate `Globals`. @@ -357,7 +357,7 @@ switch (Sym.Info.Kind) { case WASM_SYMBOL_TYPE_FUNCTION: - return Symtab->addUndefinedFunction(Name, Flags, this, Sym.FunctionType); + return Symtab->addUndefinedFunction(Name, Flags, this, Sym.FunctionSig); case WASM_SYMBOL_TYPE_DATA: return Symtab->addUndefinedData(Name, Flags, this); case WASM_SYMBOL_TYPE_GLOBAL: Index: wasm/LTO.cpp =================================================================== --- wasm/LTO.cpp +++ wasm/LTO.cpp @@ -80,7 +80,7 @@ static void undefine(Symbol *S) { if (auto F = dyn_cast(S)) replaceSymbol(F, F->getName(), 0, F->getFile(), - F->FunctionType); + F->FunctionSig); else if (isa(S)) replaceSymbol(S, S->getName(), 0, S->getFile()); else Index: wasm/MarkLive.cpp =================================================================== --- wasm/MarkLive.cpp +++ wasm/MarkLive.cpp @@ -71,7 +71,7 @@ InputChunk *C = Q.pop_back_val(); for (const WasmRelocation Reloc : C->getRelocations()) { - if (Reloc.Type == R_WEBASSEMBLY_TYPE_INDEX_LEB) + if (Reloc.Type == R_WEBASSEMBLY_SIGNATURE_INDEX_LEB) continue; Symbol *Sym = C->File->getSymbol(Reloc.Index); Index: wasm/SymbolTable.cpp =================================================================== --- wasm/SymbolTable.cpp +++ wasm/SymbolTable.cpp @@ -99,8 +99,8 @@ // Check the type of new symbol matches that of the symbol is replacing. // For functions this can also involve verifying that the signatures match. -static void checkFunctionType(Symbol *Existing, const InputFile *File, - const WasmSignature *NewSig) { +static void checkFunctionSignature(Symbol *Existing, const InputFile *File, + const WasmSignature *NewSig) { auto ExistingFunction = dyn_cast(Existing); if (!ExistingFunction) { reportTypeError(Existing, File, WASM_SYMBOL_TYPE_FUNCTION); @@ -110,9 +110,9 @@ if (!NewSig) return; - const WasmSignature *OldSig = ExistingFunction->FunctionType; + const WasmSignature *OldSig = ExistingFunction->FunctionSig; if (!OldSig) { - ExistingFunction->FunctionType = NewSig; + ExistingFunction->FunctionSig = NewSig; return; } @@ -214,17 +214,17 @@ } if (Function) - checkFunctionType(S, File, &Function->Signature); + checkFunctionSignature(S, File, &Function->Signature); if (shouldReplace(S, File, Flags)) { // If the new defined function doesn't have signture (i.e. bitcode // functions) but the old symbols does then preserve the old signature const WasmSignature *OldSig = nullptr; if (auto* F = dyn_cast(S)) - OldSig = F->FunctionType; + OldSig = F->FunctionSig; auto NewSym = replaceSymbol(S, Name, Flags, File, Function); - if (!NewSym->FunctionType) - NewSym->FunctionType = OldSig; + if (!NewSym->FunctionSig) + NewSym->FunctionSig = OldSig; } return S; } @@ -285,7 +285,7 @@ else if (auto *Lazy = dyn_cast(S)) Lazy->fetch(); else - checkFunctionType(S, File, Sig); + checkFunctionSignature(S, File, Sig); return S; } Index: wasm/Symbols.h =================================================================== --- wasm/Symbols.h +++ wasm/Symbols.h @@ -124,12 +124,12 @@ void setFunctionIndex(uint32_t Index); bool hasFunctionIndex() const; - const WasmSignature *FunctionType; + const WasmSignature *FunctionSig; protected: FunctionSymbol(StringRef Name, Kind K, uint32_t Flags, InputFile *F, - const WasmSignature *Type) - : Symbol(Name, K, Flags, F), FunctionType(Type) {} + const WasmSignature *Sig) + : Symbol(Name, K, Flags, F), FunctionSig(Sig) {} uint32_t TableIndex = INVALID_INDEX; uint32_t FunctionIndex = INVALID_INDEX; @@ -150,8 +150,8 @@ class UndefinedFunction : public FunctionSymbol { public: UndefinedFunction(StringRef Name, uint32_t Flags, InputFile *File = nullptr, - const WasmSignature *Type = nullptr) - : FunctionSymbol(Name, UndefinedFunctionKind, Flags, File, Type) {} + const WasmSignature *Sig = nullptr) + : FunctionSymbol(Name, UndefinedFunctionKind, Flags, File, Sig) {} static bool classof(const Symbol *S) { return S->kind() == UndefinedFunctionKind; Index: wasm/Writer.cpp =================================================================== --- wasm/Writer.cpp +++ wasm/Writer.cpp @@ -58,8 +58,8 @@ private: void openFile(); - uint32_t lookupType(const WasmSignature &Sig); - uint32_t registerType(const WasmSignature &Sig); + uint32_t lookupSignature(const WasmSignature &Sig); + uint32_t registerSignature(const WasmSignature &Sig); void createCtorFunction(); void calculateInitFunctions(); @@ -106,8 +106,8 @@ uint32_t MemAlign = 0; uint32_t MemSize = 0; - std::vector Types; - DenseMap TypeIndices; + std::vector Signatures; + DenseMap SigIndices; std::vector ImportedSymbols; unsigned NumImportedFunctions = 0; unsigned NumImportedGlobals = 0; @@ -182,7 +182,7 @@ Import.Field = Sym->getName(); if (auto *FunctionSym = dyn_cast(Sym)) { Import.Kind = WASM_EXTERNAL_FUNCTION; - Import.SigIndex = lookupType(*FunctionSym->FunctionType); + Import.SigIndex = lookupSignature(*FunctionSym->FunctionSig); } else { auto *GlobalSym = cast(Sym); Import.Kind = WASM_EXTERNAL_GLOBAL; @@ -195,8 +195,8 @@ void Writer::createTypeSection() { SyntheticSection *Section = createSyntheticSection(WASM_SEC_TYPE); raw_ostream &OS = Section->getStream(); - writeUleb128(OS, Types.size(), "type count"); - for (const WasmSignature *Sig : Types) + writeUleb128(OS, Signatures.size(), "type count"); + for (const WasmSignature *Sig : Signatures) writeSig(OS, *Sig); } @@ -209,7 +209,7 @@ writeUleb128(OS, InputFunctions.size(), "function count"); for (const InputFunction *Func : InputFunctions) - writeUleb128(OS, lookupType(Func->Signature), "sig index"); + writeUleb128(OS, lookupSignature(Func->Signature), "sig index"); } void Writer::createMemorySection() { @@ -851,20 +851,20 @@ // Symtab->ObjectFiles. } -uint32_t Writer::lookupType(const WasmSignature &Sig) { - auto It = TypeIndices.find(Sig); - if (It == TypeIndices.end()) { - error("type not found: " + toString(Sig)); +uint32_t Writer::lookupSignature(const WasmSignature &Sig) { + auto It = SigIndices.find(Sig); + if (It == SigIndices.end()) { + error("signature not found: " + toString(Sig)); return 0; } return It->second; } -uint32_t Writer::registerType(const WasmSignature &Sig) { - auto Pair = TypeIndices.insert(std::make_pair(Sig, Types.size())); +uint32_t Writer::registerSignature(const WasmSignature &Sig) { + auto Pair = SigIndices.insert(std::make_pair(Sig, Signatures.size())); if (Pair.second) { - LLVM_DEBUG(dbgs() << "type " << toString(Sig) << "\n"); - Types.push_back(&Sig); + LLVM_DEBUG(dbgs() << "signature " << toString(Sig) << "\n"); + Signatures.push_back(&Sig); } return Pair.first->second; } @@ -876,18 +876,18 @@ // 3. The signatures of all defined functions for (ObjFile *File : Symtab->ObjectFiles) { - ArrayRef Types = File->getWasmObj()->types(); - for (uint32_t I = 0; I < Types.size(); I++) - if (File->TypeIsUsed[I]) - File->TypeMap[I] = registerType(Types[I]); + ArrayRef Sigs = File->getWasmObj()->signatures(); + for (uint32_t I = 0; I < Signatures.size(); I++) + if (File->SigIsUsed[I]) + File->SigMap[I] = registerSignature(Sigs[I]); } for (const Symbol *Sym : ImportedSymbols) if (auto *F = dyn_cast(Sym)) - registerType(*F->FunctionType); + registerSignature(*F->FunctionSig); for (const InputFunction *F : InputFunctions) - registerType(F->Signature); + registerSignature(F->Signature); } void Writer::assignIndexes() { @@ -914,7 +914,7 @@ if (!Chunk->Live) return; ObjFile *File = Chunk->File; - ArrayRef Types = File->getWasmObj()->types(); + ArrayRef Sigs = File->getWasmObj()->signatures(); for (const WasmRelocation &Reloc : Chunk->getRelocations()) { if (Reloc.Type == R_WEBASSEMBLY_TABLE_INDEX_I32 || Reloc.Type == R_WEBASSEMBLY_TABLE_INDEX_SLEB) { @@ -923,10 +923,10 @@ continue; Sym->setTableIndex(TableIndex++); IndirectFunctions.emplace_back(Sym); - } else if (Reloc.Type == R_WEBASSEMBLY_TYPE_INDEX_LEB) { - // Mark target type as live - File->TypeMap[Reloc.Index] = registerType(Types[Reloc.Index]); - File->TypeIsUsed[Reloc.Index] = true; + } else if (Reloc.Type == R_WEBASSEMBLY_SIGNATURE_INDEX_LEB) { + // Mark target signature as live + File->SigMap[Reloc.Index] = registerSignature(Sigs[Reloc.Index]); + File->SigIsUsed[Reloc.Index] = true; } } }; @@ -1035,7 +1035,7 @@ const WasmLinkingData &L = File->getWasmObj()->linkingData(); for (const WasmInitFunc &F : L.InitFunctions) { FunctionSymbol *Sym = File->getFunctionSymbol(F.Symbol); - if (*Sym->FunctionType != WasmSignature{{}, {}}) + if (*Sym->FunctionSig != 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 @@ -58,7 +58,7 @@ std::string toString(llvm::wasm::ValType Type); std::string toString(const llvm::wasm::WasmSignature &Sig); -std::string toString(const llvm::wasm::WasmGlobalType &Sig); +std::string toString(const llvm::wasm::WasmGlobalType &Type); } // namespace lld Index: wasm/WriterUtils.cpp =================================================================== --- wasm/WriterUtils.cpp +++ wasm/WriterUtils.cpp @@ -192,7 +192,7 @@ return S.str(); } -std::string lld::toString(const WasmGlobalType &Sig) { - return (Sig.Mutable ? "var " : "const ") + - toString(static_cast(Sig.Type)); +std::string lld::toString(const WasmGlobalType &Type) { + return (Type.Mutable ? "var " : "const ") + + toString(static_cast(Type.Type)); }