summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/IRObjectFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Object/IRObjectFile.cpp')
-rw-r--r--llvm/lib/Object/IRObjectFile.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Object/IRObjectFile.cpp b/llvm/lib/Object/IRObjectFile.cpp
index bcaee029ce5..9996661fbde 100644
--- a/llvm/lib/Object/IRObjectFile.cpp
+++ b/llvm/lib/Object/IRObjectFile.cpp
@@ -139,3 +139,26 @@ IRObjectFile::create(MemoryBufferRef Object, LLVMContext &Context) {
return std::unique_ptr<IRObjectFile>(
new IRObjectFile(*BCOrErr, std::move(Mods)));
}
+
+Expected<IRSymtabFile> object::readIRSymtab(MemoryBufferRef MBRef) {
+ IRSymtabFile F;
+ ErrorOr<MemoryBufferRef> BCOrErr =
+ IRObjectFile::findBitcodeInMemBuffer(MBRef);
+ if (!BCOrErr)
+ return errorCodeToError(BCOrErr.getError());
+
+ Expected<std::vector<BitcodeModule>> BMsOrErr =
+ getBitcodeModuleList(*BCOrErr);
+ if (!BMsOrErr)
+ return BMsOrErr.takeError();
+
+ Expected<irsymtab::FileContents> FCOrErr = irsymtab::readBitcode(*BMsOrErr);
+ if (!FCOrErr)
+ return FCOrErr.takeError();
+
+ F.Mods = std::move(*BMsOrErr);
+ F.Symtab = std::move(FCOrErr->Symtab);
+ F.Strtab = std::move(FCOrErr->Strtab);
+ F.TheReader = std::move(FCOrErr->TheReader);
+ return std::move(F);
+}
OpenPOWER on IntegriCloud