[llvm] 0d59969 - [msan] Enable msan-check-constant-shadow by default

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 26 16:35:01 PDT 2022


Author: Vitaly Buka
Date: 2022-08-26T16:34:47-07:00
New Revision: 0d59969abbd2245536c99b7f9218deab78df396b

URL: https://github.com/llvm/llvm-project/commit/0d59969abbd2245536c99b7f9218deab78df396b
DIFF: https://github.com/llvm/llvm-project/commit/0d59969abbd2245536c99b7f9218deab78df396b.diff

LOG: [msan] Enable msan-check-constant-shadow by default

Depends on D132761.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D132765

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
    llvm/test/Instrumentation/MemorySanitizer/check-constant-shadow.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 2459f5aa7194..5156a8a9c56e 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -321,13 +321,10 @@ static cl::opt<bool>
                     cl::desc("Apply no_sanitize to the whole file"), cl::Hidden,
                     cl::init(false));
 
-// This is an experiment to enable handling of cases where shadow is a non-zero
-// compile-time constant. For some unexplainable reason they were silently
-// ignored in the instrumentation.
 static cl::opt<bool>
     ClCheckConstantShadow("msan-check-constant-shadow",
                           cl::desc("Insert checks for constant shadow values"),
-                          cl::Hidden, cl::init(false));
+                          cl::Hidden, cl::init(true));
 
 // This is off by default because of a bug in gold:
 // https://sourceware.org/bugzilla/show_bug.cgi?id=19002
@@ -1779,9 +1776,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
   Value *getOrigin(Value *V) {
     if (!MS.TrackOrigins)
       return nullptr;
-    if (!PropagateShadow)
-      return getCleanOrigin();
-    if (isa<Constant>(V))
+    if (!PropagateShadow || isa<Constant>(V) || isa<InlineAsm>(V))
       return getCleanOrigin();
     assert((isa<Instruction>(V) || isa<Argument>(V)) &&
            "Unexpected value type in getOrigin()");

diff  --git a/llvm/test/Instrumentation/MemorySanitizer/check-constant-shadow.ll b/llvm/test/Instrumentation/MemorySanitizer/check-constant-shadow.ll
index 61be726de74c..d268fc41bf3d 100644
--- a/llvm/test/Instrumentation/MemorySanitizer/check-constant-shadow.ll
+++ b/llvm/test/Instrumentation/MemorySanitizer/check-constant-shadow.ll
@@ -1,5 +1,5 @@
-; RUN: opt < %s -msan-check-access-address=0 -msan-check-constant-shadow=1 -msan-eager-checks=1 -msan-track-origins=1 -S -passes=msan 2>&1 | FileCheck --check-prefixes=CHECK,CONST %s --implicit-check-not=icmp --implicit-check-not="store i" --implicit-check-not="call void @__msan"
-; RUN: opt < %s -msan-check-access-address=0                               -msan-eager-checks=1 -msan-track-origins=1 -S -passes=msan 2>&1 | FileCheck --check-prefixes=CHECK       %s --implicit-check-not=icmp --implicit-check-not="store i" --implicit-check-not="call void @__msan"
+; RUN: opt < %s -msan-check-access-address=0                               -msan-eager-checks=1 -msan-track-origins=1 -S -passes=msan 2>&1 | FileCheck --check-prefixes=CHECK,CONST %s --implicit-check-not=icmp --implicit-check-not="store i" --implicit-check-not="call void @__msan"
+; RUN: opt < %s -msan-check-access-address=0 -msan-check-constant-shadow=0 -msan-eager-checks=1 -msan-track-origins=1 -S -passes=msan 2>&1 | FileCheck --check-prefixes=CHECK       %s --implicit-check-not=icmp --implicit-check-not="store i" --implicit-check-not="call void @__msan"
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"


        


More information about the llvm-commits mailing list