[llvm] 203f29b - [MemoryLocation] Use getForArgument in getForSource/getForDest. (NFC)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 5 03:13:26 PST 2021


Author: Florian Hahn
Date: 2021-12-05T11:13:14Z
New Revision: 203f29b40ca3a248307ab75af04577f10173591f

URL: https://github.com/llvm/llvm-project/commit/203f29b40ca3a248307ab75af04577f10173591f
DIFF: https://github.com/llvm/llvm-project/commit/203f29b40ca3a248307ab75af04577f10173591f.diff

LOG: [MemoryLocation] Use getForArgument in getForSource/getForDest. (NFC)

getForArgument already knows how to extract a memory location for all
memory intrinsics. Use it instead of duplicating the logic.

Added: 
    

Modified: 
    llvm/lib/Analysis/MemoryLocation.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/MemoryLocation.cpp b/llvm/lib/Analysis/MemoryLocation.cpp
index 3d068c460710..93b5f6e9871c 100644
--- a/llvm/lib/Analysis/MemoryLocation.cpp
+++ b/llvm/lib/Analysis/MemoryLocation.cpp
@@ -101,13 +101,8 @@ MemoryLocation MemoryLocation::getForSource(const AtomicMemTransferInst *MTI) {
 }
 
 MemoryLocation MemoryLocation::getForSource(const AnyMemTransferInst *MTI) {
-  auto Size = LocationSize::afterPointer();
-  if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
-    Size = LocationSize::precise(C->getValue().getZExtValue());
-
-  // memcpy/memmove can have AA tags. For memcpy, they apply
-  // to both the source and the destination.
-  return MemoryLocation(MTI->getRawSource(), Size, MTI->getAAMetadata());
+  assert(MTI->getRawSource() == MTI->getArgOperand(1));
+  return getForArgument(MTI, 1, nullptr);
 }
 
 MemoryLocation MemoryLocation::getForDest(const MemIntrinsic *MI) {
@@ -119,13 +114,8 @@ MemoryLocation MemoryLocation::getForDest(const AtomicMemIntrinsic *MI) {
 }
 
 MemoryLocation MemoryLocation::getForDest(const AnyMemIntrinsic *MI) {
-  auto Size = LocationSize::afterPointer();
-  if (ConstantInt *C = dyn_cast<ConstantInt>(MI->getLength()))
-    Size = LocationSize::precise(C->getValue().getZExtValue());
-
-  // memcpy/memmove can have AA tags. For memcpy, they apply
-  // to both the source and the destination.
-  return MemoryLocation(MI->getRawDest(), Size, MI->getAAMetadata());
+  assert(MI->getRawDest() == MI->getArgOperand(0));
+  return getForArgument(MI, 0, nullptr);
 }
 
 Optional<MemoryLocation>


        


More information about the llvm-commits mailing list