[llvm] r254482 - [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
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 1 18:37:14 PST 2015
Author: kcc
Date: Tue Dec 1 20:37:13 2015
New Revision: 254482
URL: http://llvm.org/viewvc/llvm-project?rev=254482&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=254482&r1=254481&r2=254482&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Tue Dec 1 20:37:13 2015
@@ -156,7 +156,9 @@ class SanitizerCoverageModule : public M
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::runOnModul
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::InjectCove
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::InjectCove
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;
More information about the llvm-commits
mailing list