From 9b9908a0472aed5c794e69a166bcb5dd1564f301 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 14 May 2016 05:39:45 +0000 Subject: [PATCH] Revert "Reapply "[ProfileData] (clang) Use Error in InstrProf and Coverage, NFC"" This reverts commit r269492 as the corresponding LLVM commit was reverted due to lots of warnings. See the review thread for the original LLVM commit (r269491) for details. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@269549 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 8 +++----- lib/CodeGen/CodeGenPGO.cpp | 13 ++++++------- lib/Frontend/CompilerInvocation.cpp | 3 +-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 57a6429c4b..79da25c13f 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -141,13 +141,11 @@ CodeGenModule::CodeGenModule(ASTContext &C, const HeaderSearchOptions &HSO, if (CodeGenOpts.hasProfileClangUse()) { auto ReaderOrErr = llvm::IndexedInstrProfReader::create( CodeGenOpts.ProfileInstrumentUsePath); - if (auto E = ReaderOrErr.takeError()) { + if (std::error_code EC = ReaderOrErr.getError()) { 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(); - }); + getDiags().Report(DiagID) << CodeGenOpts.ProfileInstrumentUsePath + << EC.message(); } else PGOReader = std::move(ReaderOrErr.get()); } diff --git a/lib/CodeGen/CodeGenPGO.cpp b/lib/CodeGen/CodeGenPGO.cpp index c19321b512..43bc37c49f 100644 --- a/lib/CodeGen/CodeGenPGO.cpp +++ b/lib/CodeGen/CodeGenPGO.cpp @@ -800,21 +800,20 @@ void CodeGenPGO::loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader, bool IsInMainFile) { CGM.getPGOStats().addVisited(IsInMainFile); RegionCounts.clear(); - llvm::Expected RecordExpected = + llvm::ErrorOr RecordErrorOr = PGOReader->getInstrProfRecord(FuncName, FunctionHash); - if (auto E = RecordExpected.takeError()) { - auto IPE = llvm::InstrProfError::take(std::move(E)); - if (IPE == llvm::instrprof_error::unknown_function) + if (std::error_code EC = RecordErrorOr.getError()) { + if (EC == llvm::instrprof_error::unknown_function) CGM.getPGOStats().addMissing(IsInMainFile); - else if (IPE == llvm::instrprof_error::hash_mismatch) + else if (EC == llvm::instrprof_error::hash_mismatch) CGM.getPGOStats().addMismatched(IsInMainFile); - else if (IPE == llvm::instrprof_error::malformed) + else if (EC == llvm::instrprof_error::malformed) // TODO: Consider a more specific warning for this case. CGM.getPGOStats().addMismatched(IsInMainFile); return; } ProfRecord = - llvm::make_unique(std::move(RecordExpected.get())); + llvm::make_unique(std::move(RecordErrorOr.get())); RegionCounts = ProfRecord->Counts; } diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 20b66906d5..8e93ff1a4b 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -403,8 +403,7 @@ static void setPGOUseInstrumentor(CodeGenOptions &Opts, const std::string ProfileName) { auto ReaderOrErr = llvm::IndexedInstrProfReader::create(ProfileName); // In error, return silently and let Clang PGOUse report the error message. - if (auto E = ReaderOrErr.takeError()) { - llvm::consumeError(std::move(E)); + if (ReaderOrErr.getError()) { Opts.setProfileUse(CodeGenOptions::ProfileClangInstr); return; } -- 2.40.0