[Clang] Give error message for invalid profile path when compiling IR
Before this patch, when compiling an IR file (eg the .llvmbc section from an object file compiled with -Xclang -fembed-bitcode=all) and profile data was passed in using the -fprofile-instrument-use-path flag, there would be no error printed (as the previous implementation relied on the error getting caught again in the constructor of CodeGenModule which isn't called when -x ir is set). This patch moves the error checking directly to where the error is caught originally rather than failing silently in setPGOUseInstrumentor and waiting to catch it in CodeGenModule to print diagnostic information to the user. Regression test added. Reviewed By: xur, mtrofin Differential Revision: https://reviews.llvm.org/D132991
This commit is contained in:
@@ -182,15 +182,11 @@ CodeGenModule::CodeGenModule(ASTContext &C,
|
||||
if (CodeGenOpts.hasProfileClangUse()) {
|
||||
auto ReaderOrErr = llvm::IndexedInstrProfReader::create(
|
||||
CodeGenOpts.ProfileInstrumentUsePath, CodeGenOpts.ProfileRemappingFile);
|
||||
if (auto E = ReaderOrErr.takeError()) {
|
||||
unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
|
||||
"Could not read profile %0: %1");
|
||||
llvm::handleAllErrors(std::move(E), [&](const llvm::ErrorInfoBase &EI) {
|
||||
getDiags().Report(DiagID) << CodeGenOpts.ProfileInstrumentUsePath
|
||||
<< EI.message();
|
||||
});
|
||||
} else
|
||||
PGOReader = std::move(ReaderOrErr.get());
|
||||
// We're checking for profile read errors in CompilerInvocation, so if
|
||||
// there was an error it should've already been caught. If it hasn't been
|
||||
// somehow, trip an assertion.
|
||||
assert(ReaderOrErr);
|
||||
PGOReader = std::move(ReaderOrErr.get());
|
||||
}
|
||||
|
||||
// If coverage mapping generation is enabled, create the
|
||||
|
||||
Reference in New Issue
Block a user