diff options
author | Keno Fischer <kfischer@college.harvard.edu> | 2015-12-05 14:42:34 +0000 |
---|---|---|
committer | Keno Fischer <kfischer@college.harvard.edu> | 2015-12-05 14:42:34 +0000 |
commit | e03fae4f1c4d5c54dfcea4946a6a95f3cd27ad9d (patch) | |
tree | fd88c55ad02e28a140914cb82cb691a096af49c3 /llvm/lib/Transforms | |
parent | 44375e42264d1eb9c77ed2f97178c05c9ec85bee (diff) | |
download | bcm5719-llvm-e03fae4f1c4d5c54dfcea4946a6a95f3cd27ad9d.tar.gz bcm5719-llvm-e03fae4f1c4d5c54dfcea4946a6a95f3cd27ad9d.zip |
[ASAN] Add doFinalization to reset state
Summary: If the same pass manager is used for multiple modules ASAN
complains about GlobalsMD being initialized twice. Fix this by
resetting GlobalsMD in a new doFinalization method to allow this
use case.
Reviewers: kcc
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D14962
llvm-svn: 254851
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 11 |
1 files changed, 11 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. |