r229434 - InstrProf: Update for LLVM API change

Justin Bogner mail at justinbogner.com
Sun Apr 5 22:36:01 PDT 2015


Nico Weber <thakis at chromium.org> writes:
> This introduced a crash that I just fixed in r234141. Maybe auto shouldn't be
> used for ErrorOr, to make it more difficult to make this type of mistake?

Sorry for the breakage, and thanks for catching this!

I'm not sure how not using auto would've helped here. This was simply a
case of me being dumb and considering the error path like an error that
exits early. I could've easily made the same silly mistake having
spelled out Error<IndexedInstrProfReader>.

I'm not sure how we could change this API to make this kind of mistake
harder.

> On Mon, Feb 16, 2015 at 1:29 PM, Justin Bogner <mail at justinbogner.com> wrote:
>
>     Author: bogner
>     Date: Mon Feb 16 15:29:05 2015
>     New Revision: 229434
>    
>     URL: http://llvm.org/viewvc/llvm-project?rev=229434&view=rev
>     Log:
>     InstrProf: Update for LLVM API change
>    
>     Update for the API change in r229433
>    
>     Modified:
>         cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>    
>     Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>     URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
>     CodeGenModule.cpp?rev=229434&r1=229433&r2=229434&view=diff
>     ==========================================================================
>     ====
>     --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
>     +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Feb 16 15:29:05 2015
>     @@ -140,12 +140,14 @@ CodeGenModule::CodeGenModule(ASTContext
>        RRData = new RREntrypoints();
>    
>        if (!CodeGenOpts.InstrProfileInput.empty()) {
>     -    if (std::error_code EC = llvm::IndexedInstrProfReader::create(
>     -            CodeGenOpts.InstrProfileInput, PGOReader)) {
>     +    auto ReaderOrErr =
>     +        llvm::IndexedInstrProfReader::create
>     (CodeGenOpts.InstrProfileInput);
>     +    if (std::error_code EC = ReaderOrErr.getError()) {
>            unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
>                                                    "Could not read profile:
>     %0");
>            getDiags().Report(DiagID) << EC.message();
>          }
>     +    PGOReader = std::move(ReaderOrErr.get());
>        }
>    
>        // If coverage mapping generation is enabled, create the
>
>     _______________________________________________
>     cfe-commits mailing list
>     cfe-commits at cs.uiuc.edu
>     http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list