[lld] r362626 - [WebAssembly] Handle object parsing more like the ELF backend
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 5 10:50:46 PDT 2019
Author: sbc
Date: Wed Jun 5 10:50:45 2019
New Revision: 362626
URL: http://llvm.org/viewvc/llvm-project?rev=362626&view=rev
Log:
[WebAssembly] Handle object parsing more like the ELF backend
Differential Revision: https://reviews.llvm.org/D62886
Modified:
lld/trunk/wasm/InputFiles.cpp
lld/trunk/wasm/InputFiles.h
lld/trunk/wasm/SymbolTable.cpp
Modified: lld/trunk/wasm/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputFiles.cpp?rev=362626&r1=362625&r2=362626&view=diff
==============================================================================
--- lld/trunk/wasm/InputFiles.cpp (original)
+++ lld/trunk/wasm/InputFiles.cpp Wed Jun 5 10:50:45 2019
@@ -454,7 +454,7 @@ Symbol *ObjFile::createUndefined(const W
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 @@ static Symbol *createBitcodeSymbol(const
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());
Modified: lld/trunk/wasm/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputFiles.h?rev=362626&r1=362625&r2=362626&view=diff
==============================================================================
--- lld/trunk/wasm/InputFiles.h (original)
+++ lld/trunk/wasm/InputFiles.h Wed Jun 5 10:50:45 2019
@@ -51,9 +51,6 @@ public:
// 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 @@ public:
void addMember(const llvm::object::Archive::Symbol *Sym);
- void parse(bool IgnoreComdats) override;
+ void parse();
private:
std::unique_ptr<llvm::object::Archive> File;
@@ -98,7 +95,7 @@ public:
}
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 @@ class SharedFile : public InputFile {
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 @@ public:
}
static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; }
- void parse(bool IgnoreComdats) override;
+ void parse();
std::unique_ptr<llvm::lto::InputFile> Obj;
};
Modified: lld/trunk/wasm/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/SymbolTable.cpp?rev=362626&r1=362625&r2=362626&view=diff
==============================================================================
--- lld/trunk/wasm/SymbolTable.cpp (original)
+++ lld/trunk/wasm/SymbolTable.cpp Wed Jun 5 10:50:45 2019
@@ -28,17 +28,33 @@ SymbolTable *lld::wasm::Symtab;
void SymbolTable::addFile(InputFile *File) {
log("Processing: " + toString(File));
+
+ // .a file
+ if (auto *F = dyn_cast<ArchiveFile>(File)) {
+ F->parse();
+ return;
+ }
+
+ // .so file
+ if (auto *F = dyn_cast<SharedFile>(File)) {
+ SharedFiles.push_back(F);
+ return;
+ }
+
if (Config->Trace)
message(toString(File));
- File->parse();
// LLVM bitcode file
- if (auto *F = dyn_cast<BitcodeFile>(File))
+ if (auto *F = dyn_cast<BitcodeFile>(File)) {
+ F->parse();
BitcodeFiles.push_back(F);
- else if (auto *F = dyn_cast<ObjFile>(File))
- ObjectFiles.push_back(F);
- else if (auto *F = dyn_cast<SharedFile>(File))
- SharedFiles.push_back(F);
+ return;
+ }
+
+ // Regular object file
+ auto *F = cast<ObjFile>(File);
+ F->parse(false);
+ ObjectFiles.push_back(F);
}
// This function is where all the optimizations of link-time
More information about the llvm-commits
mailing list