summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2014-12-03 23:28:26 +0000
committerKostya Serebryany <kcc@google.com>2014-12-03 23:28:26 +0000
commit543f3db572d0a920faeae784987ad3d57f4bfa07 (patch)
treeaed7f74e6560818bceb9adf5bdd90d7b7ff17872 /llvm/lib
parentbed8da2e3b6505375155e6ae9568d912cdb223d1 (diff)
downloadbcm5719-llvm-543f3db572d0a920faeae784987ad3d57f4bfa07.tar.gz
bcm5719-llvm-543f3db572d0a920faeae784987ad3d57f4bfa07.zip
[msan] allow -fsanitize-coverage=N together with -fsanitize=memory, llvm part
llvm-svn: 223312
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp5
2 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index d97332621e6..35f9fd7cce3 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -1036,7 +1036,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
IRBuilder<> IRB(I.getNextNode());
Type *ShadowTy = getShadowTy(&I);
Value *Addr = I.getPointerOperand();
- if (PropagateShadow) {
+ if (PropagateShadow && !I.getMetadata("nosanitize")) {
Value *ShadowPtr = getShadowPtr(Addr, ShadowTy, IRB);
setShadow(&I,
IRB.CreateAlignedLoad(ShadowPtr, I.getAlignment(), "_msld"));
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
index 60d7f9f69d7..34f5ae96b13 100644
--- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -166,7 +166,8 @@ bool SanitizerCoverageModule::runOnModule(Module &M) {
bool SanitizerCoverageModule::runOnFunction(Function &F) {
if (F.empty()) return false;
// For now instrument only functions that will also be asan-instrumented.
- if (!F.hasFnAttribute(Attribute::SanitizeAddress))
+ if (!F.hasFnAttribute(Attribute::SanitizeAddress) &&
+ !F.hasFnAttribute(Attribute::SanitizeMemory))
return false;
if (CoverageLevel >= 3)
SplitAllCriticalEdges(F, this);
@@ -273,6 +274,8 @@ void SanitizerCoverageModule::InjectCoverageAtBlock(Function &F,
LoadInst *Load = IRB.CreateLoad(Guard);
Load->setAtomic(Monotonic);
Load->setAlignment(1);
+ Load->setMetadata(F.getParent()->getMDKindID("nosanitize"),
+ MDNode::get(*C, ArrayRef<llvm::Value *>()));
Value *Cmp = IRB.CreateICmpEQ(Constant::getNullValue(Int8Ty), Load);
Instruction *Ins = SplitBlockAndInsertIfThen(
Cmp, IP, false, MDBuilder(*C).createBranchWeights(1, 100000));
OpenPOWER on IntegriCloud