llvm.org GIT mirror llvm / 269a999
[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 Alexey Samsonov 6 years ago
1 changed file(s) with 7 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
321321
322322 bool ThreadSanitizer::runOnFunction(Function &F) {
323323 if (!DL) return false;
324 if (BL->isIn(F)) return false;
325324 initializeCallbacks(*F.getParent());
326325 SmallVector RetVec;
327326 SmallVector AllLoadsAndStores;
330329 SmallVector MemIntrinCalls;
331330 bool Res = false;
332331 bool HasCalls = false;
332 bool SanitizeFunction =
333 F.hasFnAttribute(Attribute::SanitizeThread) && !BL->isIn(F);
333334
334335 // Traverse all instructions, collect loads/stores/returns, check for calls.
335336 for (auto &BB : F) {
354355 // FIXME: many of these accesses do not need to be checked for races
355356 // (e.g. variables that do not escape, etc).
356357
357 // Instrument memory accesses.
358 if (ClInstrumentMemoryAccesses && F.hasFnAttribute(Attribute::SanitizeThread))
358 // Instrument memory accesses only if we want to report bugs in the function.
359 if (ClInstrumentMemoryAccesses && SanitizeFunction)
359360 for (auto Inst : AllLoadsAndStores) {
360361 Res |= instrumentLoadOrStore(Inst);
361362 }
362363
363 // Instrument atomic memory accesses.
364 // Instrument atomic memory accesses in any case (they can be used to
365 // implement synchronization).
364366 if (ClInstrumentAtomics)
365367 for (auto Inst : AtomicAccesses) {
366368 Res |= instrumentAtomic(Inst);
367369 }
368370
369 if (ClInstrumentMemIntrinsics)
371 if (ClInstrumentMemIntrinsics && SanitizeFunction)
370372 for (auto Inst : MemIntrinCalls) {
371373 Res |= instrumentMemIntrinsic(Inst);
372374 }