|
@@ -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
|
|
/// Parse the function index out of an IR file and return the function
|
|
/// index object if found, or nullptr if not.
|
|
/// index object if found, or nullptr if not.
|
|
-static std::unique_ptr<FunctionInfoIndex>
|
|
|
|
-getFunctionIndexForFile(StringRef Path, std::string &Error,
|
|
|
|
|
|
+static ErrorOr<std::unique_ptr<FunctionInfoIndex>>
|
|
|
|
+getFunctionIndexForFile(StringRef Path,
|
|
DiagnosticHandlerFunction DiagnosticHandler) {
|
|
DiagnosticHandlerFunction DiagnosticHandler) {
|
|
std::unique_ptr<MemoryBuffer> Buffer;
|
|
std::unique_ptr<MemoryBuffer> Buffer;
|
|
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
|
|
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
|
|
MemoryBuffer::getFile(Path);
|
|
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());
|
|
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<FunctionInfoIndex>(nullptr);
|
|
|
|
+
|
|
ErrorOr<std::unique_ptr<object::FunctionIndexObjectFile>> ObjOrErr =
|
|
ErrorOr<std::unique_ptr<object::FunctionIndexObjectFile>> ObjOrErr =
|
|
object::FunctionIndexObjectFile::create(Buffer->getMemBufferRef(),
|
|
object::FunctionIndexObjectFile::create(Buffer->getMemBufferRef(),
|
|
DiagnosticHandler);
|
|
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();
|
|
return (*ObjOrErr)->takeIndex();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -221,14 +224,18 @@ static int createCombinedFunctionIndex(StringRef Command) {
|
|
FunctionInfoIndex CombinedIndex;
|
|
FunctionInfoIndex CombinedIndex;
|
|
uint64_t NextModuleId = 0;
|
|
uint64_t NextModuleId = 0;
|
|
for (auto &Filename : InputFilenames) {
|
|
for (auto &Filename : InputFilenames) {
|
|
- std::string Error;
|
|
|
|
- std::unique_ptr<FunctionInfoIndex> Index =
|
|
|
|
- getFunctionIndexForFile(Filename, Error, diagnosticHandler);
|
|
|
|
- if (!Index) {
|
|
|
|
|
|
+ ErrorOr<std::unique_ptr<FunctionInfoIndex>> IndexOrErr =
|
|
|
|
+ getFunctionIndexForFile(Filename, diagnosticHandler);
|
|
|
|
+ if (std::error_code EC = IndexOrErr.getError()) {
|
|
|
|
+ std::string Error = EC.message();
|
|
errs() << Command << ": error loading file '" << Filename
|
|
errs() << Command << ": error loading file '" << Filename
|
|
<< "': " << Error << "\n";
|
|
<< "': " << Error << "\n";
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
+ std::unique_ptr<FunctionInfoIndex> Index = std::move(IndexOrErr.get());
|
|
|
|
+ // Skip files without a function summary.
|
|
|
|
+ if (!Index)
|
|
|
|
+ continue;
|
|
CombinedIndex.mergeFrom(std::move(Index), ++NextModuleId);
|
|
CombinedIndex.mergeFrom(std::move(Index), ++NextModuleId);
|
|
}
|
|
}
|
|
std::error_code EC;
|
|
std::error_code EC;
|