diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-06-08 22:00:24 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-06-08 22:00:24 +0000 |
commit | 8dde4cba4ce76a9efc663e997735e96325be7902 (patch) | |
tree | 92b358855a607ca28e5a8a0091900488875107c6 /llvm/lib/Object/IRSymtab.cpp | |
parent | 108ca94fa8dd35e969720c7605531a75f84558ce (diff) | |
download | bcm5719-llvm-8dde4cba4ce76a9efc663e997735e96325be7902.tar.gz bcm5719-llvm-8dde4cba4ce76a9efc663e997735e96325be7902.zip |
Bitcode: Introduce a BitcodeFileContents data type. NFCI.
This data type includes the contents of a bitcode file.
Right now a bitcode file can only contain modules, but
a later change will add a symbol table.
Differential Revision: https://reviews.llvm.org/D33969
llvm-svn: 305019
Diffstat (limited to 'llvm/lib/Object/IRSymtab.cpp')
-rw-r--r-- | llvm/lib/Object/IRSymtab.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp index fa343618caf..94f13490939 100644 --- a/llvm/lib/Object/IRSymtab.cpp +++ b/llvm/lib/Object/IRSymtab.cpp @@ -262,11 +262,10 @@ Error irsymtab::build(ArrayRef<Module *> Mods, SmallVector<char, 0> &Symtab, return Builder(Symtab, Strtab).build(Mods); } -Expected<FileContents> irsymtab::readBitcode(ArrayRef<BitcodeModule> BMs) { +// Upgrade a vector of bitcode modules created by an old version of LLVM by +// creating an irsymtab for them in the current format. +static Expected<FileContents> upgrade(ArrayRef<BitcodeModule> BMs) { FileContents FC; - if (BMs.empty()) - return make_error<StringError>("Bitcode file does not contain any modules", - inconvertibleErrorCode()); LLVMContext Ctx; std::vector<Module *> Mods; @@ -293,3 +292,13 @@ Expected<FileContents> irsymtab::readBitcode(ArrayRef<BitcodeModule> BMs) { {FC.Strtab.data(), FC.Strtab.size()}}; return std::move(FC); } + +Expected<FileContents> irsymtab::readBitcode(const BitcodeFileContents &BFC) { + if (BFC.Mods.empty()) + return make_error<StringError>("Bitcode file does not contain any modules", + inconvertibleErrorCode()); + + // Right now we have no on-disk representation of symbol tables, so we always + // upgrade. + return upgrade(BFC.Mods); +} |