[PATCH] D47916: [asan, myriad] Use local pool for new/delete when ASan run-time is not up

Aleksey Shlyapnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 8 09:51:45 PDT 2018


alekseyshl added inline comments.


================
Comment at: compiler-rt/lib/asan/asan_malloc_linux.cc:79
 
+bool FreeFromLocalPool(const void *ptr) {
+  return IsInDlsymAllocPool(ptr);
----------------
IsFromLocalPool


================
Comment at: compiler-rt/lib/asan/asan_malloc_local.h:35
+  if (UNLIKELY(EarlyMalloc()))\
+    return MemalignFromLocalPool(alignment, size);
+
----------------
I'd prefer to have this if in operator new and let the compiler to remove the code in non-rtems case.

Maybe for the symmetry do this:

#define ALLOCATE_FROM_LOCAL_POOL UNLIKELY(EarlyMalloc())
#define ALLOCATE_FROM_LOCAL_POOL 0

if (ALLOCATE_FROM_LOCAL_POOL)
  return MemalignFromLocalPool(alignment, size);

You also probably want to die in !nothrow case

if (ALLOCATE_FROM_LOCAL_POOL) {
  void *res = MemalignFromLocalPool(alignment, size);
  if (!nothrow) CHECK(res);
  return res;
}


================
Comment at: compiler-rt/lib/asan/asan_malloc_local.h:37
+
+#define TRY_FREE_LOCAL_POOL(ptr) \
+  if (UNLIKELY(FreeFromLocalPool(ptr)))\
----------------
How about calling it IS_FROM_LOCAL_POOL

and have an explicit control flow in deletes:
if (IS_FROM_LOCAL_POOL) return;


================
Comment at: compiler-rt/lib/asan/asan_new_delete.cc:74
 #define OPERATOR_NEW_BODY(type, nothrow) \
+  TRY_MEMALIGN_LOCAL_POOL(0, size);\
   GET_STACK_TRACE_MALLOC;\
----------------
Mimic our new behavior here, pass SHADOW_GRANULARITY as an alignment (and add a comment why).


Repository:
  rL LLVM

https://reviews.llvm.org/D47916





More information about the llvm-commits mailing list