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

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 1 11:19:08 PDT 2024


================
@@ -3944,6 +3944,42 @@ 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++) {
+      if (i < I.arg_size() - trailingVerbatimArgs) {
+        Value *Shadow = getShadow(&I, i);
+        ShadowArgs.append(1, Shadow);
----------------
vitalybuka wrote:

append -> push_back()

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


More information about the llvm-commits mailing list