Don't be COMPLETELY pessimistic in the face of function calls
authorChris Lattner <sabre@nondot.org>
Mon, 15 Mar 2004 04:08:36 +0000 (04:08 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 15 Mar 2004 04:08:36 +0000 (04:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12413 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/AliasSetTracker.cpp

index 67cef76d57931b864ecb499fc23d793f350d8a18..d266c2a5a07992ecf48363ebb94551edcd883273 100644 (file)
@@ -93,9 +93,21 @@ void AliasSet::addPointer(AliasSetTracker &AST, HashNodePair &Entry,
   RefCount++;               // Entry points to alias set...
 }
 
-void AliasSet::addCallSite(CallSite CS) {
+void AliasSet::addCallSite(CallSite CS, AliasAnalysis &AA) {
   CallSites.push_back(CS);
-  AliasTy = MayAlias;         // FIXME: Too conservative?
+
+  if (Function *F = CS.getCalledFunction()) {
+    if (AA.doesNotAccessMemory(F))
+      return;
+    else if (AA.onlyReadsMemory(F)) {
+      AliasTy = MayAlias;
+      AccessTy = Refs;
+      return;
+    }
+  }
+
+  // FIXME: This should use mod/ref information to make this not suck so bad
+  AliasTy = MayAlias;
   AccessTy = ModRef;
 }
 
@@ -129,7 +141,11 @@ bool AliasSet::aliasesPointer(const Value *Ptr, unsigned Size,
 }
 
 bool AliasSet::aliasesCallSite(CallSite CS, AliasAnalysis &AA) const {
-  // FIXME: Too conservative!
+  // FIXME: Use mod/ref information to prune this better!
+  if (Function *F = CS.getCalledFunction())
+    if (AA.doesNotAccessMemory(F))
+      return false;
+
   return true;
 }
 
@@ -213,7 +229,7 @@ void AliasSetTracker::add(CallSite CS) {
     AliasSets.push_back(AliasSet());
     AS = &AliasSets.back();
   }
-  AS->addCallSite(CS); 
+  AS->addCallSite(CS, AA); 
 }
 
 void AliasSetTracker::add(Instruction *I) {