X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=tools%2Fllvm-lto%2Fllvm-lto.cpp;h=e580a5df57824d022b3cd1f45667453576b13597;hp=aac82d31a366f8b1b745d7c65cf99b881368e655;hb=f1f60632b06de61a15f7362002ef0fe3399a2d54;hpb=ef8457f79e529990594d5c7feaf9e871fbc4b38e diff --git a/tools/llvm-lto/llvm-lto.cpp b/tools/llvm-lto/llvm-lto.cpp index aac82d31a36..e580a5df578 100644 --- a/tools/llvm-lto/llvm-lto.cpp +++ b/tools/llvm-lto/llvm-lto.cpp @@ -192,24 +192,27 @@ static int listSymbols(StringRef Command, const TargetOptions &Options) { /// Parse the function index out of an IR file and return the function /// index object if found, or nullptr if not. -static std::unique_ptr -getFunctionIndexForFile(StringRef Path, std::string &Error, +static ErrorOr> +getFunctionIndexForFile(StringRef Path, DiagnosticHandlerFunction DiagnosticHandler) { std::unique_ptr Buffer; ErrorOr> BufferOrErr = MemoryBuffer::getFile(Path); - if (std::error_code EC = BufferOrErr.getError()) { - Error = EC.message(); - return nullptr; - } + if (std::error_code EC = BufferOrErr.getError()) + return EC; Buffer = std::move(BufferOrErr.get()); + + // Don't bother trying to build an index if there is no summary information + // in this bitcode file. + if (!object::FunctionIndexObjectFile::hasFunctionSummaryInMemBuffer( + Buffer->getMemBufferRef(), DiagnosticHandler)) + return std::unique_ptr(nullptr); + ErrorOr> ObjOrErr = object::FunctionIndexObjectFile::create(Buffer->getMemBufferRef(), DiagnosticHandler); - if (std::error_code EC = ObjOrErr.getError()) { - Error = EC.message(); - return nullptr; - } + if (std::error_code EC = ObjOrErr.getError()) + return EC; return (*ObjOrErr)->takeIndex(); } @@ -221,14 +224,18 @@ static int createCombinedFunctionIndex(StringRef Command) { FunctionInfoIndex CombinedIndex; uint64_t NextModuleId = 0; for (auto &Filename : InputFilenames) { - std::string Error; - std::unique_ptr Index = - getFunctionIndexForFile(Filename, Error, diagnosticHandler); - if (!Index) { + ErrorOr> IndexOrErr = + getFunctionIndexForFile(Filename, diagnosticHandler); + if (std::error_code EC = IndexOrErr.getError()) { + std::string Error = EC.message(); errs() << Command << ": error loading file '" << Filename << "': " << Error << "\n"; return 1; } + std::unique_ptr Index = std::move(IndexOrErr.get()); + // Skip files without a function summary. + if (!Index) + continue; CombinedIndex.mergeFrom(std::move(Index), ++NextModuleId); } std::error_code EC;