[PATCH] D54581: [compiler-rt] Windows Debug build fix

Matthew G McGovern via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 19 11:13:46 PST 2018


mcgov updated this revision to Diff 174652.
mcgov added a comment.

Fix debug builds by defining a Windows section of the OPERATOR_NEW_BODY macro with the MemalignFromLocalPool call and if condition removed. This section is dead code on Windows, anyway.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D54581

Files:
  lib/asan/asan_new_delete.cc


Index: lib/asan/asan_new_delete.cc
===================================================================
--- lib/asan/asan_new_delete.cc
+++ lib/asan/asan_new_delete.cc
@@ -69,6 +69,19 @@
 enum class align_val_t: size_t {};
 }  // namespace std

+//Windows builds do not define MemalignFromLocalPool
+#if SANITIZER_WINDOWS
+#define OPERATOR_NEW_BODY(type, nothrow) \
+  GET_STACK_TRACE_MALLOC;\
+  void *res = asan_memalign(0, size, &stack, type);\
+  if (!nothrow && UNLIKELY(!res)) ReportOutOfMemory(size, &stack);\
+  return res;
+#define OPERATOR_NEW_BODY_ALIGN(type, nothrow) \
+  GET_STACK_TRACE_MALLOC;\
+  void *res = asan_memalign((uptr)align, size, &stack, type);\
+  if (!nothrow && UNLIKELY(!res)) ReportOutOfMemory(size, &stack);\
+  return res;
+#else
 // TODO(alekseyshl): throw std::bad_alloc instead of dying on OOM.
 // For local pool allocation, align to SHADOW_GRANULARITY to match asan
 // allocator behavior.
@@ -92,7 +105,7 @@
   void *res = asan_memalign((uptr)align, size, &stack, type);\
   if (!nothrow && UNLIKELY(!res)) ReportOutOfMemory(size, &stack);\
   return res;
-
+#endif
 // On OS X it's not enough to just provide our own 'operator new' and
 // 'operator delete' implementations, because they're going to be in the
 // runtime dylib, and the main executable will depend on both the runtime


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54581.174652.patch
Type: text/x-patch
Size: 1326 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181119/4e532d7b/attachment.bin>


More information about the llvm-commits mailing list