Index: lld/trunk/wasm/InputFiles.h =================================================================== --- lld/trunk/wasm/InputFiles.h +++ lld/trunk/wasm/InputFiles.h @@ -51,9 +51,6 @@ // Returns the filename. StringRef getName() const { return MB.getBufferIdentifier(); } - // Reads a file (the constructor doesn't do that). - virtual void parse(bool IgnoreComdats = false) = 0; - Kind kind() const { return FileKind; } // An archive file name if this file is created from an archive. @@ -82,7 +79,7 @@ void addMember(const llvm::object::Archive::Symbol *Sym); - void parse(bool IgnoreComdats) override; + void parse(); private: std::unique_ptr File; @@ -98,7 +95,7 @@ } static bool classof(const InputFile *F) { return F->kind() == ObjectKind; } - void parse(bool IgnoreComdats) override; + void parse(bool IgnoreComdats = false); // Returns the underlying wasm file. const WasmObjectFile *getWasmObj() const { return WasmObj.get(); } @@ -150,8 +147,6 @@ public: explicit SharedFile(MemoryBufferRef M) : InputFile(SharedKind, M) {} static bool classof(const InputFile *F) { return F->kind() == SharedKind; } - - void parse(bool IgnoreComdats) override {} }; // .bc file @@ -163,7 +158,7 @@ } static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; } - void parse(bool IgnoreComdats) override; + void parse(); std::unique_ptr Obj; }; Index: lld/trunk/wasm/InputFiles.cpp =================================================================== --- lld/trunk/wasm/InputFiles.cpp +++ lld/trunk/wasm/InputFiles.cpp @@ -454,7 +454,7 @@ llvm_unreachable("unknown symbol kind"); } -void ArchiveFile::parse(bool IgnoreComdats) { +void ArchiveFile::parse() { // Parse a MemoryBufferRef as an archive file. LLVM_DEBUG(dbgs() << "Parsing library: " << toString(this) << "\n"); File = CHECK(Archive::create(MB), toString(this)); @@ -524,7 +524,7 @@ return Symtab->addDefinedData(Name, Flags, &F, nullptr, 0, 0); } -void BitcodeFile::parse(bool IgnoreComdats) { +void BitcodeFile::parse() { Obj = check(lto::InputFile::create(MemoryBufferRef( MB.getBuffer(), Saver.save(ArchiveName + MB.getBufferIdentifier())))); Triple T(Obj->getTargetTriple()); Index: lld/trunk/wasm/SymbolTable.cpp =================================================================== --- lld/trunk/wasm/SymbolTable.cpp +++ lld/trunk/wasm/SymbolTable.cpp @@ -28,17 +28,33 @@ void SymbolTable::addFile(InputFile *File) { log("Processing: " + toString(File)); + + // .a file + if (auto *F = dyn_cast(File)) { + F->parse(); + return; + } + + // .so file + if (auto *F = dyn_cast(File)) { + SharedFiles.push_back(F); + return; + } + if (Config->Trace) message(toString(File)); - File->parse(); // LLVM bitcode file - if (auto *F = dyn_cast(File)) + if (auto *F = dyn_cast(File)) { + F->parse(); BitcodeFiles.push_back(F); - else if (auto *F = dyn_cast(File)) - ObjectFiles.push_back(F); - else if (auto *F = dyn_cast(File)) - SharedFiles.push_back(F); + return; + } + + // Regular object file + auto *F = cast(File); + F->parse(false); + ObjectFiles.push_back(F); } // This function is where all the optimizations of link-time