Index: wasm/Writer.cpp =================================================================== --- wasm/Writer.cpp +++ wasm/Writer.cpp @@ -122,7 +122,7 @@ std::vector ImportedGlobals; std::vector ExportedSymbols; std::vector DefinedDataSymbols; - std::vector DefinedFunctions; + std::vector InputFunctions; std::vector IndirectFunctions; std::vector InitFunctions; @@ -202,14 +202,14 @@ } void Writer::createFunctionSection() { - if (DefinedFunctions.empty()) + if (InputFunctions.empty()) return; SyntheticSection *Section = createSyntheticSection(WASM_SEC_FUNCTION); raw_ostream &OS = Section->getStream(); - writeUleb128(OS, DefinedFunctions.size(), "function count"); - for (const InputFunction *Func : DefinedFunctions) + writeUleb128(OS, InputFunctions.size(), "function count"); + for (const InputFunction *Func : InputFunctions) writeUleb128(OS, lookupType(Func->Signature), "sig index"); } @@ -323,12 +323,12 @@ } void Writer::createCodeSection() { - if (DefinedFunctions.empty()) + if (InputFunctions.empty()) return; log("createCodeSection"); - auto Section = make(DefinedFunctions); + auto Section = make(InputFunctions); OutputSections.push_back(Section); } @@ -438,7 +438,7 @@ struct ComdatEntry { unsigned Kind; uint32_t Index; }; std::map> Comdats; - for (const InputFunction *F : DefinedFunctions) { + for (const InputFunction *F : InputFunctions) { StringRef Comdat = F->getComdat(); if (!Comdat.empty()) Comdats[Comdat].emplace_back( @@ -477,7 +477,7 @@ // Create the custom "name" section containing debug symbol names. void Writer::createNameSection() { unsigned NumNames = ImportedFunctions.size(); - for (const InputFunction *F : DefinedFunctions) + for (const InputFunction *F : InputFunctions) if (!F->getName().empty()) ++NumNames; @@ -491,13 +491,13 @@ writeUleb128(OS, NumNames, "name count"); // Names must appear in function index order. As it happens ImportedFunctions - // and DefinedFunctions are numbers in order with imported functions coming + // and InputFunctions are numbers in order with imported functions coming // first. for (const Symbol *S : ImportedFunctions) { writeUleb128(OS, S->getOutputIndex(), "import index"); writeStr(OS, S->getName(), "symbol name"); } - for (const InputFunction *F : DefinedFunctions) { + for (const InputFunction *F : InputFunctions) { if (!F->getName().empty()) { writeUleb128(OS, F->getOutputIndex(), "func index"); writeStr(OS, F->getName(), "symbol name"); @@ -714,13 +714,13 @@ for (const FunctionSymbol *Sym : ImportedFunctions) registerType(*Sym->getFunctionType()); - for (const InputFunction *F : DefinedFunctions) + for (const InputFunction *F : InputFunctions) registerType(F->Signature); } void Writer::assignIndexes() { uint32_t GlobalIndex = ImportedGlobals.size() + DefinedDataSymbols.size(); - uint32_t FunctionIndex = ImportedFunctions.size() + DefinedFunctions.size(); + uint32_t FunctionIndex = ImportedFunctions.size() + InputFunctions.size(); auto AddDefinedData = [&](DefinedData *Sym) { if (Sym) { @@ -755,7 +755,7 @@ for (InputFunction *Func : File->Functions) { if (!Func->Live) continue; - DefinedFunctions.emplace_back(Func); + InputFunctions.emplace_back(Func); Func->setOutputIndex(FunctionIndex++); } } @@ -828,7 +828,7 @@ // Create synthetic "__wasm_call_ctors" function based on ctor functions // in input object. void Writer::createCtorFunction() { - uint32_t FunctionIndex = ImportedFunctions.size() + DefinedFunctions.size(); + uint32_t FunctionIndex = ImportedFunctions.size() + InputFunctions.size(); WasmSym::CallCtors->setOutputIndex(FunctionIndex); // First write the body bytes to a string. @@ -855,7 +855,7 @@ CtorFunction = llvm::make_unique( Signature, BodyArray, WasmSym::CallCtors->getName()); CtorFunction->setOutputIndex(FunctionIndex); - DefinedFunctions.emplace_back(CtorFunction.get()); + InputFunctions.emplace_back(CtorFunction.get()); } // Populate InitFunctions vector with init functions from all input objects. @@ -892,7 +892,7 @@ calculateTypes(); if (errorHandler().Verbose) { - log("Defined Functions: " + Twine(DefinedFunctions.size())); + log("Defined Functions: " + Twine(InputFunctions.size())); log("Defined Data Syms: " + Twine(DefinedDataSymbols.size())); log("Function Imports : " + Twine(ImportedFunctions.size())); log("Global Imports : " + Twine(ImportedGlobals.size()));