[PATCH] D25313: Add asan hooks to Recycler and ArrayRecycler

Nicolai Hähnle via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 14 03:00:34 PDT 2016


nhaehnle updated this revision to Diff 74643.
nhaehnle added a comment.

Extract the MergeStore part to https://reviews.llvm.org/D25601.


https://reviews.llvm.org/D25313

Files:
  include/llvm/Support/ArrayRecycler.h
  include/llvm/Support/Recycler.h


Index: include/llvm/Support/Recycler.h
===================================================================
--- include/llvm/Support/Recycler.h
+++ include/llvm/Support/Recycler.h
@@ -43,13 +43,17 @@
 
   FreeNode *pop_val() {
     auto *Val = FreeList;
+    // Always unpoison the full Size, because the combiner relies on being able
+    // to morph SDNodes into MachineSDNodes.
+    __asan_unpoison_memory_region(FreeList, Size);
     FreeList = FreeList->Next;
     return Val;
   }
 
   void push(FreeNode *N) {
     N->Next = FreeList;
     FreeList = N;
+    __asan_poison_memory_region(FreeList, Size);
   }
 
 public:
Index: include/llvm/Support/ArrayRecycler.h
===================================================================
--- include/llvm/Support/ArrayRecycler.h
+++ include/llvm/Support/ArrayRecycler.h
@@ -48,6 +48,8 @@
     FreeList *Entry = Bucket[Idx];
     if (!Entry)
       return nullptr;
+    __asan_unpoison_memory_region(Entry,
+                                  sizeof(T) * Capacity::get(Idx).getSize());
     Bucket[Idx] = Entry->Next;
     return reinterpret_cast<T*>(Entry);
   }
@@ -60,6 +62,8 @@
       Bucket.resize(size_t(Idx) + 1);
     Entry->Next = Bucket[Idx];
     Bucket[Idx] = Entry;
+    __asan_poison_memory_region(Entry,
+                                sizeof(T) * Capacity::get(Idx).getSize());
   }
 
 public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25313.74643.patch
Type: text/x-patch
Size: 1359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161014/1c2300ce/attachment.bin>


More information about the llvm-commits mailing list