[llvm] [msan] Add debugging for handleUnknownIntrinsic (PR #123381)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 10:13:23 PST 2025


================
@@ -3016,28 +3023,32 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
   /// handling as an example of that.
   bool handleUnknownIntrinsic(IntrinsicInst &I) {
     unsigned NumArgOperands = I.arg_size();
-    if (NumArgOperands == 0)
-      return false;
 
-    if (NumArgOperands == 2 && I.getArgOperand(0)->getType()->isPointerTy() &&
-        I.getArgOperand(1)->getType()->isVectorTy() &&
-        I.getType()->isVoidTy() && !I.onlyReadsMemory()) {
+    bool success = false;
+    if (NumArgOperands == 0) {
+      // No-op
+    } else if (NumArgOperands == 2 &&
+               I.getArgOperand(0)->getType()->isPointerTy() &&
+               I.getArgOperand(1)->getType()->isVectorTy() &&
+               I.getType()->isVoidTy() && !I.onlyReadsMemory()) {
       // This looks like a vector store.
-      return handleVectorStoreIntrinsic(I);
-    }
-
-    if (NumArgOperands == 1 && I.getArgOperand(0)->getType()->isPointerTy() &&
-        I.getType()->isVectorTy() && I.onlyReadsMemory()) {
+      success = handleVectorStoreIntrinsic(I);
+    } else if (NumArgOperands == 1 &&
+               I.getArgOperand(0)->getType()->isPointerTy() &&
+               I.getType()->isVectorTy() && I.onlyReadsMemory()) {
       // This looks like a vector load.
-      return handleVectorLoadIntrinsic(I);
-    }
+      success = handleVectorLoadIntrinsic(I);
+    } else if (I.doesNotAccessMemory())
+      success = maybeHandleSimpleNomemIntrinsic(I);
+
+    if (success && ClDumpStrictIntrinsics)
+      dumpInst(I);
 
-    if (I.doesNotAccessMemory())
-      if (maybeHandleSimpleNomemIntrinsic(I))
-        return true;
+    LLVM_DEBUG(dbgs() << "UNKNOWN INTRINSIC HANDLED HEURISTICALLY: " << I
----------------
fmayer wrote:

why do we print this if `!success`? we didn't handle it heuristically then?

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


More information about the llvm-commits mailing list