summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2016-05-19 03:54:45 +0000
committerVedant Kumar <vsk@apple.com>2016-05-19 03:54:45 +0000
commit9152fd17e9a0b2fc8edf41503c026ade1d0d5b1b (patch)
treeded89a21e5bbd6aa84185c4e53395cb593d615c5 /llvm/lib/Transforms
parentb784ed36c0cefd3d3289417143deecb6a7b81622 (diff)
downloadbcm5719-llvm-9152fd17e9a0b2fc8edf41503c026ade1d0d5b1b.tar.gz
bcm5719-llvm-9152fd17e9a0b2fc8edf41503c026ade1d0d5b1b.zip
Retry^3 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"
Transition InstrProf and Coverage over to the stricter Error/Expected interface. Changes since the initial commit: - Fix error message printing in llvm-profdata. - Check errors in loadTestingFormat() + annotateAllFunctions(). - Defer error handling in InstrProfIterator to InstrProfReader. - Remove the base ProfError class to work around an MSVC ICE. Differential Revision: http://reviews.llvm.org/D19901 llvm-svn: 270020
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp4
-rw-r--r--llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp43
2 files changed, 27 insertions, 20 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index 60f77d47fb4..34967ef984f 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -388,9 +388,9 @@ void InstrProfiling::emitNameData() {
return;
std::string CompressedNameStr;
- if (auto EC = collectPGOFuncNameStrings(ReferencedNames, CompressedNameStr,
+ if (Error E = collectPGOFuncNameStrings(ReferencedNames, CompressedNameStr,
DoNameCompression)) {
- llvm::report_fatal_error(EC.message(), false);
+ llvm::report_fatal_error(toString(std::move(E)), false);
}
auto &Ctx = M->getContext();
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index 379f7c5ebed..835f75edcd2 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -582,23 +582,28 @@ void PGOUseFunc::setEdgeCount(DirectEdges &Edges, uint64_t Value) {
// Return true if the profile are successfully read, and false on errors.
bool PGOUseFunc::readCounters(IndexedInstrProfReader *PGOReader) {
auto &Ctx = M->getContext();
- ErrorOr<InstrProfRecord> Result =
+ Expected<InstrProfRecord> Result =
PGOReader->getInstrProfRecord(FuncInfo.FuncName, FuncInfo.FunctionHash);
- if (std::error_code EC = Result.getError()) {
- if (EC == instrprof_error::unknown_function) {
- NumOfPGOMissing++;
- if (NoPGOWarnMissing)
- return false;
- } else if (EC == instrprof_error::hash_mismatch ||
- EC == llvm::instrprof_error::malformed) {
- NumOfPGOMismatch++;
- if (NoPGOWarnMismatch)
- return false;
- }
+ if (Error E = Result.takeError()) {
+ handleAllErrors(std::move(E), [&](const InstrProfError &IPE) {
+ auto Err = IPE.get();
+ bool SkipWarning = false;
+ if (Err == instrprof_error::unknown_function) {
+ NumOfPGOMissing++;
+ SkipWarning = NoPGOWarnMissing;
+ } else if (Err == instrprof_error::hash_mismatch ||
+ Err == instrprof_error::malformed) {
+ NumOfPGOMismatch++;
+ SkipWarning = NoPGOWarnMismatch;
+ }
- std::string Msg = EC.message() + std::string(" ") + F.getName().str();
- Ctx.diagnose(
- DiagnosticInfoPGOProfile(M->getName().data(), Msg, DS_Warning));
+ if (SkipWarning)
+ return;
+
+ std::string Msg = IPE.message() + std::string(" ") + F.getName().str();
+ Ctx.diagnose(
+ DiagnosticInfoPGOProfile(M->getName().data(), Msg, DS_Warning));
+ });
return false;
}
ProfileRecord = std::move(Result.get());
@@ -854,9 +859,11 @@ static bool annotateAllFunctions(
auto &Ctx = M.getContext();
// Read the counter array from file.
auto ReaderOrErr = IndexedInstrProfReader::create(ProfileFileName);
- if (std::error_code EC = ReaderOrErr.getError()) {
- Ctx.diagnose(
- DiagnosticInfoPGOProfile(ProfileFileName.data(), EC.message()));
+ if (Error E = ReaderOrErr.takeError()) {
+ handleAllErrors(std::move(E), [&](const ErrorInfoBase &EI) {
+ Ctx.diagnose(
+ DiagnosticInfoPGOProfile(ProfileFileName.data(), EI.message()));
+ });
return false;
}
OpenPOWER on IntegriCloud