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

Florian Mayer via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jun 12 14:32:06 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);
----------------
fmayer wrote:

Why does it matter that this doesn't outlive `handleSelectLikeInst`? Because that also creates an IRBuilder? How does that work? That creates it from `&I` as well, which means these instructions get inserted before the ones here, right?

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


More information about the llvm-branch-commits mailing list