[llvm-commits] [llvm] r173682 - [msan] Mostly disable msan-handle-icmp-exact.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Mon Jan 28 03:42:28 PST 2013


Author: eugenis
Date: Mon Jan 28 05:42:28 2013
New Revision: 173682

URL: http://llvm.org/viewvc/llvm-project?rev=173682&view=rev
Log:
[msan] Mostly disable msan-handle-icmp-exact.

It is way too slow. Change the default option value to 0.
Always do exact shadow propagation for unsigned ICmp with constants, it is
cheap (under 1% cpu time) and required for correctness.

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
    llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll

Modified: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp?rev=173682&r1=173681&r2=173682&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Mon Jan 28 05:42:28 2013
@@ -129,7 +129,7 @@ static cl::opt<bool> ClHandleICmp("msan-
 
 static cl::opt<bool> ClHandleICmpExact("msan-handle-icmp-exact",
        cl::desc("exact handling of relational integer ICmp"),
-       cl::Hidden, cl::init(true));
+       cl::Hidden, cl::init(false));
 
 static cl::opt<bool> ClStoreCleanOrigin("msan-store-clean-origin",
        cl::desc("store origin for clean (fully initialized) values"),
@@ -1255,14 +1255,32 @@ struct MemorySanitizerVisitor : public I
   }
 
   void visitICmpInst(ICmpInst &I) {
-    if (ClHandleICmp && I.isEquality())
+    if (!ClHandleICmp) {
+      handleShadowOr(I);
+      return;
+    }
+    if (I.isEquality()) {
       handleEqualityComparison(I);
-    else if (ClHandleICmp && ClHandleICmpExact && I.isRelational())
+      return;
+    }
+
+    assert(I.isRelational());
+    if (ClHandleICmpExact) {
       handleRelationalComparisonExact(I);
-    else if (ClHandleICmp && I.isSigned() && I.isRelational())
+      return;
+    }
+    if (I.isSigned()) {
       handleSignedRelationalComparison(I);
-    else
-      handleShadowOr(I);
+      return;
+    }
+
+    assert(I.isUnsigned());
+    if ((isa<Constant>(I.getOperand(0)) || isa<Constant>(I.getOperand(1)))) {
+      handleRelationalComparisonExact(I);
+      return;
+    }
+
+    handleShadowOr(I);
   }
 
   void visitFCmpInst(FCmpInst &I) {

Modified: llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll?rev=173682&r1=173681&r2=173682&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll (original)
+++ llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll Mon Jan 28 05:42:28 2013
@@ -323,8 +323,6 @@ define zeroext i1 @ICmpSLT(i32 %x) nounw
 ; CHECK-NOT: call void @__msan_warning
 ; CHECK: icmp slt
 ; CHECK-NOT: call void @__msan_warning
-; CHECK: icmp slt
-; CHECK-NOT: call void @__msan_warning
 ; CHECK: ret i1
 
 define zeroext i1 @ICmpSGE(i32 %x) nounwind uwtable readnone {
@@ -333,9 +331,7 @@ define zeroext i1 @ICmpSGE(i32 %x) nounw
 }
 
 ; CHECK: @ICmpSGE
-; CHECK: icmp sge
-; CHECK-NOT: call void @__msan_warning
-; CHECK: icmp sge
+; CHECK: icmp slt
 ; CHECK-NOT: call void @__msan_warning
 ; CHECK: icmp sge
 ; CHECK-NOT: call void @__msan_warning
@@ -347,9 +343,7 @@ define zeroext i1 @ICmpSGT(i32 %x) nounw
 }
 
 ; CHECK: @ICmpSGT
-; CHECK: icmp sgt
-; CHECK-NOT: call void @__msan_warning
-; CHECK: icmp sgt
+; CHECK: icmp slt
 ; CHECK-NOT: call void @__msan_warning
 ; CHECK: icmp sgt
 ; CHECK-NOT: call void @__msan_warning
@@ -361,9 +355,7 @@ define zeroext i1 @ICmpSLE(i32 %x) nounw
 }
 
 ; CHECK: @ICmpSLE
-; CHECK: icmp sle
-; CHECK-NOT: call void @__msan_warning
-; CHECK: icmp sle
+; CHECK: icmp slt
 ; CHECK-NOT: call void @__msan_warning
 ; CHECK: icmp sle
 ; CHECK-NOT: call void @__msan_warning
@@ -381,27 +373,26 @@ define <2 x i1> @ICmpSLT_vector(<2 x i32
 ; CHECK: @ICmpSLT_vector
 ; CHECK: icmp slt <2 x i64>
 ; CHECK-NOT: call void @__msan_warning
-; CHECK: icmp slt <2 x i64>
-; CHECK-NOT: call void @__msan_warning
 ; CHECK: icmp slt <2 x i32*>
 ; CHECK-NOT: call void @__msan_warning
 ; CHECK: ret <2 x i1>
 
 
-; Check that we propagate shadow for arbitrary relational comparisons
+; Check that we propagate shadow for unsigned relational comparisons with
+; constants
 
-define zeroext i1 @ICmpSLENonZero(i32 %x, i32 %y) nounwind uwtable readnone {
+define zeroext i1 @ICmpUGTConst(i32 %x) nounwind uwtable readnone {
 entry:
-  %cmp = icmp sle i32 %x, %y
+  %cmp = icmp ugt i32 %x, 7
   ret i1 %cmp
 }
 
-; CHECK: @ICmpSLENonZero
-; CHECK: icmp sle i32
+; CHECK: @ICmpUGTConst
+; CHECK: icmp ugt i32
 ; CHECK-NOT: call void @__msan_warning
-; CHECK: icmp sle i32
+; CHECK: icmp ugt i32
 ; CHECK-NOT: call void @__msan_warning
-; CHECK: icmp sle i32
+; CHECK: icmp ugt i32
 ; CHECK-NOT: call void @__msan_warning
 ; CHECK: ret i1
 





More information about the llvm-commits mailing list