[MemLoc] Adjust memccpy support in MemoryLocation::getForArgument
authorDávid Bolvanský <david.bolvansky@gmail.com>
Wed, 28 Oct 2020 20:23:13 +0000 (21:23 +0100)
committerDávid Bolvanský <david.bolvansky@gmail.com>
Wed, 28 Oct 2020 20:26:10 +0000 (21:26 +0100)
Use LocationSize::upperBound instead of precise since we only know an upper bound on the number of bytes read/written.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D89885

llvm/lib/Analysis/MemoryLocation.cpp

index 4c1395c..8d58679 100644 (file)
@@ -257,10 +257,11 @@ MemoryLocation MemoryLocation::getForArgument(const CallBase *Call,
     case LibFunc_memccpy:
       assert((ArgIdx == 0 || ArgIdx == 1) &&
              "Invalid argument index for memccpy");
+      // We only know an upper bound on the number of bytes read/written.
       if (const ConstantInt *LenCI =
               dyn_cast<ConstantInt>(Call->getArgOperand(3)))
-        return MemoryLocation(Arg, LocationSize::precise(LenCI->getZExtValue()),
-                              AATags);
+        return MemoryLocation(
+            Arg, LocationSize::upperBound(LenCI->getZExtValue()), AATags);
       break;
     default:
       break;