Recommit: "[llvm-exegesis] Improve error reporting in Target.cpp"

Summary: Commit 141915963b6ab36ee4e577d1b27673fa4d05b409 was reverted in
abe01e17f648a97666d4fbed41f0861686a17972 because it broke builds testing
without libpfm. A preparatory commit <commit_sha1> was added to enable
this recommit.

Original commit message:

Followup to D74085.
Replace the use of `report_fatal_error()` with returning the error to
`llvm-exegesis.cpp` and handling it there.

Differential Revision: https://reviews.llvm.org/D74113
diff --git a/llvm/tools/llvm-exegesis/lib/Target.cpp b/llvm/tools/llvm-exegesis/lib/Target.cpp
index 701ff14..7fb2231 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Target.cpp
@@ -53,7 +53,7 @@
   return nullptr;
 }
 
-std::unique_ptr<BenchmarkRunner>
+Expected<std::unique_ptr<BenchmarkRunner>>
 ExegesisTarget::createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
                                       const LLVMState &State) const {
   PfmCountersInfo PfmCounters = State.getPfmCounters();
@@ -66,14 +66,16 @@
       const char *ModeName = Mode == InstructionBenchmark::Latency
                                  ? "latency"
                                  : "inverse_throughput";
-      report_fatal_error(Twine("can't run '").concat(ModeName).concat("' mode, "
-                               "sched model does not define a cycle counter."));
+      return make_error<Failure>(
+          Twine("can't run '")
+              .concat(ModeName)
+              .concat("' mode, sched model does not define a cycle counter."));
     }
     return createLatencyBenchmarkRunner(State, Mode);
   case InstructionBenchmark::Uops:
     if (!PfmCounters.UopsCounter && !PfmCounters.IssueCounters)
-      report_fatal_error("can't run 'uops' mode, sched model does not define "
-                         "uops or issue counters.");
+      return make_error<Failure>("can't run 'uops' mode, sched model does not "
+                                 "define uops or issue counters.");
     return createUopsBenchmarkRunner(State);
   }
   return nullptr;