[PATCH] D55803: [llvm-mca] Add an error handler for error from parseCodeRegions

Matt Davis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 17 20:15:02 PST 2018


mattd updated this revision to Diff 178583.
mattd added a comment.

- Added context


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55803/new/

https://reviews.llvm.org/D55803

Files:
  tools/llvm-mca/llvm-mca.cpp


Index: tools/llvm-mca/llvm-mca.cpp
===================================================================
--- tools/llvm-mca/llvm-mca.cpp
+++ tools/llvm-mca/llvm-mca.cpp
@@ -149,15 +149,13 @@
                   cl::desc("If set, assume that loads and stores do not alias"),
                   cl::cat(ToolOptions), cl::init(true));
 
-static cl::opt<unsigned>
-    LoadQueueSize("lqueue",
-                  cl::desc("Size of the load queue"),
-                  cl::cat(ToolOptions), cl::init(0));
+static cl::opt<unsigned> LoadQueueSize("lqueue",
+                                       cl::desc("Size of the load queue"),
+                                       cl::cat(ToolOptions), cl::init(0));
 
-static cl::opt<unsigned>
-    StoreQueueSize("squeue",
-                   cl::desc("Size of the store queue"),
-                   cl::cat(ToolOptions), cl::init(0));
+static cl::opt<unsigned> StoreQueueSize("squeue",
+                                        cl::desc("Size of the store queue"),
+                                        cl::cat(ToolOptions), cl::init(0));
 
 static cl::opt<bool>
     PrintInstructionTables("instruction-tables",
@@ -339,8 +337,14 @@
   // Parse the input and create CodeRegions that llvm-mca can analyze.
   mca::AsmCodeRegionGenerator CRG(*TheTarget, SrcMgr, Ctx, *MAI, *STI, *MCII);
   Expected<const mca::CodeRegions &> 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55803.178583.patch
Type: text/x-patch
Size: 1858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181218/139276cc/attachment.bin>


More information about the llvm-commits mailing list