summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp11
-rw-r--r--llvm/test/Instrumentation/AddressSanitizer/twice.ll8
2 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index dea94a514fe..a9df5e5898a 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -280,6 +280,11 @@ class GlobalsMetadata {
GlobalsMetadata() : inited_(false) {}
+ void reset() {
+ inited_ = false;
+ Entries.clear();
+ }
+
void init(Module &M) {
assert(!inited_);
inited_ = true;
@@ -450,6 +455,7 @@ struct AddressSanitizer : public FunctionPass {
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 @@ bool AddressSanitizer::doInitialization(Module &M) {
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.
diff --git a/llvm/test/Instrumentation/AddressSanitizer/twice.ll b/llvm/test/Instrumentation/AddressSanitizer/twice.ll
new file mode 100644
index 00000000000..9f7826f7395
--- /dev/null
+++ b/llvm/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
+}
OpenPOWER on IntegriCloud