[llvm] 4f41698 - [NFC][msan] Prepare function to extract main logic (#94880)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 13:05:08 PDT 2024


Author: Vitaly Buka
Date: 2024-06-10T13:05:05-07:00
New Revision: 4f416989d80ef6a3b5d759a2b1c576c019cbedbe

URL: https://github.com/llvm/llvm-project/commit/4f416989d80ef6a3b5d759a2b1c576c019cbedbe
DIFF: https://github.com/llvm/llvm-project/commit/4f416989d80ef6a3b5d759a2b1c576c019cbedbe.diff

LOG: [NFC][msan] Prepare function to extract main logic (#94880)

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 b352558a1c0d2..0d45bc3bfebdc 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -4486,10 +4486,15 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
     Value *B = I.getCondition();
     Value *C = I.getTrueValue();
     Value *D = I.getFalseValue();
+
     Value *Sb = getShadow(B);
     Value *Sc = getShadow(C);
     Value *Sd = getShadow(D);
 
+    Value *Ob = MS.TrackOrigins ? getOrigin(B) : nullptr;
+    Value *Oc = MS.TrackOrigins ? getOrigin(C) : nullptr;
+    Value *Od = MS.TrackOrigins ? getOrigin(D) : nullptr;
+
     // Result shadow if condition shadow is 0.
     Value *Sa0 = IRB.CreateSelect(B, Sc, Sd);
     Value *Sa1;
@@ -4522,10 +4527,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
       }
       // a = select b, c, d
       // Oa = Sb ? Ob : (b ? Oc : Od)
-      setOrigin(
-          &I, IRB.CreateSelect(Sb, getOrigin(I.getCondition()),
-                               IRB.CreateSelect(B, getOrigin(I.getTrueValue()),
-                                                getOrigin(I.getFalseValue()))));
+      setOrigin(&I, IRB.CreateSelect(Sb, Ob, IRB.CreateSelect(B, Oc, Od)));
     }
   }
 


        


More information about the llvm-commits mailing list