summaryrefslogtreecommitdiff
path: root/lib/Transforms/Instrumentation
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-05-31 00:11:37 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-05-31 00:11:37 +0000
commit269a999d21bb9879c25385f6d09c08ec685bed34 (patch)
tree68d175e178f7a22f313e5da842dfae20150a53cb /lib/Transforms/Instrumentation
parentc2fe96cad74dc869cdb08ed93d4fcd2c1a1f4a95 (diff)
downloadllvm-269a999d21bb9879c25385f6d09c08ec685bed34.tar.gz
llvm-269a999d21bb9879c25385f6d09c08ec685bed34.tar.bz2
llvm-269a999d21bb9879c25385f6d09c08ec685bed34.tar.xz
[TSan] Behave the same for functions w/o sanitize_thread attribute and blacklisted functions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209939 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Instrumentation')
-rw-r--r--lib/Transforms/Instrumentation/ThreadSanitizer.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
index 345b212d14..233f7f68b6 100644
--- a/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ b/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -322,7 +322,6 @@ static bool isAtomic(Instruction *I) {
bool ThreadSanitizer::runOnFunction(Function &F) {
if (!DL) return false;
- if (BL->isIn(F)) return false;
initializeCallbacks(*F.getParent());
SmallVector<Instruction*, 8> RetVec;
SmallVector<Instruction*, 8> AllLoadsAndStores;
@@ -331,6 +330,8 @@ bool ThreadSanitizer::runOnFunction(Function &F) {
SmallVector<Instruction*, 8> MemIntrinCalls;
bool Res = false;
bool HasCalls = false;
+ bool SanitizeFunction =
+ F.hasFnAttribute(Attribute::SanitizeThread) && !BL->isIn(F);
// Traverse all instructions, collect loads/stores/returns, check for calls.
for (auto &BB : F) {
@@ -355,19 +356,20 @@ bool ThreadSanitizer::runOnFunction(Function &F) {
// FIXME: many of these accesses do not need to be checked for races
// (e.g. variables that do not escape, etc).
- // Instrument memory accesses.
- if (ClInstrumentMemoryAccesses && F.hasFnAttribute(Attribute::SanitizeThread))
+ // Instrument memory accesses only if we want to report bugs in the function.
+ if (ClInstrumentMemoryAccesses && SanitizeFunction)
for (auto Inst : AllLoadsAndStores) {
Res |= instrumentLoadOrStore(Inst);
}
- // Instrument atomic memory accesses.
+ // Instrument atomic memory accesses in any case (they can be used to
+ // implement synchronization).
if (ClInstrumentAtomics)
for (auto Inst : AtomicAccesses) {
Res |= instrumentAtomic(Inst);
}
- if (ClInstrumentMemIntrinsics)
+ if (ClInstrumentMemIntrinsics && SanitizeFunction)
for (auto Inst : MemIntrinCalls) {
Res |= instrumentMemIntrinsic(Inst);
}