[llvm-branch-commits] [llvm] [msan] Reduces overhead of #113200, by 10% (PR #113201)

Vitaly Buka via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Oct 21 11:04:07 PDT 2024


https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/113201

>From aa4280d627d0f2b2d57bf1f9bf574d2f6ab55d38 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Mon, 21 Oct 2024 11:01:36 -0700
Subject: [PATCH 1/2] comment

Created using spr 1.3.4
---
 .../Transforms/Instrumentation/MemorySanitizer.cpp    | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 962d7cc5bca347..07fa9b729463e8 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2719,11 +2719,12 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
 
     auto GetMinMaxUnsigned = [&](Value *V, Value *S) {
       if (IsSigned) {
-        // Map from signed range to unsigned range. Relation A vs B should be
-        // preserved if checked with `getUnsignedPredicate()`.
-        // Calcualting Amin, Amax, Bmin, Bmax also will not be affected, as they
-        // are created by effectively adding/substructing from A or B a value,
-        // derived from shadow, which can't result in overflow.
+        // Sign-flip to map from signed range to unsigned range. Relation A vs B
+        // should be preserved, if checked with `getUnsignedPredicate()`.
+        // Relationship between Amin, Amax, Bmin, Bmax also will not be
+        // affected, as they are created by effectively adding/substructing from
+        // A or B a value, derived from shadow, which can't result in overflow,
+        // before or after sign flip.
         APInt MinVal =
             APInt::getSignedMinValue(V->getType()->getScalarSizeInBits());
         V = IRB.CreateXor(V, ConstantInt::get(V->getType(), MinVal));

>From afda5ceed69201fb24a46181462e2087aa768d55 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Mon, 21 Oct 2024 11:03:56 -0700
Subject: [PATCH 2/2] comment

Created using spr 1.3.4
---
 llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 07fa9b729463e8..391fb30d95e2ae 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2723,7 +2723,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
         // should be preserved, if checked with `getUnsignedPredicate()`.
         // Relationship between Amin, Amax, Bmin, Bmax also will not be
         // affected, as they are created by effectively adding/substructing from
-        // A or B a value, derived from shadow, which can't result in overflow,
+        // A (or B) a value, derived from shadow, with no overflow, either
         // before or after sign flip.
         APInt MinVal =
             APInt::getSignedMinValue(V->getType()->getScalarSizeInBits());



More information about the llvm-branch-commits mailing list