[compiler-rt] a908c53 - Revert "[HWASan] Use hwasan_memalign for aligned new."

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 12 10:57:36 PST 2022


Author: Nico Weber
Date: 2022-02-12T13:57:28-05:00
New Revision: a908c535f983bd31ab9346675ff89d34334603aa

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

LOG: Revert "[HWASan] Use hwasan_memalign for aligned new."

This reverts commit 4fb7c120fed504519d167c93ed9d920aeae46fb0.
Breaks tests on Linux were system gcc doesn't support C++17
(but gcc used to build LLVM does), see https://reviews.llvm.org/D119161

Added: 
    

Modified: 
    compiler-rt/lib/hwasan/hwasan_new_delete.cpp
    compiler-rt/test/hwasan/TestCases/new-test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/hwasan/hwasan_new_delete.cpp b/compiler-rt/lib/hwasan/hwasan_new_delete.cpp
index 31efb70bca141..4e057a651e1dd 100644
--- a/compiler-rt/lib/hwasan/hwasan_new_delete.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_new_delete.cpp
@@ -29,7 +29,7 @@
   return res
 #define OPERATOR_NEW_ALIGN_BODY(nothrow)                                    \
   GET_MALLOC_STACK_TRACE;                                                   \
-  void *res = hwasan_memalign(static_cast<uptr>(align), size, &stack);      \
+  void *res = hwasan_aligned_alloc(static_cast<uptr>(align), size, &stack); \
   if (!nothrow && UNLIKELY(!res))                                           \
     ReportOutOfMemory(size, &stack);                                        \
   return res

diff  --git a/compiler-rt/test/hwasan/TestCases/new-test.cpp b/compiler-rt/test/hwasan/TestCases/new-test.cpp
index 8a4b3476ea161..3b1991e4deaa5 100644
--- a/compiler-rt/test/hwasan/TestCases/new-test.cpp
+++ b/compiler-rt/test/hwasan/TestCases/new-test.cpp
@@ -1,13 +1,11 @@
 // Test basic new functionality.
-// RUN: %clangxx_hwasan -std=c++17 %s -o %t
+// RUN: %clangxx_hwasan %s -o %t
 // RUN: %run %t
 
-#include <cassert>
-#include <cstdint>
-#include <cstdlib>
-#include <new>
-#include <sanitizer/allocator_interface.h>
+#include <stdlib.h>
+#include <assert.h>
 #include <sanitizer/hwasan_interface.h>
+#include <sanitizer/allocator_interface.h>
 
 int main() {
   __hwasan_enable_allocator_tagging();
@@ -17,12 +15,4 @@ int main() {
   assert(a1 != nullptr);
   assert(__sanitizer_get_allocated_size(a1) == 0);
   delete[] a1;
-
-  // Aligned new/delete
-  constexpr auto kAlign = std::align_val_t{8};
-  void *a2 = ::operator new(4, kAlign);
-  assert(a2 != nullptr);
-  assert(reinterpret_cast<uintptr_t>(a2) % static_cast<uintptr_t>(kAlign) == 0);
-  assert(__sanitizer_get_allocated_size(a2) >= 4);
-  ::operator delete(a2, kAlign);
 }


        


More information about the llvm-commits mailing list