[llvm-commits] CVS: llvm/lib/Analysis/AliasSetTracker.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Sep 14 12:15:43 PDT 2004



Changes in directory llvm/lib/Analysis:

AliasSetTracker.cpp updated: 1.26 -> 1.27
---
Log message:

Implement an AliasSetTracker::copyValue method


---
Diffs of the changes:  (+30 -3)

Index: llvm/lib/Analysis/AliasSetTracker.cpp
diff -u llvm/lib/Analysis/AliasSetTracker.cpp:1.26 llvm/lib/Analysis/AliasSetTracker.cpp:1.27
--- llvm/lib/Analysis/AliasSetTracker.cpp:1.26	Thu Jul 29 12:14:54 2004
+++ llvm/lib/Analysis/AliasSetTracker.cpp	Tue Sep 14 14:15:32 2004
@@ -67,12 +67,13 @@
 }
 
 void AliasSet::addPointer(AliasSetTracker &AST, HashNodePair &Entry,
-                          unsigned Size) {
+                          unsigned Size, bool KnownMustAlias) {
   assert(!Entry.second.hasAliasSet() && "Entry already in set!");
 
   AliasAnalysis &AA = AST.getAliasAnalysis();
 
-  if (isMustAlias())    // Check to see if we have to downgrade to _may_ alias
+  // Check to see if we have to downgrade to _may_ alias.
+  if (isMustAlias() && !KnownMustAlias)
     if (HashNodePair *P = getSomePointer()) {
       AliasAnalysis::AliasResult Result =
         AA.alias(P->first, P->second.getSize(), Entry.first, Size);
@@ -400,7 +401,10 @@
 // dangling pointers to deleted instructions.
 //
 void AliasSetTracker::deleteValue(Value *PtrVal) {
-  // First, look up the PointerRec for this pointer...
+  // Notify the alias analysis implementation that this value is gone.
+  AA.deleteValue(PtrVal);
+
+  // First, look up the PointerRec for this pointer.
   hash_map<Value*, AliasSet::PointerRec>::iterator I = PointerMap.find(PtrVal);
   if (I == PointerMap.end()) return;  // Noop
 
@@ -415,6 +419,29 @@
   PointerMap.erase(I);
 }
 
+// copyValue - This method should be used whenever a preexisting value in the
+// program is copied or cloned, introducing a new value.  Note that it is ok for
+// clients that use this method to introduce the same value multiple times: if
+// the tracker already knows about a value, it will ignore the request.
+//
+void AliasSetTracker::copyValue(Value *From, Value *To) {
+  // Notify the alias analysis implementation that this value is copied.
+  AA.copyValue(From, To);
+
+  // First, look up the PointerRec for this pointer.
+  hash_map<Value*, AliasSet::PointerRec>::iterator I = PointerMap.find(From);
+  if (I == PointerMap.end() || !I->second.hasAliasSet())
+    return;  // Noop
+
+  AliasSet::HashNodePair &Entry = getEntryFor(To);
+  if (Entry.second.hasAliasSet()) return;    // Already in the tracker!
+
+  // Add it to the alias set it aliases...
+  AliasSet *AS = I->second.getAliasSet(*this);
+  AS->addPointer(*this, Entry, I->second.getSize(), true);
+}
+
+
 
 //===----------------------------------------------------------------------===//
 //               AliasSet/AliasSetTracker Printing Support






More information about the llvm-commits mailing list