[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)

Vitaly Buka via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jun 12 15:29:25 PDT 2024


================
@@ -3356,6 +3356,37 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
     setOriginForNaryOp(I);
   }
 
+  Value *convertBlendvToSelectMask(IRBuilder<> &IRB, Value *C) {
+    C = CreateAppToShadowCast(IRB, C);
+    FixedVectorType *FVT = cast<FixedVectorType>(C->getType());
+    unsigned ElSize = FVT->getElementType()->getPrimitiveSizeInBits();
+    C = IRB.CreateAShr(C, ElSize - 1);
+    FVT = FixedVectorType::get(IRB.getInt1Ty(), FVT->getNumElements());
+    return IRB.CreateTrunc(C, FVT);
+  }
+
+  // `blendv(f, t, c)` is effectively `select(c[top_bit], t, f)`.
+  void handleBlendvIntrinsic(IntrinsicInst &I) {
+    Value *C = I.getOperand(2);
+    Value *T = I.getOperand(1);
+    Value *F = I.getOperand(0);
+
+    Value *Sc = getShadow(&I, 2);
+    Value *Oc = MS.TrackOrigins ? getOrigin(C) : nullptr;
+
+    {
+      IRBuilder<> IRB(&I);
----------------
vitalybuka wrote:

I think it's unimportant. Builder has nothing interesting in destructor.

`{}` is rather just to show that we don't need to can about builders conflict.

https://github.com/llvm/llvm-project/pull/94882


More information about the llvm-branch-commits mailing list