summaryrefslogtreecommitdiff
path: root/lib/Analysis/AliasSetTracker.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-09-14 19:15:32 +0000
committerChris Lattner <sabre@nondot.org>2004-09-14 19:15:32 +0000
commitb66e648e95a9c2d29c33297b0499b00d31b660c0 (patch)
treebfc48b587561205fe1e22e3f3b0123a31dbd58fb /lib/Analysis/AliasSetTracker.cpp
parente2fe784500ee910536bfc7332eae82ab0fdd1bc7 (diff)
downloadllvm-b66e648e95a9c2d29c33297b0499b00d31b660c0.tar.gz
llvm-b66e648e95a9c2d29c33297b0499b00d31b660c0.tar.bz2
llvm-b66e648e95a9c2d29c33297b0499b00d31b660c0.tar.xz
Implement an AliasSetTracker::copyValue method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16344 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/AliasSetTracker.cpp')
-rw-r--r--lib/Analysis/AliasSetTracker.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp
index e5f7f32f9c..15b4945c59 100644
--- a/lib/Analysis/AliasSetTracker.cpp
+++ b/lib/Analysis/AliasSetTracker.cpp
@@ -67,12 +67,13 @@ void AliasSet::removeFromTracker(AliasSetTracker &AST) {
}
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 @@ bool AliasSetTracker::remove(Instruction *I) {
// 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 @@ void AliasSetTracker::deleteValue(Value *PtrVal) {
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