Index: lld/wasm/InputFiles.cpp =================================================================== --- lld/wasm/InputFiles.cpp +++ lld/wasm/InputFiles.cpp @@ -202,33 +202,25 @@ } void ObjFile::initializeSymbols() { - Symbols.reserve(WasmObj->getNumberOfSymbols()); - for (const WasmImport &Import : WasmObj->imports()) { - switch (Import.Kind) { - case WASM_EXTERNAL_FUNCTION: + if (Import.Kind == WASM_EXTERNAL_FUNCTION) ++NumFunctionImports; - break; - case WASM_EXTERNAL_GLOBAL: + else if (Import.Kind == WASM_EXTERNAL_GLOBAL) ++NumGlobalImports; - break; - } } - FunctionSymbols.resize(NumFunctionImports + WasmObj->functions().size()); - GlobalSymbols.resize(NumGlobalImports + WasmObj->globals().size()); - ArrayRef Funcs = WasmObj->functions(); ArrayRef FuncTypes = WasmObj->functionTypes(); ArrayRef Types = WasmObj->types(); ArrayRef Globals = WasmObj->globals(); - for (const auto &C : WasmObj->comdats()) - Symtab->addComdat(C, this); - + Symbols.reserve(WasmObj->getNumberOfSymbols()); FunctionSymbols.resize(NumFunctionImports + Funcs.size()); GlobalSymbols.resize(NumGlobalImports + Globals.size()); + for (StringRef S : WasmObj->comdats()) + Symtab->addComdat(S, this); + for (const WasmSegment &S : WasmObj->dataSegments()) { InputSegment *Seg = make(S, this); Seg->copyRelocations(*DataSection); @@ -236,11 +228,10 @@ } for (size_t I = 0; I < Funcs.size(); ++I) { - const WasmFunction &Func = Funcs[I]; - const WasmSignature &Sig = Types[FuncTypes[I]]; - InputFunction *F = make(Sig, &Func, this); + InputFunction *F = + make(Types[FuncTypes[I]], &Funcs[I], this); F->copyRelocations(*CodeSection); - Functions.emplace_back(F); + Functions.push_back(F); } // Populate `FunctionSymbols` and `GlobalSymbols` based on the WasmSymbols