From: Matt Davis Date: Wed, 19 Dec 2018 18:27:05 +0000 (+0000) Subject: [llvm-mca] Add an error handler for error from parseCodeRegions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6bad72cc707c1dc366ef87de14b0c3bcc5b20e93;p=llvm [llvm-mca] Add an error handler for error from parseCodeRegions Summary: It's a bit tricky to add a test for the failing path right now, binary support will have an easier path to exercise the path here. * Ran clang-format. Reviewers: andreadb Reviewed By: andreadb Subscribers: tschuett, gbedwell, llvm-commits Differential Revision: https://reviews.llvm.org/D55803 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349659 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/llvm-mca/llvm-mca.cpp b/tools/llvm-mca/llvm-mca.cpp index d0da3b85c28..37c997c4176 100644 --- a/tools/llvm-mca/llvm-mca.cpp +++ b/tools/llvm-mca/llvm-mca.cpp @@ -149,15 +149,13 @@ static cl::opt cl::desc("If set, assume that loads and stores do not alias"), cl::cat(ToolOptions), cl::init(true)); -static cl::opt - LoadQueueSize("lqueue", - cl::desc("Size of the load queue"), - cl::cat(ToolOptions), cl::init(0)); +static cl::opt LoadQueueSize("lqueue", + cl::desc("Size of the load queue"), + cl::cat(ToolOptions), cl::init(0)); -static cl::opt - StoreQueueSize("squeue", - cl::desc("Size of the store queue"), - cl::cat(ToolOptions), cl::init(0)); +static cl::opt StoreQueueSize("squeue", + cl::desc("Size of the store queue"), + cl::cat(ToolOptions), cl::init(0)); static cl::opt PrintInstructionTables("instruction-tables", @@ -339,8 +337,14 @@ int main(int argc, char **argv) { // Parse the input and create CodeRegions that llvm-mca can analyze. mca::AsmCodeRegionGenerator CRG(*TheTarget, SrcMgr, Ctx, *MAI, *STI, *MCII); Expected RegionsOrErr = CRG.parseCodeRegions(); - if (auto Err = RegionsOrErr.takeError()) { - WithColor::error() << Err << "\n"; + if (!RegionsOrErr) { + if (auto Err = + handleErrors(RegionsOrErr.takeError(), [](const StringError &Err) { + WithColor::error() << Err.getMessage() << '\n'; + })) { + // Default case. + WithColor::error() << toString(std::move(Err)) << '\n'; + } return 1; } const mca::CodeRegions &Regions = *RegionsOrErr;