aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/AliasSetTracker.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-30 20:21:41 +0000
committerDan Gohman <gohman@apple.com>2009-07-30 20:21:41 +0000
commitb5b56ba9d4df47e618d4e0f9e1e09bf216733ee8 (patch)
tree51b88036976afa291af99dbf4ea8e5a0fc68fd05 /lib/Analysis/AliasSetTracker.cpp
parentd8c95b5ac2ae0619c22434dbdd993196ea82489b (diff)
Use CallbackVH in AliasSetTracker to avoid getting stuck with
dangling Value*s. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77623 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/AliasSetTracker.cpp')
-rw-r--r--lib/Analysis/AliasSetTracker.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp
index 841cd2be3b..9f201c322d 100644
--- a/lib/Analysis/AliasSetTracker.cpp
+++ b/lib/Analysis/AliasSetTracker.cpp
@@ -187,8 +187,8 @@ bool AliasSet::aliasesCallSite(CallSite CS, AliasAnalysis &AA) const {
void AliasSetTracker::clear() {
// Delete all the PointerRec entries.
- for (DenseMap<Value*, AliasSet::PointerRec*>::iterator I = PointerMap.begin(),
- E = PointerMap.end(); I != E; ++I)
+ for (PointerMapType::iterator I = PointerMap.begin(), E = PointerMap.end();
+ I != E; ++I)
I->second->eraseFromList();
PointerMap.clear();
@@ -485,7 +485,7 @@ void AliasSetTracker::deleteValue(Value *PtrVal) {
AS->removeCallSite(CS);
// First, look up the PointerRec for this pointer.
- DenseMap<Value*, AliasSet::PointerRec*>::iterator I = PointerMap.find(PtrVal);
+ PointerMapType::iterator I = PointerMap.find(PtrVal);
if (I == PointerMap.end()) return; // Noop
// If we found one, remove the pointer from the alias set it is in.
@@ -511,7 +511,7 @@ void AliasSetTracker::copyValue(Value *From, Value *To) {
AA.copyValue(From, To);
// First, look up the PointerRec for this pointer.
- DenseMap<Value*, AliasSet::PointerRec*>::iterator I = PointerMap.find(From);
+ PointerMapType::iterator I = PointerMap.find(From);
if (I == PointerMap.end())
return; // Noop
assert(I->second->hasAliasSet() && "Dead entry?");
@@ -576,6 +576,22 @@ void AliasSet::dump() const { print (cerr); }
void AliasSetTracker::dump() const { print(cerr); }
//===----------------------------------------------------------------------===//
+// ASTCallbackVH Class Implementation
+//===----------------------------------------------------------------------===//
+
+void AliasSetTracker::ASTCallbackVH::deleted() {
+ assert(AST && "ASTCallbackVH called with a null AliasSetTracker!");
+ AST->deleteValue(getValPtr());
+ // this now dangles!
+}
+
+AliasSetTracker::ASTCallbackVH::ASTCallbackVH(Value *V, AliasSetTracker *ast)
+ : CallbackVH(V == DenseMapInfo<Value *>::getEmptyKey() ? 0 :
+ V == DenseMapInfo<Value *>::getTombstoneKey() ? 0 :
+ V),
+ AST(ast) {}
+
+//===----------------------------------------------------------------------===//
// AliasSetPrinter Pass
//===----------------------------------------------------------------------===//