add "getLocation" method to AliasAnalysis for getting the source and
authorChris Lattner <sabre@nondot.org>
Sun, 21 Nov 2010 07:51:27 +0000 (07:51 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 21 Nov 2010 07:51:27 +0000 (07:51 +0000)
destination location of a memcpy/memmove.  I'm not clear about whether
TBAA works on these, so I'm leaving it out for now.  Dan, please revisit
this when convenient.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119928 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/AliasAnalysis.h
lib/Analysis/AliasAnalysis.cpp

index 5fe9d91776811383fb3a5d7dfb6dddd2d23257cc..007724dd5f7a20ee6264ec6be1dd227f1320f352 100644 (file)
@@ -48,6 +48,7 @@ class VAArgInst;
 class TargetData;
 class Pass;
 class AnalysisUsage;
+class MemTransferInst;
 
 class AliasAnalysis {
 protected:
@@ -135,6 +136,8 @@ public:
   Location getLocation(const LoadInst *LI);
   Location getLocation(const StoreInst *SI);
   Location getLocation(const VAArgInst *VI);
+  Location getLocationForSource(const MemTransferInst *MTI);
+  Location getLocationForDest(const MemTransferInst *MTI);
 
   /// Alias analysis result - Either we know for sure that it does not alias, we
   /// know for sure it must alias, or we don't know anything: The two pointers
index 94a6d41872cf40adf8fb70be482144f177e37d12..f452c9e67661b776588de7cc49facfa910e86472 100644 (file)
@@ -212,6 +212,29 @@ AliasAnalysis::Location AliasAnalysis::getLocation(const VAArgInst *VI) {
                   VI->getMetadata(LLVMContext::MD_tbaa));
 }
 
+
+AliasAnalysis::Location 
+AliasAnalysis::getLocationForSource(const MemTransferInst *MTI) {
+  uint64_t Size = UnknownSize;
+  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);
+}
+
+AliasAnalysis::Location 
+AliasAnalysis::getLocationForDest(const MemTransferInst *MTI) {
+  uint64_t Size = UnknownSize;
+  if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
+    Size = C->getValue().getZExtValue();
+  
+  // FIXME: Can memcpy/memmove have TBAA tags?
+  return Location(MTI->getRawDest(), Size, 0);
+}
+
+
+
 AliasAnalysis::ModRefResult
 AliasAnalysis::getModRefInfo(const LoadInst *L, const Location &Loc) {
   // Be conservative in the face of volatile.