From 203f29b40ca3a248307ab75af04577f10173591f Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sun, 5 Dec 2021 11:12:44 +0000 Subject: [PATCH] [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. --- llvm/lib/Analysis/MemoryLocation.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/llvm/lib/Analysis/MemoryLocation.cpp b/llvm/lib/Analysis/MemoryLocation.cpp index 3d068c4..93b5f6e 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(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(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 -- 2.7.4