Skip to content

[msan] Switch to -msan-handle-icmp-exact my default #113200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

vitalybuka
Copy link
Collaborator

Fixes #111212.

This grows .text by 5.3% on CTMark, (or 2.6% large internal binary)
Perf regressed by 1.6%. We will try to improve in follow up patches.

It worth to pay some performance regression to fix
correctness to avoid stuff like #111212.

@llvmbot
Copy link
Member

llvmbot commented Oct 21, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

@llvm/pr-subscribers-llvm-transforms

Author: Vitaly Buka (vitalybuka)

Changes

Fixes #111212.

This grows .text by 5.3% on CTMark, (or 2.6% large internal binary)
Perf regressed by 1.6%. We will try to improve in follow up patches.

It worth to pay some performance regression to fix
correctness to avoid stuff like #111212.


Patch is 49.51 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/113200.diff

3 Files Affected:

  • (modified) llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp (+1-1)
  • (modified) llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll (+485-40)
  • (modified) llvm/test/Instrumentation/MemorySanitizer/pr32842.ll (+27-2)
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 9e174e2415e719..440413b8c2684f 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -276,7 +276,7 @@ static cl::opt<bool>
 static cl::opt<bool>
     ClHandleICmpExact("msan-handle-icmp-exact",
                       cl::desc("exact handling of relational integer ICmp"),
-                      cl::Hidden, cl::init(false));
+                      cl::Hidden, cl::init(true));
 
 static cl::opt<bool> ClHandleLifetimeIntrinsics(
     "msan-handle-lifetime-intrinsics",
diff --git a/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll b/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
index 809e20dcb4a919..7aeb763b309048 100644
--- a/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
+++ b/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
@@ -1622,7 +1622,21 @@ define zeroext i1 @ICmpSLTZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; CHECK-SAME: i32 [[X:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; CHECK-NEXT:    call void @llvm.donothing()
-; CHECK-NEXT:    [[TMP16:%.*]] = icmp slt i32 [[TMP1]], 0
+; CHECK-NEXT:    [[TMP2:%.*]] = shl i32 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP3:%.*]] = lshr i32 [[TMP2]], 1
+; CHECK-NEXT:    [[TMP4:%.*]] = xor i32 [[TMP1]], [[TMP3]]
+; CHECK-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP3]], -1
+; CHECK-NEXT:    [[TMP6:%.*]] = and i32 [[X]], [[TMP5]]
+; CHECK-NEXT:    [[TMP7:%.*]] = or i32 [[TMP6]], [[TMP4]]
+; CHECK-NEXT:    [[TMP8:%.*]] = icmp slt i32 [[TMP7]], 0
+; CHECK-NEXT:    [[TMP9:%.*]] = shl i32 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP10:%.*]] = lshr i32 [[TMP9]], 1
+; CHECK-NEXT:    [[TMP11:%.*]] = xor i32 [[TMP1]], [[TMP10]]
+; CHECK-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP11]], -1
+; CHECK-NEXT:    [[TMP13:%.*]] = and i32 [[X]], [[TMP12]]
+; CHECK-NEXT:    [[TMP14:%.*]] = or i32 [[TMP13]], [[TMP10]]
+; CHECK-NEXT:    [[TMP15:%.*]] = icmp slt i32 [[TMP14]], 0
+; CHECK-NEXT:    [[TMP16:%.*]] = xor i1 [[TMP8]], [[TMP15]]
 ; CHECK-NEXT:    [[TMP17:%.*]] = icmp slt i32 [[X]], 0
 ; CHECK-NEXT:    store i1 [[TMP16]], ptr @__msan_retval_tls, align 8
 ; CHECK-NEXT:    ret i1 [[TMP17]]
@@ -1632,7 +1646,21 @@ define zeroext i1 @ICmpSLTZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; ORIGIN-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; ORIGIN-NEXT:    [[TMP2:%.*]] = load i32, ptr @__msan_param_origin_tls, align 4
 ; ORIGIN-NEXT:    call void @llvm.donothing()
-; ORIGIN-NEXT:    [[TMP17:%.*]] = icmp slt i32 [[TMP1]], 0
+; ORIGIN-NEXT:    [[TMP3:%.*]] = shl i32 [[TMP1]], 1
+; ORIGIN-NEXT:    [[TMP4:%.*]] = lshr i32 [[TMP3]], 1
+; ORIGIN-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP1]], [[TMP4]]
+; ORIGIN-NEXT:    [[TMP6:%.*]] = xor i32 [[TMP4]], -1
+; ORIGIN-NEXT:    [[TMP7:%.*]] = and i32 [[X]], [[TMP6]]
+; ORIGIN-NEXT:    [[TMP8:%.*]] = or i32 [[TMP7]], [[TMP5]]
+; ORIGIN-NEXT:    [[TMP9:%.*]] = icmp slt i32 [[TMP8]], 0
+; ORIGIN-NEXT:    [[TMP10:%.*]] = shl i32 [[TMP1]], 1
+; ORIGIN-NEXT:    [[TMP11:%.*]] = lshr i32 [[TMP10]], 1
+; ORIGIN-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP1]], [[TMP11]]
+; ORIGIN-NEXT:    [[TMP13:%.*]] = xor i32 [[TMP12]], -1
+; ORIGIN-NEXT:    [[TMP14:%.*]] = and i32 [[X]], [[TMP13]]
+; ORIGIN-NEXT:    [[TMP15:%.*]] = or i32 [[TMP14]], [[TMP11]]
+; ORIGIN-NEXT:    [[TMP16:%.*]] = icmp slt i32 [[TMP15]], 0
+; ORIGIN-NEXT:    [[TMP17:%.*]] = xor i1 [[TMP9]], [[TMP16]]
 ; ORIGIN-NEXT:    [[TMP18:%.*]] = icmp slt i32 [[X]], 0
 ; ORIGIN-NEXT:    store i1 [[TMP17]], ptr @__msan_retval_tls, align 8
 ; ORIGIN-NEXT:    store i32 [[TMP2]], ptr @__msan_retval_origin_tls, align 4
@@ -1643,7 +1671,21 @@ define zeroext i1 @ICmpSLTZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; CALLS-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; CALLS-NEXT:    [[TMP2:%.*]] = load i32, ptr @__msan_param_origin_tls, align 4
 ; CALLS-NEXT:    call void @llvm.donothing()
-; CALLS-NEXT:    [[TMP17:%.*]] = icmp slt i32 [[TMP1]], 0
+; CALLS-NEXT:    [[TMP3:%.*]] = shl i32 [[TMP1]], 1
+; CALLS-NEXT:    [[TMP4:%.*]] = lshr i32 [[TMP3]], 1
+; CALLS-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP1]], [[TMP4]]
+; CALLS-NEXT:    [[TMP6:%.*]] = xor i32 [[TMP4]], -1
+; CALLS-NEXT:    [[TMP7:%.*]] = and i32 [[X]], [[TMP6]]
+; CALLS-NEXT:    [[TMP8:%.*]] = or i32 [[TMP7]], [[TMP5]]
+; CALLS-NEXT:    [[TMP9:%.*]] = icmp slt i32 [[TMP8]], 0
+; CALLS-NEXT:    [[TMP10:%.*]] = shl i32 [[TMP1]], 1
+; CALLS-NEXT:    [[TMP11:%.*]] = lshr i32 [[TMP10]], 1
+; CALLS-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP1]], [[TMP11]]
+; CALLS-NEXT:    [[TMP13:%.*]] = xor i32 [[TMP12]], -1
+; CALLS-NEXT:    [[TMP14:%.*]] = and i32 [[X]], [[TMP13]]
+; CALLS-NEXT:    [[TMP15:%.*]] = or i32 [[TMP14]], [[TMP11]]
+; CALLS-NEXT:    [[TMP16:%.*]] = icmp slt i32 [[TMP15]], 0
+; CALLS-NEXT:    [[TMP17:%.*]] = xor i1 [[TMP9]], [[TMP16]]
 ; CALLS-NEXT:    [[TMP18:%.*]] = icmp slt i32 [[X]], 0
 ; CALLS-NEXT:    store i1 [[TMP17]], ptr @__msan_retval_tls, align 8
 ; CALLS-NEXT:    store i32 [[TMP2]], ptr @__msan_retval_origin_tls, align 4
@@ -1659,7 +1701,21 @@ define zeroext i1 @ICmpSGEZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; CHECK-SAME: i32 [[X:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; CHECK-NEXT:    call void @llvm.donothing()
-; CHECK-NEXT:    [[TMP16:%.*]] = icmp slt i32 [[TMP1]], 0
+; CHECK-NEXT:    [[TMP2:%.*]] = shl i32 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP3:%.*]] = lshr i32 [[TMP2]], 1
+; CHECK-NEXT:    [[TMP4:%.*]] = xor i32 [[TMP1]], [[TMP3]]
+; CHECK-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP3]], -1
+; CHECK-NEXT:    [[TMP6:%.*]] = and i32 [[X]], [[TMP5]]
+; CHECK-NEXT:    [[TMP7:%.*]] = or i32 [[TMP6]], [[TMP4]]
+; CHECK-NEXT:    [[TMP8:%.*]] = icmp sge i32 [[TMP7]], 0
+; CHECK-NEXT:    [[TMP9:%.*]] = shl i32 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP10:%.*]] = lshr i32 [[TMP9]], 1
+; CHECK-NEXT:    [[TMP11:%.*]] = xor i32 [[TMP1]], [[TMP10]]
+; CHECK-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP11]], -1
+; CHECK-NEXT:    [[TMP13:%.*]] = and i32 [[X]], [[TMP12]]
+; CHECK-NEXT:    [[TMP14:%.*]] = or i32 [[TMP13]], [[TMP10]]
+; CHECK-NEXT:    [[TMP15:%.*]] = icmp sge i32 [[TMP14]], 0
+; CHECK-NEXT:    [[TMP16:%.*]] = xor i1 [[TMP8]], [[TMP15]]
 ; CHECK-NEXT:    [[TMP17:%.*]] = icmp sge i32 [[X]], 0
 ; CHECK-NEXT:    store i1 [[TMP16]], ptr @__msan_retval_tls, align 8
 ; CHECK-NEXT:    ret i1 [[TMP17]]
@@ -1669,7 +1725,21 @@ define zeroext i1 @ICmpSGEZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; ORIGIN-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; ORIGIN-NEXT:    [[TMP2:%.*]] = load i32, ptr @__msan_param_origin_tls, align 4
 ; ORIGIN-NEXT:    call void @llvm.donothing()
-; ORIGIN-NEXT:    [[TMP17:%.*]] = icmp slt i32 [[TMP1]], 0
+; ORIGIN-NEXT:    [[TMP3:%.*]] = shl i32 [[TMP1]], 1
+; ORIGIN-NEXT:    [[TMP4:%.*]] = lshr i32 [[TMP3]], 1
+; ORIGIN-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP1]], [[TMP4]]
+; ORIGIN-NEXT:    [[TMP6:%.*]] = xor i32 [[TMP4]], -1
+; ORIGIN-NEXT:    [[TMP7:%.*]] = and i32 [[X]], [[TMP6]]
+; ORIGIN-NEXT:    [[TMP8:%.*]] = or i32 [[TMP7]], [[TMP5]]
+; ORIGIN-NEXT:    [[TMP9:%.*]] = icmp sge i32 [[TMP8]], 0
+; ORIGIN-NEXT:    [[TMP10:%.*]] = shl i32 [[TMP1]], 1
+; ORIGIN-NEXT:    [[TMP11:%.*]] = lshr i32 [[TMP10]], 1
+; ORIGIN-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP1]], [[TMP11]]
+; ORIGIN-NEXT:    [[TMP13:%.*]] = xor i32 [[TMP12]], -1
+; ORIGIN-NEXT:    [[TMP14:%.*]] = and i32 [[X]], [[TMP13]]
+; ORIGIN-NEXT:    [[TMP15:%.*]] = or i32 [[TMP14]], [[TMP11]]
+; ORIGIN-NEXT:    [[TMP16:%.*]] = icmp sge i32 [[TMP15]], 0
+; ORIGIN-NEXT:    [[TMP17:%.*]] = xor i1 [[TMP9]], [[TMP16]]
 ; ORIGIN-NEXT:    [[TMP18:%.*]] = icmp sge i32 [[X]], 0
 ; ORIGIN-NEXT:    store i1 [[TMP17]], ptr @__msan_retval_tls, align 8
 ; ORIGIN-NEXT:    store i32 [[TMP2]], ptr @__msan_retval_origin_tls, align 4
@@ -1680,7 +1750,21 @@ define zeroext i1 @ICmpSGEZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; CALLS-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; CALLS-NEXT:    [[TMP2:%.*]] = load i32, ptr @__msan_param_origin_tls, align 4
 ; CALLS-NEXT:    call void @llvm.donothing()
-; CALLS-NEXT:    [[TMP17:%.*]] = icmp slt i32 [[TMP1]], 0
+; CALLS-NEXT:    [[TMP3:%.*]] = shl i32 [[TMP1]], 1
+; CALLS-NEXT:    [[TMP4:%.*]] = lshr i32 [[TMP3]], 1
+; CALLS-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP1]], [[TMP4]]
+; CALLS-NEXT:    [[TMP6:%.*]] = xor i32 [[TMP4]], -1
+; CALLS-NEXT:    [[TMP7:%.*]] = and i32 [[X]], [[TMP6]]
+; CALLS-NEXT:    [[TMP8:%.*]] = or i32 [[TMP7]], [[TMP5]]
+; CALLS-NEXT:    [[TMP9:%.*]] = icmp sge i32 [[TMP8]], 0
+; CALLS-NEXT:    [[TMP10:%.*]] = shl i32 [[TMP1]], 1
+; CALLS-NEXT:    [[TMP11:%.*]] = lshr i32 [[TMP10]], 1
+; CALLS-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP1]], [[TMP11]]
+; CALLS-NEXT:    [[TMP13:%.*]] = xor i32 [[TMP12]], -1
+; CALLS-NEXT:    [[TMP14:%.*]] = and i32 [[X]], [[TMP13]]
+; CALLS-NEXT:    [[TMP15:%.*]] = or i32 [[TMP14]], [[TMP11]]
+; CALLS-NEXT:    [[TMP16:%.*]] = icmp sge i32 [[TMP15]], 0
+; CALLS-NEXT:    [[TMP17:%.*]] = xor i1 [[TMP9]], [[TMP16]]
 ; CALLS-NEXT:    [[TMP18:%.*]] = icmp sge i32 [[X]], 0
 ; CALLS-NEXT:    store i1 [[TMP17]], ptr @__msan_retval_tls, align 8
 ; CALLS-NEXT:    store i32 [[TMP2]], ptr @__msan_retval_origin_tls, align 4
@@ -1696,7 +1780,21 @@ define zeroext i1 @ICmpSGTZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; CHECK-SAME: i32 [[X:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; CHECK-NEXT:    call void @llvm.donothing()
-; CHECK-NEXT:    [[TMP16:%.*]] = icmp slt i32 [[TMP1]], 0
+; CHECK-NEXT:    [[TMP2:%.*]] = shl i32 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP3:%.*]] = lshr i32 [[TMP2]], 1
+; CHECK-NEXT:    [[TMP4:%.*]] = xor i32 [[TMP1]], [[TMP3]]
+; CHECK-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP4]], -1
+; CHECK-NEXT:    [[TMP6:%.*]] = and i32 [[X]], [[TMP5]]
+; CHECK-NEXT:    [[TMP7:%.*]] = or i32 [[TMP6]], [[TMP3]]
+; CHECK-NEXT:    [[TMP8:%.*]] = icmp sgt i32 0, [[TMP7]]
+; CHECK-NEXT:    [[TMP9:%.*]] = shl i32 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP10:%.*]] = lshr i32 [[TMP9]], 1
+; CHECK-NEXT:    [[TMP11:%.*]] = xor i32 [[TMP1]], [[TMP10]]
+; CHECK-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP10]], -1
+; CHECK-NEXT:    [[TMP13:%.*]] = and i32 [[X]], [[TMP12]]
+; CHECK-NEXT:    [[TMP14:%.*]] = or i32 [[TMP13]], [[TMP11]]
+; CHECK-NEXT:    [[TMP15:%.*]] = icmp sgt i32 0, [[TMP14]]
+; CHECK-NEXT:    [[TMP16:%.*]] = xor i1 [[TMP8]], [[TMP15]]
 ; CHECK-NEXT:    [[TMP17:%.*]] = icmp sgt i32 0, [[X]]
 ; CHECK-NEXT:    store i1 [[TMP16]], ptr @__msan_retval_tls, align 8
 ; CHECK-NEXT:    ret i1 [[TMP17]]
@@ -1706,10 +1804,26 @@ define zeroext i1 @ICmpSGTZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; ORIGIN-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; ORIGIN-NEXT:    [[TMP2:%.*]] = load i32, ptr @__msan_param_origin_tls, align 4
 ; ORIGIN-NEXT:    call void @llvm.donothing()
-; ORIGIN-NEXT:    [[TMP17:%.*]] = icmp slt i32 [[TMP1]], 0
+; ORIGIN-NEXT:    [[TMP3:%.*]] = shl i32 [[TMP1]], 1
+; ORIGIN-NEXT:    [[TMP4:%.*]] = lshr i32 [[TMP3]], 1
+; ORIGIN-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP1]], [[TMP4]]
+; ORIGIN-NEXT:    [[TMP6:%.*]] = xor i32 [[TMP5]], -1
+; ORIGIN-NEXT:    [[TMP7:%.*]] = and i32 [[X]], [[TMP6]]
+; ORIGIN-NEXT:    [[TMP8:%.*]] = or i32 [[TMP7]], [[TMP4]]
+; ORIGIN-NEXT:    [[TMP9:%.*]] = icmp sgt i32 0, [[TMP8]]
+; ORIGIN-NEXT:    [[TMP10:%.*]] = shl i32 [[TMP1]], 1
+; ORIGIN-NEXT:    [[TMP11:%.*]] = lshr i32 [[TMP10]], 1
+; ORIGIN-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP1]], [[TMP11]]
+; ORIGIN-NEXT:    [[TMP13:%.*]] = xor i32 [[TMP11]], -1
+; ORIGIN-NEXT:    [[TMP14:%.*]] = and i32 [[X]], [[TMP13]]
+; ORIGIN-NEXT:    [[TMP15:%.*]] = or i32 [[TMP14]], [[TMP12]]
+; ORIGIN-NEXT:    [[TMP16:%.*]] = icmp sgt i32 0, [[TMP15]]
+; ORIGIN-NEXT:    [[TMP17:%.*]] = xor i1 [[TMP9]], [[TMP16]]
+; ORIGIN-NEXT:    [[TMP18:%.*]] = icmp ne i32 [[TMP1]], 0
+; ORIGIN-NEXT:    [[TMP19:%.*]] = select i1 [[TMP18]], i32 [[TMP2]], i32 0
 ; ORIGIN-NEXT:    [[TMP20:%.*]] = icmp sgt i32 0, [[X]]
 ; ORIGIN-NEXT:    store i1 [[TMP17]], ptr @__msan_retval_tls, align 8
-; ORIGIN-NEXT:    store i32 [[TMP2]], ptr @__msan_retval_origin_tls, align 4
+; ORIGIN-NEXT:    store i32 [[TMP19]], ptr @__msan_retval_origin_tls, align 4
 ; ORIGIN-NEXT:    ret i1 [[TMP20]]
 ;
 ; CALLS-LABEL: define zeroext i1 @ICmpSGTZero(
@@ -1717,10 +1831,26 @@ define zeroext i1 @ICmpSGTZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; CALLS-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; CALLS-NEXT:    [[TMP2:%.*]] = load i32, ptr @__msan_param_origin_tls, align 4
 ; CALLS-NEXT:    call void @llvm.donothing()
-; CALLS-NEXT:    [[TMP17:%.*]] = icmp slt i32 [[TMP1]], 0
+; CALLS-NEXT:    [[TMP3:%.*]] = shl i32 [[TMP1]], 1
+; CALLS-NEXT:    [[TMP4:%.*]] = lshr i32 [[TMP3]], 1
+; CALLS-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP1]], [[TMP4]]
+; CALLS-NEXT:    [[TMP6:%.*]] = xor i32 [[TMP5]], -1
+; CALLS-NEXT:    [[TMP7:%.*]] = and i32 [[X]], [[TMP6]]
+; CALLS-NEXT:    [[TMP8:%.*]] = or i32 [[TMP7]], [[TMP4]]
+; CALLS-NEXT:    [[TMP9:%.*]] = icmp sgt i32 0, [[TMP8]]
+; CALLS-NEXT:    [[TMP10:%.*]] = shl i32 [[TMP1]], 1
+; CALLS-NEXT:    [[TMP11:%.*]] = lshr i32 [[TMP10]], 1
+; CALLS-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP1]], [[TMP11]]
+; CALLS-NEXT:    [[TMP13:%.*]] = xor i32 [[TMP11]], -1
+; CALLS-NEXT:    [[TMP14:%.*]] = and i32 [[X]], [[TMP13]]
+; CALLS-NEXT:    [[TMP15:%.*]] = or i32 [[TMP14]], [[TMP12]]
+; CALLS-NEXT:    [[TMP16:%.*]] = icmp sgt i32 0, [[TMP15]]
+; CALLS-NEXT:    [[TMP17:%.*]] = xor i1 [[TMP9]], [[TMP16]]
+; CALLS-NEXT:    [[TMP18:%.*]] = icmp ne i32 [[TMP1]], 0
+; CALLS-NEXT:    [[TMP19:%.*]] = select i1 [[TMP18]], i32 [[TMP2]], i32 0
 ; CALLS-NEXT:    [[TMP20:%.*]] = icmp sgt i32 0, [[X]]
 ; CALLS-NEXT:    store i1 [[TMP17]], ptr @__msan_retval_tls, align 8
-; CALLS-NEXT:    store i32 [[TMP2]], ptr @__msan_retval_origin_tls, align 4
+; CALLS-NEXT:    store i32 [[TMP19]], ptr @__msan_retval_origin_tls, align 4
 ; CALLS-NEXT:    ret i1 [[TMP20]]
 ;
   %1 = icmp sgt i32 0, %x
@@ -1733,7 +1863,21 @@ define zeroext i1 @ICmpSLEZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; CHECK-SAME: i32 [[X:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; CHECK-NEXT:    call void @llvm.donothing()
-; CHECK-NEXT:    [[TMP16:%.*]] = icmp slt i32 [[TMP1]], 0
+; CHECK-NEXT:    [[TMP2:%.*]] = shl i32 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP3:%.*]] = lshr i32 [[TMP2]], 1
+; CHECK-NEXT:    [[TMP4:%.*]] = xor i32 [[TMP1]], [[TMP3]]
+; CHECK-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP4]], -1
+; CHECK-NEXT:    [[TMP6:%.*]] = and i32 [[X]], [[TMP5]]
+; CHECK-NEXT:    [[TMP7:%.*]] = or i32 [[TMP6]], [[TMP3]]
+; CHECK-NEXT:    [[TMP8:%.*]] = icmp sle i32 0, [[TMP7]]
+; CHECK-NEXT:    [[TMP9:%.*]] = shl i32 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP10:%.*]] = lshr i32 [[TMP9]], 1
+; CHECK-NEXT:    [[TMP11:%.*]] = xor i32 [[TMP1]], [[TMP10]]
+; CHECK-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP10]], -1
+; CHECK-NEXT:    [[TMP13:%.*]] = and i32 [[X]], [[TMP12]]
+; CHECK-NEXT:    [[TMP14:%.*]] = or i32 [[TMP13]], [[TMP11]]
+; CHECK-NEXT:    [[TMP15:%.*]] = icmp sle i32 0, [[TMP14]]
+; CHECK-NEXT:    [[TMP16:%.*]] = xor i1 [[TMP8]], [[TMP15]]
 ; CHECK-NEXT:    [[TMP17:%.*]] = icmp sle i32 0, [[X]]
 ; CHECK-NEXT:    store i1 [[TMP16]], ptr @__msan_retval_tls, align 8
 ; CHECK-NEXT:    ret i1 [[TMP17]]
@@ -1743,10 +1887,26 @@ define zeroext i1 @ICmpSLEZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; ORIGIN-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; ORIGIN-NEXT:    [[TMP2:%.*]] = load i32, ptr @__msan_param_origin_tls, align 4
 ; ORIGIN-NEXT:    call void @llvm.donothing()
-; ORIGIN-NEXT:    [[TMP17:%.*]] = icmp slt i32 [[TMP1]], 0
+; ORIGIN-NEXT:    [[TMP3:%.*]] = shl i32 [[TMP1]], 1
+; ORIGIN-NEXT:    [[TMP4:%.*]] = lshr i32 [[TMP3]], 1
+; ORIGIN-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP1]], [[TMP4]]
+; ORIGIN-NEXT:    [[TMP6:%.*]] = xor i32 [[TMP5]], -1
+; ORIGIN-NEXT:    [[TMP7:%.*]] = and i32 [[X]], [[TMP6]]
+; ORIGIN-NEXT:    [[TMP8:%.*]] = or i32 [[TMP7]], [[TMP4]]
+; ORIGIN-NEXT:    [[TMP9:%.*]] = icmp sle i32 0, [[TMP8]]
+; ORIGIN-NEXT:    [[TMP10:%.*]] = shl i32 [[TMP1]], 1
+; ORIGIN-NEXT:    [[TMP11:%.*]] = lshr i32 [[TMP10]], 1
+; ORIGIN-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP1]], [[TMP11]]
+; ORIGIN-NEXT:    [[TMP13:%.*]] = xor i32 [[TMP11]], -1
+; ORIGIN-NEXT:    [[TMP14:%.*]] = and i32 [[X]], [[TMP13]]
+; ORIGIN-NEXT:    [[TMP15:%.*]] = or i32 [[TMP14]], [[TMP12]]
+; ORIGIN-NEXT:    [[TMP16:%.*]] = icmp sle i32 0, [[TMP15]]
+; ORIGIN-NEXT:    [[TMP17:%.*]] = xor i1 [[TMP9]], [[TMP16]]
+; ORIGIN-NEXT:    [[TMP18:%.*]] = icmp ne i32 [[TMP1]], 0
+; ORIGIN-NEXT:    [[TMP19:%.*]] = select i1 [[TMP18]], i32 [[TMP2]], i32 0
 ; ORIGIN-NEXT:    [[TMP20:%.*]] = icmp sle i32 0, [[X]]
 ; ORIGIN-NEXT:    store i1 [[TMP17]], ptr @__msan_retval_tls, align 8
-; ORIGIN-NEXT:    store i32 [[TMP2]], ptr @__msan_retval_origin_tls, align 4
+; ORIGIN-NEXT:    store i32 [[TMP19]], ptr @__msan_retval_origin_tls, align 4
 ; ORIGIN-NEXT:    ret i1 [[TMP20]]
 ;
 ; CALLS-LABEL: define zeroext i1 @ICmpSLEZero(
@@ -1754,10 +1914,26 @@ define zeroext i1 @ICmpSLEZero(i32 %x) nounwind uwtable readnone sanitize_memory
 ; CALLS-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; CALLS-NEXT:    [[TMP2:%.*]] = load i32, ptr @__msan_param_origin_tls, align 4
 ; CALLS-NEXT:    call void @llvm.donothing()
-; CALLS-NEXT:    [[TMP17:%.*]] = icmp slt i32 [[TMP1]], 0
+; CALLS-NEXT:    [[TMP3:%.*]] = shl i32 [[TMP1]], 1
+; CALLS-NEXT:    [[TMP4:%.*]] = lshr i32 [[TMP3]], 1
+; CALLS-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP1]], [[TMP4]]
+; CALLS-NEXT:    [[TMP6:%.*]] = xor i32 [[TMP5]], -1
+; CALLS-NEXT:    [[TMP7:%.*]] = and i32 [[X]], [[TMP6]]
+; CALLS-NEXT:    [[TMP8:%.*]] = or i32 [[TMP7]], [[TMP4]]
+; CALLS-NEXT:    [[TMP9:%.*]] = icmp sle i32 0, [[TMP8]]
+; CALLS-NEXT:    [[TMP10:%.*]] = shl i32 [[TMP1]], 1
+; CALLS-NEXT:    [[TMP11:%.*]] = lshr i32 [[TMP10]], 1
+; CALLS-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP1]], [[TMP11]]
+; CALLS-NEXT:    [[TMP13:%.*]] = xor i32 [[TMP11]], -1
+; CALLS-NEXT:    [[TMP14:%.*]] = and i32 [[X]], [[TMP13]]
+; CALLS-NEXT:    [[TMP15:%.*]] = or i32 [[TMP14]], [[TMP12]]
+; CALLS-NEXT:    [[TMP16:%.*]] = icmp sle i32 0, [[TMP15]]
+; CALLS-NEXT:    [[TMP17:%.*]] = xor i1 [[TMP9]], [[TMP16]]
+; CALLS-NEXT:    [[TMP18:%.*]] = icmp ne i32 [[TMP1]], 0
+; CALLS-NEXT:    [[TMP19:%.*]] = select i1 [[TMP18]], i32 [[TMP2]], i32 0
 ; CALLS-NEXT:    [[TMP20:%.*]] = icmp sle i32 0, [[X]]
 ; CALLS-NEXT:    store i1 [[TMP17]], ptr @__msan_retval_tls, align 8
-; CALLS-NEXT:    store i32 [[TMP2]], ptr @__msan_retval_origin_tls, align 4
+; CALLS-NEXT:    store i32 [[TMP19]], ptr @__msan_retval_origin_tls, align 4
 ; CALLS-NEXT:    ret i1 [[TMP20]]
 ;
   %1 = icmp sle i32 0, %x
@@ -1773,7 +1949,21 @@ define zeroext i1 @ICmpSLTAllOnes(i32 %x) nounwind uwtable readnone sanitize_mem
 ; CHECK-SAME: i32 [[X:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr @__msan_param_tls, align 8
 ; CHECK-NEXT:    call void @llvm.donothing()
-; CHECK-NEXT:    [[TMP16:%.*]] = icmp slt i32 [[TMP1]], 0
+; CHECK-NEXT:    [[TMP2:%.*]] = shl i32 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP3:%.*]] = lshr i32 [[TMP2]], 1
+; CHECK-NEXT:    [[TMP4:%.*]] = xor i32 [[TMP1]], [[TMP3]]
+; CHECK-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP4]], -1
+; CHECK-NEXT:    [[TMP6:%.*]] = and i32 [[X]], [[TMP5]]
+; CHECK-NEXT:    [[TMP7:%.*]] = or i32 [[TMP6]], [[TMP3]]
+; CHECK-NEXT:    [[TMP8:%.*]] = icmp slt i32 -1, [[TMP7]]
+; CHECK-NEXT:    [[TMP9:%.*]] = shl i32 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP10:%.*]] = lshr i32 [[TMP9]], 1
+; CHECK-NEXT:    [[TMP11:%.*]] = xor i32 [[TMP1]], [[TMP10]]
+; CHECK-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP10]], -1
+; CHECK-NEXT:    [[TMP13:%.*]] = and i32 [[X]], [[TMP12]]
+; CHECK-NEXT:    [[TMP14:%.*]] = or i32 [[TMP13]], [[TMP11]]
+; CHECK-NEXT:    [[TMP15:%.*]] = icmp slt i32 -1, [[TMP14]]
+; CHECK-NEXT:    [[TMP16:%.*]] = xor i1 [[TMP8]], [[TMP15]]
 ; CHECK-NEXT:    [[TMP17:%.*]] = icmp slt i32 -1, [[X]]
 ; CHECK-NEXT:    store i1 [[TMP16]], ptr @__msan_retval_tls, align 8
 ; CHECK-NEXT:    ret i1 [[TMP17]]
@@ -1783,10 +1973,26 @@ define zeroext i1 @ICmpS...
[truncated]

Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
vitalybuka added a commit that referenced this pull request Oct 22, 2024
PR is to:
1. Simplify test update in #113200
2. Make tests more comprehensive, currently interesting cases looks very
basic:

```
; CHECK-LABEL: @ICmpSGTAllOnes
; CHECK: icmp slt
; CHECK-NOT: call void @__msan_warning
; CHECK: icmp sgt
; CHECK-NOT: call void @__msan_warning
; CHECK: ret i1
```
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
@vitalybuka vitalybuka changed the base branch from users/vitalybuka/spr/main.msan-switch-to-msan-handle-icmp-exact-my-default to main October 22, 2024 19:34
@vitalybuka vitalybuka merged commit 395093e into main Oct 22, 2024
6 of 8 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/msan-switch-to-msan-handle-icmp-exact-my-default branch October 22, 2024 19:35
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 22, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-sie-ubuntu-fast running on sie-linux-worker while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/9929

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: Instrumentation/MemorySanitizer/pr32842.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/opt < /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll -S -passes=msan 2>&1 | /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/opt -S -passes=msan
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
�[1m/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll:18:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: is not on the line after the previous match
�[0m; CHECK-NEXT: [[TMP28:%.*]] = shl i32 [[TMP0]], 1
�[0;1;32m              ^
�[0m�[1m<stdin>:28:2: �[0m�[0;1;30mnote: �[0m�[1m'next' match was here
�[0m %8 = shl i32 %0, 1
�[0;1;32m ^
�[0m�[1m<stdin>:21:29: �[0m�[0;1;30mnote: �[0m�[1mprevious match ended here
�[0m call void @llvm.donothing()
�[0;1;32m                            ^
�[0m�[1m<stdin>:22:1: �[0m�[0;1;30mnote: �[0m�[1mnon-matching line after previous match is here
�[0m %2 = shl i32 %1, 1
�[0;1;32m^
�[0m
Input file: <stdin>
Check file: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
�[1m�[0m�[0;1;30m            1: �[0m�[1m�[0;1;46m; ModuleID = '<stdin>' �[0m
�[0;1;30m            2: �[0m�[1m�[0;1;46msource_filename = "<stdin>" �[0m
�[0;1;30m            3: �[0m�[1m�[0;1;46mtarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" �[0m
�[0;1;30m            4: �[0m�[1m�[0;1;46mtarget triple = "x86_64-unknown-linux-gnu" �[0m
�[0;1;30m            5: �[0m�[1m�[0;1;46m �[0m
�[0;1;30m            6: �[0m�[1m�[0;1;[email protected] = appending global [1 x ptr] [ptr @msan.module_ctor], section "llvm.metadata" �[0m
�[0;1;30m            7: �[0m�[1m�[0;1;[email protected]_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr @msan.module_ctor, ptr null }] �[0m
�[0;1;30m            8: �[0m�[1m�[0;1;46m@__msan_retval_tls = external thread_local(initialexec) global [100 x i64] �[0m
�[0;1;30m            9: �[0m�[1m�[0;1;46m@__msan_retval_origin_tls = external thread_local(initialexec) global i32 �[0m
�[0;1;30m           10: �[0m�[1m�[0;1;46m@__msan_param_tls = external thread_local(initialexec) global [100 x i64] �[0m
�[0;1;30m           11: �[0m�[1m�[0;1;46m@__msan_param_origin_tls = external thread_local(initialexec) global [200 x i32] �[0m
�[0;1;30m           12: �[0m�[1m�[0;1;46m@__msan_va_arg_tls = external thread_local(initialexec) global [100 x i64] �[0m
�[0;1;30m           13: �[0m�[1m�[0;1;46m@__msan_va_arg_origin_tls = external thread_local(initialexec) global [200 x i32] �[0m
�[0;1;30m           14: �[0m�[1m�[0;1;46m@__msan_va_arg_overflow_size_tls = external thread_local(initialexec) global i64 �[0m
�[0;1;30m           15: �[0m�[1m�[0;1;46m �[0m
�[0;1;30m           16: �[0m�[1m�[0;1;46m; Function Attrs: sanitize_memory �[0m
�[0;1;30m           17: �[0m�[1m�[0;1;46m�[0mdefine zeroext i1 @_Z1fii(i32 %x, i32 %y) #0 {�[0;1;46m �[0m
�[0;1;32mlabel:12'0     ^~~~~~~~~~~~~~~~~~~~~~~~~~
�[0m�[0;1;32mlabel:12'1     ^~~~~~~~~~~~~~~~~~~~~~~~~~
�[0m�[0;1;32msame:13'0                                ^~~~~~~~~~~~~~~~~~~~
�[0m�[0;1;32msame:13'1                                    ^~                captured var "X"
�[0m�[0;1;32msame:13'2                                            ^~        captured var "Y"
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 22, 2024

LLVM Buildbot has detected a new failure on builder llvm-nvptx-nvidia-ubuntu running on as-builder-7 while building llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/180/builds/7144

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: Instrumentation/MemorySanitizer/pr32842.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/bin/opt < /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll -S -passes=msan 2>&1 | /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/bin/opt -S -passes=msan
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll:18:15: error: CHECK-NEXT: is not on the line after the previous match
; CHECK-NEXT: [[TMP28:%.*]] = shl i32 [[TMP0]], 1
              ^
<stdin>:28:2: note: 'next' match was here
 %8 = shl i32 %0, 1
 ^
<stdin>:21:29: note: previous match ended here
 call void @llvm.donothing()
                            ^
<stdin>:22:1: note: non-matching line after previous match is here
 %2 = shl i32 %1, 1
^

Input file: <stdin>
Check file: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
         .
         .
         .
        23:  %3 = lshr i32 %2, 1 
        24:  %4 = xor i32 %1, %3 
        25:  %5 = xor i32 %4, -1 
        26:  %6 = and i32 %y, %5 
        27:  %7 = or i32 %6, %3 
        28:  %8 = shl i32 %0, 1 
next:18      !~~~~~~~~~~~~~~~~~  error: match on wrong line
        29:  %9 = lshr i32 %8, 1 
        30:  %10 = xor i32 %0, %9 
        31:  %11 = xor i32 %9, -1 
        32:  %12 = and i32 %x, %11 
        33:  %13 = or i32 %12, %10 
         .
         .
         .
>>>>>>

--

...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 22, 2024

LLVM Buildbot has detected a new failure on builder ml-opt-rel-x86-64 running on ml-opt-rel-x86-64-b1 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/185/builds/7254

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: Instrumentation/MemorySanitizer/pr32842.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /b/ml-opt-rel-x86-64-b1/build/bin/opt < /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll -S -passes=msan 2>&1 | /b/ml-opt-rel-x86-64-b1/build/bin/FileCheck /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
+ /b/ml-opt-rel-x86-64-b1/build/bin/FileCheck /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
+ /b/ml-opt-rel-x86-64-b1/build/bin/opt -S -passes=msan
/b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll:18:15: error: CHECK-NEXT: is not on the line after the previous match
; CHECK-NEXT: [[TMP28:%.*]] = shl i32 [[TMP0]], 1
              ^
<stdin>:28:2: note: 'next' match was here
 %8 = shl i32 %0, 1
 ^
<stdin>:21:29: note: previous match ended here
 call void @llvm.donothing()
                            ^
<stdin>:22:1: note: non-matching line after previous match is here
 %2 = shl i32 %1, 1
^

Input file: <stdin>
Check file: /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
         .
         .
         .
        23:  %3 = lshr i32 %2, 1 
        24:  %4 = xor i32 %1, %3 
        25:  %5 = xor i32 %4, -1 
        26:  %6 = and i32 %y, %5 
        27:  %7 = or i32 %6, %3 
        28:  %8 = shl i32 %0, 1 
next:18      !~~~~~~~~~~~~~~~~~  error: match on wrong line
        29:  %9 = lshr i32 %8, 1 
        30:  %10 = xor i32 %0, %9 
        31:  %11 = xor i32 %9, -1 
        32:  %12 = and i32 %x, %11 
        33:  %13 = or i32 %12, %10 
         .
         .
         .
>>>>>>

--

...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 22, 2024

LLVM Buildbot has detected a new failure on builder ml-opt-devrel-x86-64 running on ml-opt-devrel-x86-64-b1 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/175/builds/7270

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: Instrumentation/MemorySanitizer/pr32842.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /b/ml-opt-devrel-x86-64-b1/build/bin/opt < /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll -S -passes=msan 2>&1 | /b/ml-opt-devrel-x86-64-b1/build/bin/FileCheck /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
+ /b/ml-opt-devrel-x86-64-b1/build/bin/opt -S -passes=msan
+ /b/ml-opt-devrel-x86-64-b1/build/bin/FileCheck /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
/b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll:18:15: error: CHECK-NEXT: is not on the line after the previous match
; CHECK-NEXT: [[TMP28:%.*]] = shl i32 [[TMP0]], 1
              ^
<stdin>:28:2: note: 'next' match was here
 %8 = shl i32 %0, 1
 ^
<stdin>:21:29: note: previous match ended here
 call void @llvm.donothing()
                            ^
<stdin>:22:1: note: non-matching line after previous match is here
 %2 = shl i32 %1, 1
^

Input file: <stdin>
Check file: /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
         .
         .
         .
        23:  %3 = lshr i32 %2, 1 
        24:  %4 = xor i32 %1, %3 
        25:  %5 = xor i32 %4, -1 
        26:  %6 = and i32 %y, %5 
        27:  %7 = or i32 %6, %3 
        28:  %8 = shl i32 %0, 1 
next:18      !~~~~~~~~~~~~~~~~~  error: match on wrong line
        29:  %9 = lshr i32 %8, 1 
        30:  %10 = xor i32 %0, %9 
        31:  %11 = xor i32 %9, -1 
        32:  %12 = and i32 %x, %11 
        33:  %13 = or i32 %12, %10 
         .
         .
         .
>>>>>>

--

...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 22, 2024

LLVM Buildbot has detected a new failure on builder ml-opt-dev-x86-64 running on ml-opt-dev-x86-64-b2 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/137/builds/7368

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: Instrumentation/MemorySanitizer/pr32842.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /b/ml-opt-dev-x86-64-b1/build/bin/opt < /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll -S -passes=msan 2>&1 | /b/ml-opt-dev-x86-64-b1/build/bin/FileCheck /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
+ /b/ml-opt-dev-x86-64-b1/build/bin/opt -S -passes=msan
+ /b/ml-opt-dev-x86-64-b1/build/bin/FileCheck /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll:18:15: error: CHECK-NEXT: is not on the line after the previous match
; CHECK-NEXT: [[TMP28:%.*]] = shl i32 [[TMP0]], 1
              ^
<stdin>:28:2: note: 'next' match was here
 %8 = shl i32 %0, 1
 ^
<stdin>:21:29: note: previous match ended here
 call void @llvm.donothing()
                            ^
<stdin>:22:1: note: non-matching line after previous match is here
 %2 = shl i32 %1, 1
^

Input file: <stdin>
Check file: /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
         .
         .
         .
        23:  %3 = lshr i32 %2, 1 
        24:  %4 = xor i32 %1, %3 
        25:  %5 = xor i32 %4, -1 
        26:  %6 = and i32 %y, %5 
        27:  %7 = or i32 %6, %3 
        28:  %8 = shl i32 %0, 1 
next:18      !~~~~~~~~~~~~~~~~~  error: match on wrong line
        29:  %9 = lshr i32 %8, 1 
        30:  %10 = xor i32 %0, %9 
        31:  %11 = xor i32 %9, -1 
        32:  %12 = and i32 %x, %11 
        33:  %13 = or i32 %12, %10 
         .
         .
         .
>>>>>>

--

...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 22, 2024

LLVM Buildbot has detected a new failure on builder llvm-nvptx64-nvidia-ubuntu running on as-builder-7 while building llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/7146

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: Instrumentation/MemorySanitizer/pr32842.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/opt < /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll -S -passes=msan 2>&1 | /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/opt -S -passes=msan
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll:18:15: error: CHECK-NEXT: is not on the line after the previous match
; CHECK-NEXT: [[TMP28:%.*]] = shl i32 [[TMP0]], 1
              ^
<stdin>:28:2: note: 'next' match was here
 %8 = shl i32 %0, 1
 ^
<stdin>:21:29: note: previous match ended here
 call void @llvm.donothing()
                            ^
<stdin>:22:1: note: non-matching line after previous match is here
 %2 = shl i32 %1, 1
^

Input file: <stdin>
Check file: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
         .
         .
         .
        23:  %3 = lshr i32 %2, 1 
        24:  %4 = xor i32 %1, %3 
        25:  %5 = xor i32 %4, -1 
        26:  %6 = and i32 %y, %5 
        27:  %7 = or i32 %6, %3 
        28:  %8 = shl i32 %0, 1 
next:18      !~~~~~~~~~~~~~~~~~  error: match on wrong line
        29:  %9 = lshr i32 %8, 1 
        30:  %10 = xor i32 %0, %9 
        31:  %11 = xor i32 %9, -1 
        32:  %12 = and i32 %x, %11 
        33:  %13 = or i32 %12, %10 
         .
         .
         .
>>>>>>

--

...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 22, 2024

LLVM Buildbot has detected a new failure on builder lld-x86_64-ubuntu-fast running on as-builder-4 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/33/builds/5194

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: Instrumentation/MemorySanitizer/pr32842.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/opt < /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll -S -passes=msan 2>&1 | /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
+ /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/opt -S -passes=msan
+ /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll
/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll:18:15: error: CHECK-NEXT: is not on the line after the previous match
; CHECK-NEXT: [[TMP28:%.*]] = shl i32 [[TMP0]], 1
              ^
<stdin>:28:2: note: 'next' match was here
 %8 = shl i32 %0, 1
 ^
<stdin>:21:29: note: previous match ended here
 call void @llvm.donothing()
                            ^
<stdin>:22:1: note: non-matching line after previous match is here
 %2 = shl i32 %1, 1
^

Input file: <stdin>
Check file: /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/Instrumentation/MemorySanitizer/pr32842.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
         .
         .
         .
        23:  %3 = lshr i32 %2, 1 
        24:  %4 = xor i32 %1, %3 
        25:  %5 = xor i32 %4, -1 
        26:  %6 = and i32 %y, %5 
        27:  %7 = or i32 %6, %3 
        28:  %8 = shl i32 %0, 1 
next:18      !~~~~~~~~~~~~~~~~~  error: match on wrong line
        29:  %9 = lshr i32 %8, 1 
        30:  %10 = xor i32 %0, %9 
        31:  %11 = xor i32 %9, -1 
        32:  %12 = and i32 %x, %11 
        33:  %13 = or i32 %12, %10 
         .
         .
         .
>>>>>>

--

...

goldsteinn added a commit that referenced this pull request Oct 23, 2024
vitalybuka added a commit that referenced this pull request Oct 25, 2024
CTMark #113200 size overhead was 5.3%, now it's 4.7%.

The patch affects only signed integers.

https://alive2.llvm.org/ce/z/Lv5hyi

* The patch replaces code which extracted sign bit,
maximized/minimized it, then packed it back, with
simple sign bit flip. The another way to think about
transformation is as a subtraction of MIN_SINT from
A/B. Then we map MIN_SINT to 0, 0 to -MIN_SINT, and
MAX_SINT to MAX_UINT.

* Then to maximize/minimize A/B we don't need
to extract sign bit, we can apply shadow the
same way as to other bits.

* After sign bit flip, we had to switch to unsigned
version of the predicates.

* After change above  getHighestPossibleValue/getLowestPossibleValue
became very similar, so we can combine into a single function.

* Because the function does sign bit flip and
requires unsigned predicates used for returned values,
there is no point in keeping it as a member of class,
to hide, we switch to function local lambda.
@frobtech frobtech mentioned this pull request Oct 25, 2024
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
CTMark llvm#113200 size overhead was 5.3%, now it's 4.7%.

The patch affects only signed integers.

https://alive2.llvm.org/ce/z/Lv5hyi

* The patch replaces code which extracted sign bit,
maximized/minimized it, then packed it back, with
simple sign bit flip. The another way to think about
transformation is as a subtraction of MIN_SINT from
A/B. Then we map MIN_SINT to 0, 0 to -MIN_SINT, and
MAX_SINT to MAX_UINT.

* Then to maximize/minimize A/B we don't need
to extract sign bit, we can apply shadow the
same way as to other bits.

* After sign bit flip, we had to switch to unsigned
version of the predicates.

* After change above  getHighestPossibleValue/getLowestPossibleValue
became very similar, so we can combine into a single function.

* Because the function does sign bit flip and
requires unsigned predicates used for returned values,
there is no point in keeping it as a member of class,
to hide, we switch to function local lambda.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[msan] Better handling of signed compare
4 participants