LLVM  6.0.0svn
Macros | Functions | Variables
SanitizerCoverage.cpp File Reference
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/EHPersonalities.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Instrumentation.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
Include dependency graph for SanitizerCoverage.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "sancov"
 

Functions

static bool isFullDominator (const BasicBlock *BB, const DominatorTree *DT)
 
static bool isFullPostDominator (const BasicBlock *BB, const PostDominatorTree *PDT)
 
static bool shouldInstrumentBlock (const Function &F, const BasicBlock *BB, const DominatorTree *DT, const PostDominatorTree *PDT, const SanitizerCoverageOptions &Options)
 
 INITIALIZE_PASS_BEGIN (SanitizerCoverageModule, "sancov", "SanitizerCoverage: TODO." "ModulePass", false, false) INITIALIZE_PASS_END(SanitizerCoverageModule
 

Variables

static const char *const SanCovTracePCIndirName
 
static const char *const SanCovTracePCName = "__sanitizer_cov_trace_pc"
 
static const char *const SanCovTraceCmp1 = "__sanitizer_cov_trace_cmp1"
 
static const char *const SanCovTraceCmp2 = "__sanitizer_cov_trace_cmp2"
 
static const char *const SanCovTraceCmp4 = "__sanitizer_cov_trace_cmp4"
 
static const char *const SanCovTraceCmp8 = "__sanitizer_cov_trace_cmp8"
 
static const char *const SanCovTraceConstCmp1
 
static const char *const SanCovTraceConstCmp2
 
static const char *const SanCovTraceConstCmp4
 
static const char *const SanCovTraceConstCmp8
 
static const char *const SanCovTraceDiv4 = "__sanitizer_cov_trace_div4"
 
static const char *const SanCovTraceDiv8 = "__sanitizer_cov_trace_div8"
 
static const char *const SanCovTraceGep = "__sanitizer_cov_trace_gep"
 
static const char *const SanCovTraceSwitchName = "__sanitizer_cov_trace_switch"
 
static const char *const SanCovModuleCtorName = "sancov.module_ctor"
 
static const uint64_t SanCtorAndDtorPriority = 2
 
static const char *const SanCovTracePCGuardName
 
static const char *const SanCovTracePCGuardInitName
 
static const char *const SanCov8bitCountersInitName
 
static const char *const SanCovPCsInitName = "__sanitizer_cov_pcs_init"
 
static const char *const SanCovGuardsSectionName = "sancov_guards"
 
static const char *const SanCovCountersSectionName = "sancov_cntrs"
 
static const char *const SanCovPCsSectionName = "sancov_pcs"
 
static const char *const SanCovLowestStackName = "__sancov_lowest_stack"
 
static cl::opt< int > ClCoverageLevel ("sanitizer-coverage-level", cl::desc("Sanitizer Coverage. 0: none, 1: entry block, 2: all blocks, " "3: all blocks and critical edges"), cl::Hidden, cl::init(0))
 
static cl::opt< boolClTracePC ("sanitizer-coverage-trace-pc", cl::desc("Experimental pc tracing"), cl::Hidden, cl::init(false))
 
static cl::opt< boolClTracePCGuard ("sanitizer-coverage-trace-pc-guard", cl::desc("pc tracing with a guard"), cl::Hidden, cl::init(false))
 
static cl::opt< boolClCreatePCTable ("sanitizer-coverage-pc-table", cl::desc("create a static PC table"), cl::Hidden, cl::init(false))
 
static cl::opt< boolClInline8bitCounters ("sanitizer-coverage-inline-8bit-counters", cl::desc("increments 8-bit counter for every edge"), cl::Hidden, cl::init(false))
 
static cl::opt< boolClCMPTracing ("sanitizer-coverage-trace-compares", cl::desc("Tracing of CMP and similar instructions"), cl::Hidden, cl::init(false))
 
static cl::opt< boolClDIVTracing ("sanitizer-coverage-trace-divs", cl::desc("Tracing of DIV instructions"), cl::Hidden, cl::init(false))
 
static cl::opt< boolClGEPTracing ("sanitizer-coverage-trace-geps", cl::desc("Tracing of GEP instructions"), cl::Hidden, cl::init(false))
 
static cl::opt< boolClPruneBlocks ("sanitizer-coverage-prune-blocks", cl::desc("Reduce the number of instrumented blocks"), cl::Hidden, cl::init(true))
 
static cl::opt< boolClStackDepth ("sanitizer-coverage-stack-depth", cl::desc("max stack depth tracing"), cl::Hidden, cl::init(false))
 
 sancov
 
SanitizerCoverage __pad0__
 
SanitizerCoverage false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "sancov"

Definition at line 44 of file SanitizerCoverage.cpp.

Function Documentation

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( SanitizerCoverageModule  ,
"sancov"  ,
"SanitizerCoverage: TODO." "ModulePass ,
false  ,
false   
)

Referenced by shouldInstrumentBlock().

◆ isFullDominator()

static bool isFullDominator ( const BasicBlock BB,
const DominatorTree DT 
)
static

◆ isFullPostDominator()

static bool isFullPostDominator ( const BasicBlock BB,
const PostDominatorTree PDT 
)
static

◆ shouldInstrumentBlock()

static bool shouldInstrumentBlock ( const Function F,
const BasicBlock BB,
const DominatorTree DT,
const PostDominatorTree PDT,
const SanitizerCoverageOptions Options 
)
static

Definition at line 438 of file SanitizerCoverage.cpp.

References assert(), llvm::GlobalValue::AvailableExternallyLinkage, B, llvm::SmallVectorTemplateCommon< T >::begin(), C, Callee, llvm::classifyEHPersonality(), llvm::Triple::COFF, llvm::SanitizerCoverageOptions::CoverageType, llvm::IRBuilder< T, Inserter >::CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateGEP(), llvm::IRBuilder< T, Inserter >::CreateICmpULT(), llvm::IRBuilder< T, Inserter >::CreateIntCast(), llvm::IRBuilder< T, Inserter >::CreateIntToPtr(), llvm::IRBuilder< T, Inserter >::CreateLoad(), llvm::IRBuilder< T, Inserter >::CreatePointerCast(), llvm::IRBuilder< T, Inserter >::CreatePtrToInt(), llvm::IRBuilder< T, Inserter >::CreateStore(), llvm::ArrayRef< T >::empty(), llvm::Function::empty(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::BasicBlock::end(), F(), llvm::StringRef::find(), GEP, llvm::DebugLoc::get(), llvm::ConstantInt::get(), llvm::ArrayType::get(), llvm::ConstantArray::get(), llvm::BlockAddress::get(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledValue(), llvm::ConstantExpr::getCast(), llvm::GlobalObject::getComdat(), llvm::Intrinsic::getDeclaration(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstInsertionPt(), llvm::Type::getIntNTy(), llvm::GlobalValue::getLinkage(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::GlobalValue::getParent(), llvm::Function::getPersonalityFn(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::BasicBlock::getSinglePredecessor(), llvm::Function::getSubprogram(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::Function::hasPersonalityFn(), I, llvm::SystemZISD::ICMP, llvm::SanitizerCoverageOptions::IndirectCalls, INITIALIZE_PASS_BEGIN(), INITIALIZE_PASS_DEPENDENCY, llvm::SanitizerCoverageOptions::Inline8bitCounters, Int32Ty, llvm::GlobalValue::InternalLinkage, llvm::isAsynchronousEHPersonality(), isFullDominator(), isFullPostDominator(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::SPII::Load, N, llvm::SanitizerCoverageOptions::NoPrune, llvm::SanitizerCoverageOptions::PCTable, llvm::PrepareToSplitEntryBlock(), llvm::GlobalValue::PrivateLinkage, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), SanCovCountersSectionName, SanCovGuardsSectionName, llvm::SanitizerCoverageOptions::SCK_Edge, llvm::SanitizerCoverageOptions::SCK_Function, llvm::ARMBuildAttrs::Section, llvm::IRBuilderBase::SetCurrentDebugLocation(), SI, llvm::SmallVectorTemplateCommon< T >::size(), llvm::ArrayRef< T >::size(), llvm::parallel::sort(), llvm::SplitAllCriticalEdges(), llvm::SplitBlockAndInsertIfThen(), llvm::SanitizerCoverageOptions::StackDepth, llvm::StringRef::startswith(), llvm::SPII::Store, std::swap(), llvm::SanitizerCoverageOptions::TraceCmp, llvm::SanitizerCoverageOptions::TraceDiv, llvm::SanitizerCoverageOptions::TraceGep, llvm::SanitizerCoverageOptions::TracePC, and llvm::SanitizerCoverageOptions::TracePCGuard.

Variable Documentation

◆ __pad0__

SanitizerCoverage __pad0__

Definition at line 831 of file SanitizerCoverage.cpp.

◆ ClCMPTracing

cl::opt<bool> ClCMPTracing("sanitizer-coverage-trace-compares", cl::desc("Tracing of CMP and similar instructions"), cl::Hidden, cl::init(false))
static

◆ ClCoverageLevel

cl::opt<int> ClCoverageLevel("sanitizer-coverage-level", cl::desc("Sanitizer Coverage. 0: none, 1: entry block, 2: all blocks, " "3: all blocks and critical edges"), cl::Hidden, cl::init(0))
static

◆ ClCreatePCTable

cl::opt<bool> ClCreatePCTable("sanitizer-coverage-pc-table", cl::desc("create a static PC table"), cl::Hidden, cl::init(false))
static

◆ ClDIVTracing

cl::opt<bool> ClDIVTracing("sanitizer-coverage-trace-divs", cl::desc("Tracing of DIV instructions"), cl::Hidden, cl::init(false))
static

◆ ClGEPTracing

cl::opt<bool> ClGEPTracing("sanitizer-coverage-trace-geps", cl::desc("Tracing of GEP instructions"), cl::Hidden, cl::init(false))
static

◆ ClInline8bitCounters

cl::opt<bool> ClInline8bitCounters("sanitizer-coverage-inline-8bit-counters", cl::desc("increments 8-bit counter for every edge"), cl::Hidden, cl::init(false))
static

◆ ClPruneBlocks

cl::opt<bool> ClPruneBlocks("sanitizer-coverage-prune-blocks", cl::desc("Reduce the number of instrumented blocks"), cl::Hidden, cl::init(true))
static

◆ ClStackDepth

cl::opt<bool> ClStackDepth("sanitizer-coverage-stack-depth", cl::desc("max stack depth tracing"), cl::Hidden, cl::init(false))
static

◆ ClTracePC

cl::opt<bool> ClTracePC("sanitizer-coverage-trace-pc", cl::desc("Experimental pc tracing"), cl::Hidden, cl::init(false))
static

◆ ClTracePCGuard

cl::opt<bool> ClTracePCGuard("sanitizer-coverage-trace-pc-guard", cl::desc("pc tracing with a guard"), cl::Hidden, cl::init(false))
static

◆ false

SanitizerCoverage false

Definition at line 831 of file SanitizerCoverage.cpp.

◆ sancov

sancov

Definition at line 831 of file SanitizerCoverage.cpp.

◆ SanCov8bitCountersInitName

const char* const SanCov8bitCountersInitName
static
Initial value:
=
"__sanitizer_cov_8bit_counters_init"

Definition at line 72 of file SanitizerCoverage.cpp.

◆ SanCovCountersSectionName

const char* const SanCovCountersSectionName = "sancov_cntrs"
static

Definition at line 77 of file SanitizerCoverage.cpp.

Referenced by shouldInstrumentBlock().

◆ SanCovGuardsSectionName

const char* const SanCovGuardsSectionName = "sancov_guards"
static

Definition at line 76 of file SanitizerCoverage.cpp.

Referenced by shouldInstrumentBlock().

◆ SanCovLowestStackName

const char* const SanCovLowestStackName = "__sancov_lowest_stack"
static

Definition at line 80 of file SanitizerCoverage.cpp.

◆ SanCovModuleCtorName

const char* const SanCovModuleCtorName = "sancov.module_ctor"
static

Definition at line 65 of file SanitizerCoverage.cpp.

◆ SanCovPCsInitName

const char* const SanCovPCsInitName = "__sanitizer_cov_pcs_init"
static

Definition at line 74 of file SanitizerCoverage.cpp.

◆ SanCovPCsSectionName

const char* const SanCovPCsSectionName = "sancov_pcs"
static

Definition at line 78 of file SanitizerCoverage.cpp.

◆ SanCovTraceCmp1

const char* const SanCovTraceCmp1 = "__sanitizer_cov_trace_cmp1"
static

Definition at line 49 of file SanitizerCoverage.cpp.

◆ SanCovTraceCmp2

const char* const SanCovTraceCmp2 = "__sanitizer_cov_trace_cmp2"
static

Definition at line 50 of file SanitizerCoverage.cpp.

◆ SanCovTraceCmp4

const char* const SanCovTraceCmp4 = "__sanitizer_cov_trace_cmp4"
static

Definition at line 51 of file SanitizerCoverage.cpp.

◆ SanCovTraceCmp8

const char* const SanCovTraceCmp8 = "__sanitizer_cov_trace_cmp8"
static

Definition at line 52 of file SanitizerCoverage.cpp.

◆ SanCovTraceConstCmp1

const char* const SanCovTraceConstCmp1
static
Initial value:
=
"__sanitizer_cov_trace_const_cmp1"

Definition at line 53 of file SanitizerCoverage.cpp.

◆ SanCovTraceConstCmp2

const char* const SanCovTraceConstCmp2
static
Initial value:
=
"__sanitizer_cov_trace_const_cmp2"

Definition at line 55 of file SanitizerCoverage.cpp.

◆ SanCovTraceConstCmp4

const char* const SanCovTraceConstCmp4
static
Initial value:
=
"__sanitizer_cov_trace_const_cmp4"

Definition at line 57 of file SanitizerCoverage.cpp.

◆ SanCovTraceConstCmp8

const char* const SanCovTraceConstCmp8
static
Initial value:
=
"__sanitizer_cov_trace_const_cmp8"

Definition at line 59 of file SanitizerCoverage.cpp.

◆ SanCovTraceDiv4

const char* const SanCovTraceDiv4 = "__sanitizer_cov_trace_div4"
static

Definition at line 61 of file SanitizerCoverage.cpp.

◆ SanCovTraceDiv8

const char* const SanCovTraceDiv8 = "__sanitizer_cov_trace_div8"
static

Definition at line 62 of file SanitizerCoverage.cpp.

◆ SanCovTraceGep

const char* const SanCovTraceGep = "__sanitizer_cov_trace_gep"
static

Definition at line 63 of file SanitizerCoverage.cpp.

◆ SanCovTracePCGuardInitName

const char* const SanCovTracePCGuardInitName
static
Initial value:
=
"__sanitizer_cov_trace_pc_guard_init"

Definition at line 70 of file SanitizerCoverage.cpp.

◆ SanCovTracePCGuardName

const char* const SanCovTracePCGuardName
static
Initial value:
=
"__sanitizer_cov_trace_pc_guard"

Definition at line 68 of file SanitizerCoverage.cpp.

◆ SanCovTracePCIndirName

const char* const SanCovTracePCIndirName
static
Initial value:
=
"__sanitizer_cov_trace_pc_indir"

Definition at line 46 of file SanitizerCoverage.cpp.

◆ SanCovTracePCName

const char* const SanCovTracePCName = "__sanitizer_cov_trace_pc"
static

Definition at line 48 of file SanitizerCoverage.cpp.

◆ SanCovTraceSwitchName

const char* const SanCovTraceSwitchName = "__sanitizer_cov_trace_switch"
static

Definition at line 64 of file SanitizerCoverage.cpp.

◆ SanCtorAndDtorPriority

const uint64_t SanCtorAndDtorPriority = 2
static

Definition at line 66 of file SanitizerCoverage.cpp.