[msan] Add msan-insert-check DEBUG_COUNTER

This commit is contained in:
Vitaly Buka 2022-09-15 21:49:57 -07:00
parent 45b85aebdb
commit f0c2ffa8f8
1 changed files with 10 additions and 0 deletions

View File

@ -186,6 +186,7 @@
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DebugCounter.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
@ -204,6 +205,9 @@ using namespace llvm;
#define DEBUG_TYPE "msan"
DEBUG_COUNTER(DebugInsertCheck, "msan-insert-check",
"Controls which checks to insert");
static const unsigned kOriginSize = 4;
static const Align kMinOriginAlignment = Align(4);
static const Align kShadowTLSAlignment = Align(8);
@ -1999,6 +2003,12 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
assert(Shadow);
if (!InsertChecks)
return;
if (!DebugCounter::shouldExecute(DebugInsertCheck)) {
LLVM_DEBUG(dbgs() << "Skipping check of " << *Shadow << " before "
<< *OrigIns << "\n");
return;
}
#ifndef NDEBUG
Type *ShadowTy = Shadow->getType();
assert((isa<IntegerType>(ShadowTy) || isa<VectorType>(ShadowTy) ||