[llvm] 1d14034 - [NFC][msan] Add DebugInstrumentInstruction DEBUG_COUNTER

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 11:26:22 PDT 2024


Author: Vitaly Buka
Date: 2024-04-23T11:20:50-07:00
New Revision: 1d140348733d5454c2dc72b3f4f16404981f2102

URL: https://github.com/llvm/llvm-project/commit/1d140348733d5454c2dc72b3f4f16404981f2102
DIFF: https://github.com/llvm/llvm-project/commit/1d140348733d5454c2dc72b3f4f16404981f2102.diff

LOG: [NFC][msan] Add DebugInstrumentInstruction DEBUG_COUNTER

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 24c18cef2b0fef..824cbee4eca578 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -212,6 +212,9 @@ using namespace llvm;
 DEBUG_COUNTER(DebugInsertCheck, "msan-insert-check",
               "Controls which checks to insert");
 
+DEBUG_COUNTER(DebugInstrumentInstruction, "msan-instrument-instruction",
+              "Controls which instruction to instrument");
+
 static const unsigned kOriginSize = 4;
 static const Align kMinOriginAlignment = Align(4);
 static const Align kShadowTLSAlignment = Align(8);
@@ -2176,6 +2179,13 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
     // Don't want to visit if we're in the prologue
     if (isInPrologue(I))
       return;
+    if (!DebugCounter::shouldExecute(DebugInstrumentInstruction)) {
+      LLVM_DEBUG(dbgs() << "Skipping instruction: " << I << "\n");
+      // We still need to set the shadow and origin to clean values.
+      setShadow(&I, getCleanShadow(&I));
+      setOrigin(&I, getCleanOrigin());
+      return;
+    }
     InstVisitor<MemorySanitizerVisitor>::visit(I);
   }
 


        


More information about the llvm-commits mailing list