[llvm] a5de497 - [NFC][llvm-exegesis] `InstructionBenchmark`: only allow move constructor

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 17 17:23:41 PST 2022


Author: Roman Lebedev
Date: 2022-12-18T04:23:20+03:00
New Revision: a5de49755cab6ccea9380f7f51a133d2e37cdc88

URL: https://github.com/llvm/llvm-project/commit/a5de49755cab6ccea9380f7f51a133d2e37cdc88
DIFF: https://github.com/llvm/llvm-project/commit/a5de49755cab6ccea9380f7f51a133d2e37cdc88.diff

LOG: [NFC][llvm-exegesis] `InstructionBenchmark`: only allow move constructor

We don't ever legitimately need to copy it, so let's make that explicit

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
index 679946d723e0..11c2ade6789e 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
@@ -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);

diff  --git a/llvm/unittests/tools/llvm-exegesis/Mips/BenchmarkResultTest.cpp b/llvm/unittests/tools/llvm-exegesis/Mips/BenchmarkResultTest.cpp
index 429e6589eb5d..575e53d75310 100644
--- a/llvm/unittests/tools/llvm-exegesis/Mips/BenchmarkResultTest.cpp
+++ b/llvm/unittests/tools/llvm-exegesis/Mips/BenchmarkResultTest.cpp
@@ -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);

diff  --git a/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp b/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
index 0d47a76b5480..bfee792d158a 100644
--- a/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
+++ b/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
@@ -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);


        


More information about the llvm-commits mailing list