[llvm] [msan] Add handleIntrinsicByApplyingToShadow; support NEON tbl/tbx (PR #114490)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 1 12:54:49 PDT 2024


================
@@ -3944,6 +3944,45 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
     }
   }
 
+  /// Handle intrinsics by applying the intrinsic to the shadows. The trailing
+  /// arguments are passed verbatim e.g., for an intrinsic with one trailing
+  /// verbatim argument:
+  ///     out = intrinsic(var1, var2, opType)
+  /// we compute:
+  ///     shadow[out] = intrinsic(shadow[var1], shadow[var2], opType)
+  ///
+  /// For example, this can be applied to the Arm NEON vector table intrinsics
+  /// (tbl{1,2,3,4}).
+  ///
+  /// The origin is approximated using setOriginForNaryOp.
+  void handleIntrinsicByApplyingToShadow(IntrinsicInst &I,
+                                         unsigned int trailingVerbatimArgs) {
+    IRBuilder<> IRB(&I);
+
+    assert(trailingVerbatimArgs < I.arg_size());
+
+    SmallVector<Value *, 8> ShadowArgs;
+    // Don't use getNumOperands() because it includes the callee
+    for (unsigned int i = 0; i < I.arg_size(); i++) {
----------------
vitalybuka wrote:

Not sure how common is undef in indexes when output then ignored.
it's possible that instead of check it's better to "OR(CI,  IDX)".

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


More information about the llvm-commits mailing list