From 8dde4cba4ce76a9efc663e997735e96325be7902 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 8 Jun 2017 22:00:24 +0000 Subject: 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 --- llvm/lib/Object/IRSymtab.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Object/IRSymtab.cpp') 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 Mods, SmallVector &Symtab, return Builder(Symtab, Strtab).build(Mods); } -Expected irsymtab::readBitcode(ArrayRef 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 upgrade(ArrayRef BMs) { FileContents FC; - if (BMs.empty()) - return make_error("Bitcode file does not contain any modules", - inconvertibleErrorCode()); LLVMContext Ctx; std::vector Mods; @@ -293,3 +292,13 @@ Expected irsymtab::readBitcode(ArrayRef BMs) { {FC.Strtab.data(), FC.Strtab.size()}}; return std::move(FC); } + +Expected irsymtab::readBitcode(const BitcodeFileContents &BFC) { + if (BFC.Mods.empty()) + return make_error("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); +} -- cgit v1.2.3