From 3383ccc4003a685476be4eb5786539648c33ba90 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Mon, 9 Nov 2015 02:46:41 +0000 Subject: Add a method to the BitcodeReader to parse only the identification block Summary: Mimic parseTriple(); and exposes it to LTOModule.cpp Reviewers: dexonsmith, rafael Subscribers: llvm-commits From: Mehdi Amini llvm-svn: 252442 --- llvm/lib/LTO/LTOModule.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/lib/LTO/LTOModule.cpp') diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp index ec8991ed236..d28563c23b8 100644 --- a/llvm/lib/LTO/LTOModule.cpp +++ b/llvm/lib/LTO/LTOModule.cpp @@ -91,6 +91,15 @@ bool LTOModule::isBitcodeForTarget(MemoryBuffer *Buffer, return StringRef(Triple).startswith(TriplePrefix); } +std::string LTOModule::getProducerString(MemoryBuffer *Buffer) { + ErrorOr BCOrErr = + IRObjectFile::findBitcodeInMemBuffer(Buffer->getMemBufferRef()); + if (!BCOrErr) + return ""; + LLVMContext Context; + return getBitcodeProducerString(*BCOrErr, Context); +} + LTOModule *LTOModule::createFromFile(const char *path, TargetOptions options, std::string &errMsg) { ErrorOr> BufferOrErr = -- cgit v1.2.3