[libc-commits] [libc] 8dcb7f6 - [libc][Obvious] Fix memory function benchmarks after removal of None.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Sat Dec 10 16:38:05 PST 2022


Author: Siva Chandra Reddy
Date: 2022-12-11T00:31:21Z
New Revision: 8dcb7f6b6f7863331a88798415144f0cabc4b59b

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

LOG: [libc][Obvious] Fix memory function benchmarks after removal of None.

Added: 
    

Modified: 
    libc/benchmarks/JSON.cpp
    libc/benchmarks/LibcMemoryBenchmark.h
    libc/benchmarks/LibcMemoryBenchmarkTest.cpp

Removed: 
    


################################################################################
diff  --git a/libc/benchmarks/JSON.cpp b/libc/benchmarks/JSON.cpp
index f2a9d8b27f48..fd5cf4573344 100644
--- a/libc/benchmarks/JSON.cpp
+++ b/libc/benchmarks/JSON.cpp
@@ -21,6 +21,7 @@
 #include <chrono>
 #include <limits>
 #include <memory>
+#include <optional>
 #include <string>
 #include <vector>
 
@@ -86,7 +87,7 @@ static Error fromJson(const json::Value &V, MaybeAlign &Out) {
                              "Can't parse Align, not an Integer");
   const int64_t Value = *MaybeInt;
   if (!Value) {
-    Out = None;
+    Out = std::nullopt;
     return Error::success();
   }
   if (isPowerOf2_64(Value)) {
@@ -108,7 +109,7 @@ static Error fromJson(const json::Value &V,
           .Case("None", libc_benchmarks::BenchmarkLog::None)
           .Case("Last", libc_benchmarks::BenchmarkLog::Last)
           .Case("Full", libc_benchmarks::BenchmarkLog::Full)
-          .Default(None);
+          .Default(std::nullopt);
   if (!Parsed)
     return createStringError(errc::io_error,
                              Twine("Can't parse BenchmarkLog, invalid value '")

diff  --git a/libc/benchmarks/LibcMemoryBenchmark.h b/libc/benchmarks/LibcMemoryBenchmark.h
index b3f0f94cd314..382ff867e36f 100644
--- a/libc/benchmarks/LibcMemoryBenchmark.h
+++ b/libc/benchmarks/LibcMemoryBenchmark.h
@@ -18,6 +18,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Alignment.h"
 #include <cstdint>
+#include <optional>
 #include <random>
 
 namespace llvm {
@@ -58,7 +59,7 @@ struct StudyConfiguration {
   // None : Use a fixed address that is at least cache line aligned,
   //    1 : Use random address,
   //   >1 : Use random address aligned to value.
-  MaybeAlign AccessAlignment = None;
+  MaybeAlign AccessAlignment = std::nullopt;
 
   // When Function == 'memcmp', this is the buffers mismatch position.
   //  0 : Buffers always compare equal,

diff  --git a/libc/benchmarks/LibcMemoryBenchmarkTest.cpp b/libc/benchmarks/LibcMemoryBenchmarkTest.cpp
index 4de521aafeac..00866e5a65c2 100644
--- a/libc/benchmarks/LibcMemoryBenchmarkTest.cpp
+++ b/libc/benchmarks/LibcMemoryBenchmarkTest.cpp
@@ -10,6 +10,7 @@
 #include "llvm/Support/Alignment.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include <optional>
 
 using testing::AllOf;
 using testing::AnyOf;
@@ -35,7 +36,7 @@ TEST(AlignedBuffer, Empty) {
 
 TEST(OffsetDistribution, AlignToBegin) {
   const size_t BufferSize = 8192;
-  OffsetDistribution OD(BufferSize, 1024, None);
+  OffsetDistribution OD(BufferSize, 1024, std::nullopt);
   std::default_random_engine Gen;
   for (size_t I = 0; I <= 10; ++I)
     EXPECT_EQ(OD(Gen), 0U);


        


More information about the libc-commits mailing list