[libc-commits] [PATCH] D157247: [test][libc] Fix aligned_alloc argument

Vitaly Buka via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Aug 7 16:36:33 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG9abc1e080dc9: [test][libc] Fix aligned_alloc argument (authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157247

Files:
  libc/benchmarks/LibcMemoryBenchmark.h


Index: libc/benchmarks/LibcMemoryBenchmark.h
===================================================================
--- libc/benchmarks/LibcMemoryBenchmark.h
+++ libc/benchmarks/LibcMemoryBenchmark.h
@@ -17,6 +17,7 @@
 #include "MemorySizeDistributions.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Alignment.h"
+#include "llvm/Support/MathExtras.h"
 #include <cstdint>
 #include <optional>
 #include <random>
@@ -107,11 +108,11 @@
   size_t Size = 0;
 
 public:
-  // Note: msan / asan can't handle Alignment > 512.
   static constexpr size_t Alignment = 512;
 
   explicit AlignedBuffer(size_t Size)
-      : Buffer(static_cast<char *>(aligned_alloc(Alignment, Size))),
+      : Buffer(static_cast<char *>(
+            aligned_alloc(Alignment, alignTo(Size, Alignment)))),
         Size(Size) {}
   ~AlignedBuffer() { free(Buffer); }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157247.547993.patch
Type: text/x-patch
Size: 852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230807/479cf1fa/attachment.bin>


More information about the libc-commits mailing list