summaryrefslogtreecommitdiff
path: root/lib/Analysis/AliasAnalysis.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-12-16 02:51:19 +0000
committerDan Gohman <gohman@apple.com>2010-12-16 02:51:19 +0000
commit387f28aff41bae6a81311279b203a1281eaa443a (patch)
treed2c63b30ae9175f22baaea33a98c5f1f4875ae68 /lib/Analysis/AliasAnalysis.cpp
parentad3ea3d85f164dc1b2746950e378334197d8688d (diff)
downloadllvm-387f28aff41bae6a81311279b203a1281eaa443a.tar.gz
llvm-387f28aff41bae6a81311279b203a1281eaa443a.tar.bz2
llvm-387f28aff41bae6a81311279b203a1281eaa443a.tar.xz
Make memcpyopt TBAA-aware.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121944 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/AliasAnalysis.cpp')
-rw-r--r--lib/Analysis/AliasAnalysis.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp
index 588d68da33..7a94c431de 100644
--- a/lib/Analysis/AliasAnalysis.cpp
+++ b/lib/Analysis/AliasAnalysis.cpp
@@ -219,8 +219,11 @@ AliasAnalysis::getLocationForSource(const MemTransferInst *MTI) {
if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
Size = C->getValue().getZExtValue();
- // FIXME: Can memcpy/memmove have TBAA tags?
- return Location(MTI->getRawSource(), Size, 0);
+ // memcpy/memmove can have TBAA tags. For memcpy, they apply
+ // to both the source and the destination.
+ MDNode *TBAATag = MTI->getMetadata(LLVMContext::MD_tbaa);
+
+ return Location(MTI->getRawSource(), Size, TBAATag);
}
AliasAnalysis::Location
@@ -228,9 +231,12 @@ AliasAnalysis::getLocationForDest(const MemIntrinsic *MTI) {
uint64_t Size = UnknownSize;
if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
Size = C->getValue().getZExtValue();
+
+ // memcpy/memmove can have TBAA tags. For memcpy, they apply
+ // to both the source and the destination.
+ MDNode *TBAATag = MTI->getMetadata(LLVMContext::MD_tbaa);
- // FIXME: Can memcpy/memmove have TBAA tags?
- return Location(MTI->getRawDest(), Size, 0);
+ return Location(MTI->getRawDest(), Size, TBAATag);
}