aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorAiden Grossman <agrossman154@yahoo.com>2022-09-16 19:35:50 +0000
committerAiden Grossman <agrossman154@yahoo.com>2022-09-16 19:45:57 +0000
commitc0bc461999fdac918dd26867947c24eb6235c8d0 (patch)
tree49c00ed268837a53a0143816fd116d94cb5bf637 /clang/lib/CodeGen/CodeGenModule.cpp
parent8a868d8859f9da23ee051848863045208c17ab47 (diff)
downloadllvm-c0bc461999fdac918dd26867947c24eb6235c8d0.zip
llvm-c0bc461999fdac918dd26867947c24eb6235c8d0.tar.gz
llvm-c0bc461999fdac918dd26867947c24eb6235c8d0.tar.bz2
[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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index bbd4295..06ad67a4 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -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