[NFC][llvm-exegesis] `InstructionBenchmark`: only allow move constructor
authorRoman Lebedev <lebedev.ri@gmail.com>
Sat, 17 Dec 2022 20:48:57 +0000 (23:48 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sun, 18 Dec 2022 01:23:20 +0000 (04:23 +0300)
We don't ever legitimately need to copy it, so let's make that explicit

llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
llvm/unittests/tools/llvm-exegesis/Mips/BenchmarkResultTest.cpp
llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp

index 679946d..11c2ade 100644 (file)
@@ -78,6 +78,14 @@ struct InstructionBenchmark {
   std::vector<uint8_t> AssembledSnippet;
   // How to aggregate measurements.
   enum ResultAggregationModeE { Min, Max, Mean, MinVariance };
+
+  InstructionBenchmark() = default;
+  InstructionBenchmark(InstructionBenchmark &&) = default;
+
+  InstructionBenchmark(const InstructionBenchmark &) = delete;
+  InstructionBenchmark &operator=(const InstructionBenchmark &) = delete;
+  InstructionBenchmark &operator=(InstructionBenchmark &&) = delete;
+
   // Read functions.
   static Expected<InstructionBenchmark> readYaml(const LLVMState &State,
                                                  MemoryBufferRef Buffer);
index 429e658..575e53d 100644 (file)
@@ -112,7 +112,7 @@ TEST_F(MipsBenchmarkResultTest, WriteToAndReadFromDisk) {
     const auto FromDiskVector =
         ExitOnErr(InstructionBenchmark::readYamls(State, *Buffer));
     ASSERT_EQ(FromDiskVector.size(), size_t{1});
-    const auto FromDisk = FromDiskVector[0];
+    const auto &FromDisk = FromDiskVector[0];
     EXPECT_THAT(FromDisk.Key.Instructions,
                 Pointwise(EqMCInst(), ToDisk.Key.Instructions));
     EXPECT_EQ(FromDisk.Key.Config, ToDisk.Key.Config);
index 0d47a76..bfee792 100644 (file)
@@ -136,7 +136,7 @@ TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
     const auto FromDiskVector =
         ExitOnErr(InstructionBenchmark::readYamls(State, *Buffer));
     ASSERT_EQ(FromDiskVector.size(), size_t{1});
-    const auto FromDisk = FromDiskVector[0];
+    const auto &FromDisk = FromDiskVector[0];
     EXPECT_THAT(FromDisk.Key.Instructions,
                 Pointwise(EqMCInst(), ToDisk.Key.Instructions));
     EXPECT_EQ(FromDisk.Key.Config, ToDisk.Key.Config);