LLVM
8.0.1
|
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Instrumentation.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/EscapeEnumerator.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "tsan" |
Functions | |
STATISTIC (NumInstrumentedReads, "Number of instrumented reads") | |
STATISTIC (NumInstrumentedWrites, "Number of instrumented writes") | |
STATISTIC (NumOmittedReadsBeforeWrite, "Number of reads ignored due to following writes") | |
STATISTIC (NumAccessesWithBadSize, "Number of accesses with bad size") | |
STATISTIC (NumInstrumentedVtableWrites, "Number of vtable ptr writes") | |
STATISTIC (NumInstrumentedVtableReads, "Number of vtable ptr reads") | |
STATISTIC (NumOmittedReadsFromConstantGlobals, "Number of reads from constant globals") | |
STATISTIC (NumOmittedReadsFromVtable, "Number of vtable reads") | |
STATISTIC (NumOmittedNonCaptured, "Number of accesses ignored due to capturing") | |
INITIALIZE_PASS_BEGIN (ThreadSanitizerLegacyPass, "tsan", "ThreadSanitizer: detects data races.", false, false) INITIALIZE_PASS_END(ThreadSanitizerLegacyPass | |
static bool | isVtableAccess (Instruction *I) |
static bool | shouldInstrumentReadWriteFromAddress (const Module *M, Value *Addr) |
static bool | isAtomic (Instruction *I) |
static ConstantInt * | createOrdering (IRBuilder<> *IRB, AtomicOrdering ord) |
Variables | |
static cl::opt< bool > | ClInstrumentMemoryAccesses ("tsan-instrument-memory-accesses", cl::init(true), cl::desc("Instrument memory accesses"), cl::Hidden) |
static cl::opt< bool > | ClInstrumentFuncEntryExit ("tsan-instrument-func-entry-exit", cl::init(true), cl::desc("Instrument function entry and exit"), cl::Hidden) |
static cl::opt< bool > | ClHandleCxxExceptions ("tsan-handle-cxx-exceptions", cl::init(true), cl::desc("Handle C++ exceptions (insert cleanup blocks for unwinding)"), cl::Hidden) |
static cl::opt< bool > | ClInstrumentAtomics ("tsan-instrument-atomics", cl::init(true), cl::desc("Instrument atomics"), cl::Hidden) |
static cl::opt< bool > | ClInstrumentMemIntrinsics ("tsan-instrument-memintrinsics", cl::init(true), cl::desc("Instrument memintrinsics (memset/memcpy/memmove)"), cl::Hidden) |
static const char *const | kTsanModuleCtorName = "tsan.module_ctor" |
static const char *const | kTsanInitName = "__tsan_init" |
tsan | |
ThreadSanitizer | __pad0__ |
ThreadSanitizer | false |
#define DEBUG_TYPE "tsan" |
Definition at line 53 of file ThreadSanitizer.cpp.
|
static |
Definition at line 573 of file ThreadSanitizer.cpp.
References llvm::Acquire, llvm::AcquireRelease, llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), C, llvm::countTrailingZeros(), llvm::CallInst::Create(), llvm::IRBuilder< T, Inserter >::CreateBitOrPointerCast(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateICmpEQ(), llvm::IRBuilder< T, Inserter >::CreateInsertValue(), llvm::IRBuilder< T, Inserter >::CreateIntCast(), llvm::IRBuilder< T, Inserter >::CreateIntToPtr(), llvm::IRBuilder< T, Inserter >::CreatePointerCast(), llvm::Instruction::eraseFromParent(), llvm::UndefValue::get(), llvm::IRBuilderBase::getContext(), llvm::IRBuilderBase::getInt32(), llvm::IRBuilderBase::getInt32Ty(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::Type::getIntNTy(), llvm::Type::getPointerTo(), llvm::Value::getType(), llvm::DataLayout::getTypeStoreSizeInBits(), llvm::Type::isSized(), kNumberOfAccessSizes, LLVM_FALLTHROUGH, llvm_unreachable, llvm::Monotonic, llvm::NotAtomic, llvm::Release, llvm::Value::replaceAllUsesWith(), llvm::ReplaceInstWithInst(), llvm::SequentiallyConsistent, SI, llvm::SyncScope::SingleThread, Success, and llvm::Unordered.
INITIALIZE_PASS_BEGIN | ( | ThreadSanitizerLegacyPass | , |
"tsan" | , | ||
"ThreadSanitizer: detects data races." | , | ||
false | , | ||
false | |||
) |
Referenced by llvm::ThreadSanitizerPass::run().
|
static |
Definition at line 411 of file ThreadSanitizer.cpp.
References assert(), ClHandleCxxExceptions, ClInstrumentAtomics, ClInstrumentFuncEntryExit, ClInstrumentMemIntrinsics, ClInstrumentMemoryAccesses, llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateExtractElement(), llvm::IRBuilder< T, Inserter >::CreateIntToPtr(), llvm::IRBuilder< T, Inserter >::CreatePointerCast(), llvm::dbgs(), llvm::ConstantInt::get(), getAlignment(), llvm::Module::getDataLayout(), llvm::Intrinsic::getDeclaration(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstNonPHI(), llvm::IRBuilderBase::getInt32Ty(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::GlobalValue::getParent(), llvm::getPointerOperand(), llvm::Value::getType(), llvm::DataLayout::getTypeStoreSizeInBits(), HasCalls, llvm::Function::hasFnAttribute(), I, llvm::Type::isIntegerTy(), llvm::Value::isSwiftError(), isVtableAccess(), LLVM_DEBUG, llvm::maybeMarkSanitizerLibraryCallNoBuiltin(), llvm::EscapeEnumerator::Next(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Intrinsic::returnaddress, llvm::Attribute::SanitizeThread, SI, and llvm::SyncScope::SingleThread.
Referenced by CC_MipsO32_FP64(), emitSignedInt64(), FunctionNumber(), getComparePred(), llvm::LLParser::getContext(), maybePrintCallAddrSpace(), llvm::Instruction::mayReadOrWriteMemory(), and parseOptionalLinkageAux().
|
static |
Definition at line 297 of file ThreadSanitizer.cpp.
References llvm::Instruction::getMetadata(), llvm::LLVMContext::MD_tbaa, and llvm::Tag.
Referenced by isAtomic(), and shouldInstrumentReadWriteFromAddress().
Definition at line 305 of file ThreadSanitizer.cpp.
References llvm::SmallVectorImpl< T >::clear(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::StringRef::endswith(), GEP, llvm::getInstrProfSectionName(), llvm::Type::getPointerAddressSpace(), llvm::LoadInst::getPointerOperand(), llvm::getPointerOperand(), llvm::Type::getScalarType(), llvm::Module::getTargetTriple(), llvm::Value::getType(), llvm::GetUnderlyingObject(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), isVtableAccess(), llvm::SPII::Load, llvm::PointerMayBeCaptured(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::reverse(), llvm::SPII::Store, and llvm::Value::stripInBoundsOffsets().
STATISTIC | ( | NumInstrumentedReads | , |
"Number of instrumented reads" | |||
) |
STATISTIC | ( | NumInstrumentedWrites | , |
"Number of instrumented writes" | |||
) |
STATISTIC | ( | NumOmittedReadsBeforeWrite | , |
"Number of reads ignored due to following writes" | |||
) |
STATISTIC | ( | NumAccessesWithBadSize | , |
"Number of accesses with bad size" | |||
) |
STATISTIC | ( | NumInstrumentedVtableWrites | , |
"Number of vtable ptr writes" | |||
) |
STATISTIC | ( | NumInstrumentedVtableReads | , |
"Number of vtable ptr reads" | |||
) |
STATISTIC | ( | NumOmittedReadsFromConstantGlobals | , |
"Number of reads from constant globals" | |||
) |
STATISTIC | ( | NumOmittedReadsFromVtable | , |
"Number of vtable reads" | |||
) |
STATISTIC | ( | NumOmittedNonCaptured | , |
"Number of accesses ignored due to capturing" | |||
) |
ThreadSanitizer __pad0__ |
Definition at line 160 of file ThreadSanitizer.cpp.
|
static |
Referenced by isAtomic().
|
static |
Referenced by isAtomic().
|
static |
Referenced by isAtomic().
|
static |
Referenced by isAtomic().
|
static |
Referenced by isAtomic().
ThreadSanitizer false |
Definition at line 160 of file ThreadSanitizer.cpp.
Definition at line 85 of file ThreadSanitizer.cpp.
Referenced by llvm::createThreadSanitizerLegacyPassPass().
Definition at line 84 of file ThreadSanitizer.cpp.
Referenced by llvm::createThreadSanitizerLegacyPassPass().
tsan |
Definition at line 160 of file ThreadSanitizer.cpp.