[PATCH] D14962: [ASAN] Add doFinalization to reset state

Keno Fischer via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 4 17:32:52 PST 2015


loladiro updated this revision to Diff 41966.
loladiro added a comment.

Add test case


http://reviews.llvm.org/D14962

Files:
  lib/Transforms/Instrumentation/AddressSanitizer.cpp
  test/Transforms/AddressSanitizer/empty-twice.ll

Index: test/Transforms/AddressSanitizer/empty-twice.ll
===================================================================
--- /dev/null
+++ test/Transforms/AddressSanitizer/empty-twice.ll
@@ -0,0 +1,2 @@
+; Check that the address sanitizer pass can be reused
+; RUN: opt < %s -S -run-twice -asan
Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -280,6 +280,11 @@
 
   GlobalsMetadata() : inited_(false) {}
 
+  void reset() {
+    inited_ = false;
+    Entries.clear();
+  }
+
   void init(Module &M) {
     assert(!inited_);
     inited_ = true;
@@ -450,6 +455,7 @@
   bool maybeInsertAsanInitAtFunctionEntry(Function &F);
   void markEscapedLocalAllocas(Function &F);
   bool doInitialization(Module &M) override;
+  bool doFinalization(Module &M) override;
   static char ID;  // Pass identification, replacement for typeid
 
   DominatorTree &getDominatorTree() const { return *DT; }
@@ -1521,6 +1527,11 @@
   return true;
 }
 
+bool AddressSanitizer::doFinalization(Module &M) {
+  GlobalsMD.reset();
+  return false;
+}
+
 bool AddressSanitizer::maybeInsertAsanInitAtFunctionEntry(Function &F) {
   // For each NSObject descendant having a +load method, this method is invoked
   // by the ObjC runtime before any of the static constructors is called.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14962.41966.patch
Type: text/x-patch
Size: 1452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151205/43587587/attachment.bin>


More information about the llvm-commits mailing list