diff options
author | Kostya Serebryany <kcc@google.com> | 2015-03-05 01:20:05 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2015-03-05 01:20:05 +0000 |
commit | 83ce8779d56debc38ce1943444b7f62f004c3e57 (patch) | |
tree | 8219af6d00f543200c424f9f5f9bae877f02a004 /llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | |
parent | af7e99f2f4be1c49a3827a18eb3529ff6ee3351a (diff) | |
download | llvm-83ce8779d56debc38ce1943444b7f62f004c3e57.zip llvm-83ce8779d56debc38ce1943444b7f62f004c3e57.tar.gz llvm-83ce8779d56debc38ce1943444b7f62f004c3e57.tar.bz2 |
[sanitizer] add nosanitize metadata to more coverage instrumentation instructions
llvm-svn: 231333
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index e7a0934..6000fd0 100644 --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -109,6 +109,7 @@ class SanitizerCoverageModule : public ModulePass { ArrayRef<Instruction *> IndirCalls); bool InjectCoverage(Function &F, ArrayRef<BasicBlock *> AllBlocks, ArrayRef<Instruction *> IndirCalls); + void SetNoSanitizeMetada(Instruction *I); void InjectCoverageAtBlock(Function &F, BasicBlock &BB, bool UseCalls); Function *SanCovFunction; Function *SanCovWithCheckFunction; @@ -306,6 +307,12 @@ void SanitizerCoverageModule::InjectCoverageForIndirectCalls( } } +void SanitizerCoverageModule::SetNoSanitizeMetada(Instruction *I) { + I->setMetadata( + I->getParent()->getParent()->getParent()->getMDKindID("nosanitize"), + MDNode::get(*C, None)); +} + void SanitizerCoverageModule::InjectCoverageAtBlock(Function &F, BasicBlock &BB, bool UseCalls) { BasicBlock::iterator IP = BB.getFirstInsertionPt(), BE = BB.end(); @@ -335,8 +342,7 @@ void SanitizerCoverageModule::InjectCoverageAtBlock(Function &F, BasicBlock &BB, LoadInst *Load = IRB.CreateLoad(GuardP); Load->setAtomic(Monotonic); Load->setAlignment(4); - Load->setMetadata(F.getParent()->getMDKindID("nosanitize"), - MDNode::get(*C, None)); + SetNoSanitizeMetada(Load); Value *Cmp = IRB.CreateICmpSGE(Constant::getNullValue(Load->getType()), Load); Instruction *Ins = SplitBlockAndInsertIfThen( Cmp, IP, false, MDBuilder(*C).createBranchWeights(1, 100000)); @@ -353,9 +359,11 @@ void SanitizerCoverageModule::InjectCoverageAtBlock(Function &F, BasicBlock &BB, IRB.CreatePointerCast(EightBitCounterArray, IntptrTy), ConstantInt::get(IntptrTy, SanCovFunction->getNumUses() - 1)); P = IRB.CreateIntToPtr(P, IRB.getInt8PtrTy()); - Value *LI = IRB.CreateLoad(P); + LoadInst *LI = IRB.CreateLoad(P); Value *Inc = IRB.CreateAdd(LI, ConstantInt::get(IRB.getInt8Ty(), 1)); - IRB.CreateStore(Inc, P); + StoreInst *SI = IRB.CreateStore(Inc, P); + SetNoSanitizeMetada(LI); + SetNoSanitizeMetada(SI); } if (ClExperimentalTracing) { |