summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2012-11-29 12:30:18 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2012-11-29 12:30:18 +0000
commit1d2da65bf86a9b0b9521fc09c10825b8b54f47a0 (patch)
tree1bc3dbc59a4d7cb75fbb3d71ae3f53eac7c161ee /llvm/lib
parentdde9dcc24b23e0b8185cf7ce5072c0dc8ff086c9 (diff)
downloadbcm5719-llvm-1d2da65bf86a9b0b9521fc09c10825b8b54f47a0.tar.gz
bcm5719-llvm-1d2da65bf86a9b0b9521fc09c10825b8b54f47a0.zip
[msan] Make sure that report callbacks do not get merged.
llvm-svn: 168873
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 57c50030850..bc9e709fd47 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -183,6 +183,8 @@ private:
MDNode *ColdCallWeights;
/// \brief The blacklist.
OwningPtr<BlackList> BL;
+ /// \brief An empty volatile inline asm that prevents callback merge.
+ InlineAsm *EmptyAsm;
friend class MemorySanitizerVisitor;
friend class VarArgAMD64Helper;
@@ -295,6 +297,11 @@ bool MemorySanitizer::doInitialization(Module &M) {
OriginTLS = new GlobalVariable(
M, IRB.getInt32Ty(), false, GlobalVariable::ExternalLinkage, 0,
"__msan_origin_tls", 0, GlobalVariable::GeneralDynamicTLSModel);
+
+ // We insert an empty inline asm after __msan_report* to avoid callback merge.
+ EmptyAsm = InlineAsm::get(FunctionType::get(IRB.getVoidTy(), false),
+ StringRef(""), StringRef(""),
+ /*hasSideEffects=*/true);
return true;
}
@@ -391,6 +398,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
}
CallInst *Call = IRB.CreateCall(MS.WarningFn);
Call->setDebugLoc(OrigIns->getDebugLoc());
+ IRB.CreateCall(MS.EmptyAsm);
DEBUG(dbgs() << " CHECK: " << *Cmp << "\n");
}
DEBUG(dbgs() << "DONE:\n" << F);
OpenPOWER on IntegriCloud