summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/SampleProfile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SampleProfile.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/SampleProfile.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/SampleProfile.cpp b/llvm/lib/Transforms/Scalar/SampleProfile.cpp
index fedbcf3a7c0..8d5480c7cb5 100644
--- a/llvm/lib/Transforms/Scalar/SampleProfile.cpp
+++ b/llvm/lib/Transforms/Scalar/SampleProfile.cpp
@@ -737,8 +737,14 @@ INITIALIZE_PASS_END(SampleProfileLoader, "sample-profile",
"Sample Profile loader", false, false)
bool SampleProfileLoader::doInitialization(Module &M) {
- Reader.reset(new SampleProfileReader(M, Filename));
- ProfileIsValid = Reader->load();
+ if (std::error_code EC =
+ SampleProfileReader::create(Filename, Reader, M.getContext())) {
+ std::string Msg = "Could not open profile: " + EC.message();
+ DiagnosticInfoSampleProfile Diag(Filename.data(), Msg);
+ M.getContext().diagnose(Diag);
+ return false;
+ }
+ ProfileIsValid = (Reader->read() == sampleprof_error::success);
return true;
}
OpenPOWER on IntegriCloud