[llvm] [msan] Handle horizontal add/subtract intrinsic by applying to shadow (PR #124159)

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 14:29:24 PST 2025


================
@@ -3904,6 +3904,23 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
     setOriginForNaryOp(I);
   }
 
+  void handleAVXHorizontalAddSubIntrinsic(IntrinsicInst &I) {
+    // Approximation only:
+    //    output         = horizontal_add(A, B)
+    // => shadow[output] = horizontal_add(shadow[A], shadow[B])
+    //
+    // - If we add/subtract two adjacent zero (initialized) shadow values, the
+    //   result always be zero i.e., no false positives.
+    // - If we add/subtract two shadows, one of which is uninitialized, the
+    //   result will always be non-zero i.e., no false negative.
+    // - However, we can have false negatives if we subtract two non-zero
+    //   shadows of the same value (or do an addition that wraps to zero); we
+    //   consider this an acceptable tradeoff for performance.
----------------
thurstond wrote:

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

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


More information about the llvm-commits mailing list