[llvm] r254851 - [ASAN] Add doFinalization to reset state
Keno Fischer via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 5 06:42:37 PST 2015
Author: kfischer
Date: Sat Dec 5 08:42:34 2015
New Revision: 254851
URL: http://llvm.org/viewvc/llvm-project?rev=254851&view=rev
Log:
[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
Added:
llvm/trunk/test/Instrumentation/AddressSanitizer/twice.ll
Modified:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=254851&r1=254850&r2=254851&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Sat Dec 5 08:42:34 2015
@@ -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 Functio
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(
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.
Added: llvm/trunk/test/Instrumentation/AddressSanitizer/twice.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/twice.ll?rev=254851&view=auto
==============================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/twice.ll (added)
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/twice.ll Sat Dec 5 08:42:34 2015
@@ -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
+}
More information about the llvm-commits
mailing list