LLVM  13.0.0git
Macros | Functions | Variables
SanitizerCoverage.cpp File Reference
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
#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/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/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/SpecialCaseList.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Instrumentation.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)
 
static bool IsBackEdge (BasicBlock *From, BasicBlock *To, const DominatorTree *DT)
 
static bool IsInterestingCmp (ICmpInst *CMP, const DominatorTree *DT, const SanitizerCoverageOptions &Options)
 
 INITIALIZE_PASS_BEGIN (ModuleSanitizerCoverageLegacyPass, "sancov", "Pass for instrumenting coverage on functions", false, false) INITIALIZE_PASS_END(ModuleSanitizerCoverageLegacyPass
 

Variables

const char SanCovTracePCIndirName [] = "__sanitizer_cov_trace_pc_indir"
 
const char SanCovTracePCName [] = "__sanitizer_cov_trace_pc"
 
const char SanCovTraceCmp1 [] = "__sanitizer_cov_trace_cmp1"
 
const char SanCovTraceCmp2 [] = "__sanitizer_cov_trace_cmp2"
 
const char SanCovTraceCmp4 [] = "__sanitizer_cov_trace_cmp4"
 
const char SanCovTraceCmp8 [] = "__sanitizer_cov_trace_cmp8"
 
const char SanCovTraceConstCmp1 [] = "__sanitizer_cov_trace_const_cmp1"
 
const char SanCovTraceConstCmp2 [] = "__sanitizer_cov_trace_const_cmp2"
 
const char SanCovTraceConstCmp4 [] = "__sanitizer_cov_trace_const_cmp4"
 
const char SanCovTraceConstCmp8 [] = "__sanitizer_cov_trace_const_cmp8"
 
const char SanCovTraceDiv4 [] = "__sanitizer_cov_trace_div4"
 
const char SanCovTraceDiv8 [] = "__sanitizer_cov_trace_div8"
 
const char SanCovTraceGep [] = "__sanitizer_cov_trace_gep"
 
const char SanCovTraceSwitchName [] = "__sanitizer_cov_trace_switch"
 
const char SanCovModuleCtorTracePcGuardName []
 
const char SanCovModuleCtor8bitCountersName []
 
const char SanCovModuleCtorBoolFlagName [] = "sancov.module_ctor_bool_flag"
 
static const uint64_t SanCtorAndDtorPriority = 2
 
const char SanCovTracePCGuardName [] = "__sanitizer_cov_trace_pc_guard"
 
const char SanCovTracePCGuardInitName [] = "__sanitizer_cov_trace_pc_guard_init"
 
const char SanCov8bitCountersInitName [] = "__sanitizer_cov_8bit_counters_init"
 
const char SanCovBoolFlagInitName [] = "__sanitizer_cov_bool_flag_init"
 
const char SanCovPCsInitName [] = "__sanitizer_cov_pcs_init"
 
const char SanCovGuardsSectionName [] = "sancov_guards"
 
const char SanCovCountersSectionName [] = "sancov_cntrs"
 
const char SanCovBoolFlagSectionName [] = "sancov_bools"
 
const char SanCovPCsSectionName [] = "sancov_pcs"
 
const char SanCovLowestStackName [] = "__sancov_lowest_stack"
 
static cl::opt< intClCoverageLevel ("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< bool > ClTracePC ("sanitizer-coverage-trace-pc", cl::desc("Experimental pc tracing"), cl::Hidden, cl::init(false))
 
static cl::opt< bool > ClTracePCGuard ("sanitizer-coverage-trace-pc-guard", cl::desc("pc tracing with a guard"), cl::Hidden, cl::init(false))
 
static cl::opt< bool > ClCreatePCTable ("sanitizer-coverage-pc-table", cl::desc("create a static PC table"), cl::Hidden, cl::init(false))
 
static cl::opt< bool > ClInline8bitCounters ("sanitizer-coverage-inline-8bit-counters", cl::desc("increments 8-bit counter for every edge"), cl::Hidden, cl::init(false))
 
static cl::opt< bool > ClInlineBoolFlag ("sanitizer-coverage-inline-bool-flag", cl::desc("sets a boolean flag for every edge"), cl::Hidden, cl::init(false))
 
static cl::opt< bool > ClCMPTracing ("sanitizer-coverage-trace-compares", cl::desc("Tracing of CMP and similar instructions"), cl::Hidden, cl::init(false))
 
static cl::opt< bool > ClDIVTracing ("sanitizer-coverage-trace-divs", cl::desc("Tracing of DIV instructions"), cl::Hidden, cl::init(false))
 
static cl::opt< bool > ClGEPTracing ("sanitizer-coverage-trace-geps", cl::desc("Tracing of GEP instructions"), cl::Hidden, cl::init(false))
 
static cl::opt< bool > ClPruneBlocks ("sanitizer-coverage-prune-blocks", cl::desc("Reduce the number of instrumented blocks"), cl::Hidden, cl::init(true))
 
static cl::opt< bool > ClStackDepth ("sanitizer-coverage-stack-depth", cl::desc("max stack depth tracing"), cl::Hidden, cl::init(false))
 
 sancov
 
Pass for instrumenting coverage on functions
 
Pass for instrumenting coverage on false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "sancov"

Definition at line 46 of file SanitizerCoverage.cpp.

Function Documentation

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( ModuleSanitizerCoverageLegacyPass  ,
"sancov"  ,
"Pass for instrumenting coverage on functions ,
false  ,
false   
)

◆ IsBackEdge()

static bool IsBackEdge ( BasicBlock From,
BasicBlock To,
const DominatorTree DT 
)
static

◆ isFullDominator()

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

◆ isFullPostDominator()

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

◆ IsInterestingCmp()

static bool IsInterestingCmp ( ICmpInst CMP,
const DominatorTree DT,
const SanitizerCoverageOptions Options 
)
static

◆ shouldInstrumentBlock()

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

Variable Documentation

◆ 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

◆ ClInlineBoolFlag

cl::opt<bool> ClInlineBoolFlag("sanitizer-coverage-inline-bool-flag", cl::desc("sets a boolean flag 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

Pass for instrumenting coverage on false

Definition at line 1003 of file SanitizerCoverage.cpp.

◆ functions

Pass for instrumenting coverage on functions

Definition at line 1003 of file SanitizerCoverage.cpp.

◆ sancov

sancov

Definition at line 1002 of file SanitizerCoverage.cpp.

◆ SanCov8bitCountersInitName

const char SanCov8bitCountersInitName[] = "__sanitizer_cov_8bit_counters_init"

Definition at line 71 of file SanitizerCoverage.cpp.

◆ SanCovBoolFlagInitName

const char SanCovBoolFlagInitName[] = "__sanitizer_cov_bool_flag_init"

Definition at line 72 of file SanitizerCoverage.cpp.

◆ SanCovBoolFlagSectionName

const char SanCovBoolFlagSectionName[] = "sancov_bools"

Definition at line 77 of file SanitizerCoverage.cpp.

◆ SanCovCountersSectionName

const char SanCovCountersSectionName[] = "sancov_cntrs"

Definition at line 76 of file SanitizerCoverage.cpp.

◆ SanCovGuardsSectionName

const char SanCovGuardsSectionName[] = "sancov_guards"

Definition at line 75 of file SanitizerCoverage.cpp.

◆ SanCovLowestStackName

const char SanCovLowestStackName[] = "__sancov_lowest_stack"

Definition at line 80 of file SanitizerCoverage.cpp.

◆ SanCovModuleCtor8bitCountersName

const char SanCovModuleCtor8bitCountersName[]
Initial value:
=
"sancov.module_ctor_8bit_counters"

Definition at line 64 of file SanitizerCoverage.cpp.

◆ SanCovModuleCtorBoolFlagName

const char SanCovModuleCtorBoolFlagName[] = "sancov.module_ctor_bool_flag"

Definition at line 66 of file SanitizerCoverage.cpp.

◆ SanCovModuleCtorTracePcGuardName

const char SanCovModuleCtorTracePcGuardName[]
Initial value:
=
"sancov.module_ctor_trace_pc_guard"

Definition at line 62 of file SanitizerCoverage.cpp.

◆ SanCovPCsInitName

const char SanCovPCsInitName[] = "__sanitizer_cov_pcs_init"

Definition at line 73 of file SanitizerCoverage.cpp.

◆ SanCovPCsSectionName

const char SanCovPCsSectionName[] = "sancov_pcs"

Definition at line 78 of file SanitizerCoverage.cpp.

◆ SanCovTraceCmp1

const char SanCovTraceCmp1[] = "__sanitizer_cov_trace_cmp1"

Definition at line 50 of file SanitizerCoverage.cpp.

◆ SanCovTraceCmp2

const char SanCovTraceCmp2[] = "__sanitizer_cov_trace_cmp2"

Definition at line 51 of file SanitizerCoverage.cpp.

◆ SanCovTraceCmp4

const char SanCovTraceCmp4[] = "__sanitizer_cov_trace_cmp4"

Definition at line 52 of file SanitizerCoverage.cpp.

◆ SanCovTraceCmp8

const char SanCovTraceCmp8[] = "__sanitizer_cov_trace_cmp8"

Definition at line 53 of file SanitizerCoverage.cpp.

◆ SanCovTraceConstCmp1

const char SanCovTraceConstCmp1[] = "__sanitizer_cov_trace_const_cmp1"

Definition at line 54 of file SanitizerCoverage.cpp.

◆ SanCovTraceConstCmp2

const char SanCovTraceConstCmp2[] = "__sanitizer_cov_trace_const_cmp2"

Definition at line 55 of file SanitizerCoverage.cpp.

◆ SanCovTraceConstCmp4

const char SanCovTraceConstCmp4[] = "__sanitizer_cov_trace_const_cmp4"

Definition at line 56 of file SanitizerCoverage.cpp.

◆ SanCovTraceConstCmp8

const char SanCovTraceConstCmp8[] = "__sanitizer_cov_trace_const_cmp8"

Definition at line 57 of file SanitizerCoverage.cpp.

◆ SanCovTraceDiv4

const char SanCovTraceDiv4[] = "__sanitizer_cov_trace_div4"

Definition at line 58 of file SanitizerCoverage.cpp.

◆ SanCovTraceDiv8

const char SanCovTraceDiv8[] = "__sanitizer_cov_trace_div8"

Definition at line 59 of file SanitizerCoverage.cpp.

◆ SanCovTraceGep

const char SanCovTraceGep[] = "__sanitizer_cov_trace_gep"

Definition at line 60 of file SanitizerCoverage.cpp.

◆ SanCovTracePCGuardInitName

const char SanCovTracePCGuardInitName[] = "__sanitizer_cov_trace_pc_guard_init"

Definition at line 70 of file SanitizerCoverage.cpp.

◆ SanCovTracePCGuardName

const char SanCovTracePCGuardName[] = "__sanitizer_cov_trace_pc_guard"

Definition at line 69 of file SanitizerCoverage.cpp.

◆ SanCovTracePCIndirName

const char SanCovTracePCIndirName[] = "__sanitizer_cov_trace_pc_indir"

Definition at line 48 of file SanitizerCoverage.cpp.

◆ SanCovTracePCName

const char SanCovTracePCName[] = "__sanitizer_cov_trace_pc"

Definition at line 49 of file SanitizerCoverage.cpp.

◆ SanCovTraceSwitchName

const char SanCovTraceSwitchName[] = "__sanitizer_cov_trace_switch"

Definition at line 61 of file SanitizerCoverage.cpp.

◆ SanCtorAndDtorPriority

const uint64_t SanCtorAndDtorPriority = 2
static

Definition at line 67 of file SanitizerCoverage.cpp.