summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2015-12-02 02:37:13 +0000
committerKostya Serebryany <kcc@google.com>2015-12-02 02:37:13 +0000
commita3c5347764b2e43e44c8d1b1cfbe102e6e9f1d77 (patch)
tree64b815108f37f97aaa40c06fdc765284c6161be5 /llvm/lib/Transforms
parent5ce81794c3510ee4d56ef47549f18727c6e9b0bb (diff)
downloadbcm5719-llvm-a3c5347764b2e43e44c8d1b1cfbe102e6e9f1d77.tar.gz
bcm5719-llvm-a3c5347764b2e43e44c8d1b1cfbe102e6e9f1d77.zip
[sanitizer coverage] when adding a bb trace instrumentation, do it instead, not in addition to, regular coverage. Do the regular coverage in the run-time instead
llvm-svn: 254482
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
index 3430ee01035..719a436b05d 100644
--- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -156,7 +156,9 @@ class SanitizerCoverageModule : public ModulePass {
void SetNoSanitizeMetadata(Instruction *I);
void InjectCoverageAtBlock(Function &F, BasicBlock &BB, bool UseCalls);
unsigned NumberOfInstrumentedBlocks() {
- return SanCovFunction->getNumUses() + SanCovWithCheckFunction->getNumUses();
+ return SanCovFunction->getNumUses() +
+ SanCovWithCheckFunction->getNumUses() + SanCovTraceBB->getNumUses() +
+ SanCovTraceEnter->getNumUses();
}
Function *SanCovFunction;
Function *SanCovWithCheckFunction;
@@ -211,12 +213,10 @@ bool SanitizerCoverageModule::runOnModule(Module &M) {
StringRef(""), StringRef(""),
/*hasSideEffects=*/true);
- if (Options.TraceBB) {
- SanCovTraceEnter = checkSanitizerInterfaceFunction(
- M.getOrInsertFunction(kSanCovTraceEnter, VoidTy, Int32PtrTy, nullptr));
- SanCovTraceBB = checkSanitizerInterfaceFunction(
- M.getOrInsertFunction(kSanCovTraceBB, VoidTy, Int32PtrTy, nullptr));
- }
+ SanCovTraceEnter = checkSanitizerInterfaceFunction(
+ M.getOrInsertFunction(kSanCovTraceEnter, VoidTy, Int32PtrTy, nullptr));
+ SanCovTraceBB = checkSanitizerInterfaceFunction(
+ M.getOrInsertFunction(kSanCovTraceBB, VoidTy, Int32PtrTy, nullptr));
// At this point we create a dummy array of guards because we don't
// know how many elements we will need.
@@ -466,7 +466,9 @@ void SanitizerCoverageModule::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
ConstantInt::get(IntptrTy, (1 + NumberOfInstrumentedBlocks()) * 4));
Type *Int32PtrTy = PointerType::getUnqual(IRB.getInt32Ty());
GuardP = IRB.CreateIntToPtr(GuardP, Int32PtrTy);
- if (UseCalls) {
+ if (Options.TraceBB) {
+ IRB.CreateCall(IsEntryBB ? SanCovTraceEnter : SanCovTraceBB, GuardP);
+ } else if (UseCalls) {
IRB.CreateCall(SanCovWithCheckFunction, GuardP);
} else {
LoadInst *Load = IRB.CreateLoad(GuardP);
@@ -495,13 +497,6 @@ void SanitizerCoverageModule::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
SetNoSanitizeMetadata(LI);
SetNoSanitizeMetadata(SI);
}
-
- if (Options.TraceBB) {
- // Experimental support for tracing.
- // Insert a callback with the same guard variable as used for coverage.
- IRB.SetInsertPoint(&*IP);
- IRB.CreateCall(IsEntryBB ? SanCovTraceEnter : SanCovTraceBB, GuardP);
- }
}
char SanitizerCoverageModule::ID = 0;
OpenPOWER on IntegriCloud