[PATCH] D26352: Use -fsanitize-recover instead of -mllvm -msan-keep-going.
Aleksey Shlyapnikov via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 7 09:27:50 PST 2016
alekseyshl created this revision.
alekseyshl added a reviewer: eugenis.
alekseyshl added a subscriber: llvm-commits.
Use -fsanitize-recover instead of -mllvm -msan-keep-going.
https://reviews.llvm.org/D26352
Files:
include/llvm/Transforms/Instrumentation.h
lib/Transforms/Instrumentation/MemorySanitizer.cpp
Index: lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -312,9 +312,10 @@
/// uninitialized reads.
class MemorySanitizer : public FunctionPass {
public:
- MemorySanitizer(int TrackOrigins = 0)
+ MemorySanitizer(int TrackOrigins = 0, bool Recover = false)
: FunctionPass(ID),
TrackOrigins(std::max(TrackOrigins, (int)ClTrackOrigins)),
+ Recover(Recover || ClKeepGoing),
WarningFn(nullptr) {}
StringRef getPassName() const override { return "MemorySanitizer"; }
void getAnalysisUsage(AnalysisUsage &AU) const override {
@@ -329,6 +330,7 @@
/// \brief Track origins (allocation points) of uninitialized values.
int TrackOrigins;
+ bool Recover;
LLVMContext *C;
Type *IntptrTy;
@@ -395,8 +397,8 @@
MemorySanitizer, "msan",
"MemorySanitizer: detects uninitialized reads.", false, false)
-FunctionPass *llvm::createMemorySanitizerPass(int TrackOrigins) {
- return new MemorySanitizer(TrackOrigins);
+FunctionPass *llvm::createMemorySanitizerPass(int TrackOrigins, bool Recover) {
+ return new MemorySanitizer(TrackOrigins, Recover);
}
/// \brief Create a non-const global initialized with the given string.
@@ -421,8 +423,8 @@
// Create the callback.
// FIXME: this function should have "Cold" calling conv,
// which is not yet implemented.
- StringRef WarningFnName = ClKeepGoing ? "__msan_warning"
- : "__msan_warning_noreturn";
+ StringRef WarningFnName = Recover ? "__msan_warning"
+ : "__msan_warning_noreturn";
WarningFn = M.getOrInsertFunction(WarningFnName, IRB.getVoidTy(), nullptr);
for (size_t AccessSizeIndex = 0; AccessSizeIndex < kNumberOfAccessSizes;
@@ -566,9 +568,9 @@
new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
IRB.getInt32(TrackOrigins), "__msan_track_origins");
- if (ClKeepGoing)
+ if (Recover)
new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
- IRB.getInt32(ClKeepGoing), "__msan_keep_going");
+ IRB.getInt32(Recover), "__msan_keep_going");
return true;
}
@@ -792,7 +794,7 @@
}
IRB.CreateCall(MS.WarningFn, {});
IRB.CreateCall(MS.EmptyAsm, {});
- // FIXME: Insert UnreachableInst if !ClKeepGoing?
+ // FIXME: Insert UnreachableInst if !MS.Recover?
// This may invalidate some of the following checks and needs to be done
// at the very end.
}
@@ -815,7 +817,7 @@
getCleanShadow(ConvertedShadow), "_mscmp");
Instruction *CheckTerm = SplitBlockAndInsertIfThen(
Cmp, OrigIns,
- /* Unreachable */ !ClKeepGoing, MS.ColdCallWeights);
+ /* Unreachable */ !MS.Recover, MS.ColdCallWeights);
IRB.SetInsertPoint(CheckTerm);
if (MS.TrackOrigins) {
Index: include/llvm/Transforms/Instrumentation.h
===================================================================
--- include/llvm/Transforms/Instrumentation.h
+++ include/llvm/Transforms/Instrumentation.h
@@ -108,7 +108,8 @@
bool Recover = false);
// Insert MemorySanitizer instrumentation (detection of uninitialized reads)
-FunctionPass *createMemorySanitizerPass(int TrackOrigins = 0);
+FunctionPass *createMemorySanitizerPass(int TrackOrigins = 0,
+ bool Recover = false);
// Insert ThreadSanitizer (race detection) instrumentation
FunctionPass *createThreadSanitizerPass();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26352.77047.patch
Type: text/x-patch
Size: 3783 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161107/3302f928/attachment.bin>
More information about the llvm-commits
mailing list