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

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 5 06:45:35 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL254851: [ASAN] Add doFinalization to reset state (authored by kfischer).

Changed prior to commit:
  http://reviews.llvm.org/D14962?vs=41966&id=41989#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14962

Files:
  llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/trunk/test/Instrumentation/AddressSanitizer/twice.ll

Index: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/trunk/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.
Index: llvm/trunk/test/Instrumentation/AddressSanitizer/twice.ll
===================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/twice.ll
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/twice.ll
@@ -0,0 +1,8 @@
+; Check that the address sanitizer pass can be reused
+; RUN: opt < %s -S -run-twice -asan
+
+define void @foo(i64* %b) nounwind uwtable sanitize_address {
+  entry:
+  store i64 0, i64* %b, align 1
+  ret void
+}


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


More information about the llvm-commits mailing list