From f3aa040637002b1c68a141a01aa74f6bf89bbbad Mon Sep 17 00:00:00 2001 From: Thurston Dang Date: Wed, 17 Jul 2024 18:07:33 +0000 Subject: [PATCH] Use arg_size() instead of (getNumOperands() - 1) --- .../Transforms/Instrumentation/MemorySanitizer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 377223e93cd8d07..b2a3072a7ffe7b6 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -3800,10 +3800,11 @@ struct MemorySanitizerVisitor : public InstVisitor { /// Calculates the shadow for interleaving 2, 3 or 4 vectors /// (e.g., for Arm NEON vector store). Value *interleaveShadow(IRBuilder<> &IRB, IntrinsicInst &I) { - // Call arguments only - int numArgOperands = I.getNumOperands() - 1; + // Don't use getNumOperands() because it includes the callee + int numArgOperands = I.arg_size(); assert(numArgOperands >= 1); + // The last arg operand is the output int numVectors = numArgOperands - 1; for (int i = 0; i < numVectors; i++) { @@ -3846,9 +3847,11 @@ struct MemorySanitizerVisitor : public InstVisitor { Value *interleavedShadow = interleaveShadow(IRB, I); - // Call arguments only - int numArgOperands = I.getNumOperands() - 1; + // Don't use getNumOperands() because it includes the callee + int numArgOperands = I.arg_size(); assert(numArgOperands >= 1); + + // The last arg operand is the output Value *Addr = I.getArgOperand(numArgOperands - 1); Value *ShadowPtr, *OriginPtr;