summaryrefslogtreecommitdiff
path: root/lib/Analysis/AliasSetTracker.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-22 07:58:18 +0000
committerChris Lattner <sabre@nondot.org>2004-07-22 07:58:18 +0000
commitb8a31ace2c49af703cf7b1f1bda408a361f53447 (patch)
tree83465e9feea0ed547a1d14382a13c933cec54cc3 /lib/Analysis/AliasSetTracker.cpp
parent199edde70774ecb69922230fcde65acc51c21d89 (diff)
downloadllvm-b8a31ace2c49af703cf7b1f1bda408a361f53447.tar.gz
llvm-b8a31ace2c49af703cf7b1f1bda408a361f53447.tar.bz2
llvm-b8a31ace2c49af703cf7b1f1bda408a361f53447.tar.xz
Clean up reference counting to stop "leaking" alias sets
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15099 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/AliasSetTracker.cpp')
-rw-r--r--lib/Analysis/AliasSetTracker.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp
index d6a6ecad8a..efb3184bd5 100644
--- a/lib/Analysis/AliasSetTracker.cpp
+++ b/lib/Analysis/AliasSetTracker.cpp
@@ -45,7 +45,7 @@ void AliasSet::mergeSetIn(AliasSet &AS) {
assert(RefCount != 0);
AS.Forward = this; // Forward across AS now...
- RefCount++; // AS is now pointing to us...
+ addRef(); // AS is now pointing to us...
// Merge the list of constituent pointers...
if (AS.PtrList) {
@@ -59,6 +59,10 @@ void AliasSet::mergeSetIn(AliasSet &AS) {
}
void AliasSetTracker::removeAliasSet(AliasSet *AS) {
+ if (AliasSet *Fwd = AS->Forward) {
+ Fwd->dropRef(*this);
+ AS->Forward = 0;
+ }
AliasSets.erase(AS);
}
@@ -91,7 +95,7 @@ void AliasSet::addPointer(AliasSetTracker &AST, HashNodePair &Entry,
assert(*PtrListEnd == 0 && "End of list is not null?");
*PtrListEnd = &Entry;
PtrListEnd = Entry.second.setPrevInList(PtrListEnd);
- RefCount++; // Entry points to alias set...
+ addRef(); // Entry points to alias set...
}
void AliasSet::addCallSite(CallSite CS, AliasAnalysis &AA) {
@@ -130,7 +134,7 @@ bool AliasSet::aliasesPointer(const Value *Ptr, unsigned Size,
// If this is a may-alias set, we have to check all of the pointers in the set
// to be sure it doesn't alias the set...
for (iterator I = begin(), E = end(); I != E; ++I)
- if (AA.alias(Ptr, Size, I->first, I->second.getSize()))
+ if (AA.alias(Ptr, Size, I.getPointer(), I.getSize()))
return true;
// Check the call sites list and invoke list...
@@ -204,7 +208,7 @@ AliasSet &AliasSetTracker::getAliasSetForPointer(Value *Pointer, unsigned Size,
} else {
if (New) *New = true;
// Otherwise create a new alias set to hold the loaded pointer...
- AliasSets.push_back(AliasSet());
+ AliasSets.push_back(new AliasSet());
AliasSets.back().addPointer(*this, Entry, Size);
return AliasSets.back();
}
@@ -238,7 +242,7 @@ bool AliasSetTracker::add(CallSite CS) {
AliasSet *AS = findAliasSetForCallSite(CS);
if (!AS) {
- AliasSets.push_back(AliasSet());
+ AliasSets.push_back(new AliasSet());
AS = &AliasSets.back();
AS->addCallSite(CS, AA);
return true;
@@ -285,7 +289,7 @@ void AliasSetTracker::add(const AliasSetTracker &AST) {
AliasSet::iterator I = AS.begin(), E = AS.end();
bool X;
for (; I != E; ++I)
- addPointer(I->first, I->second.getSize(),
+ addPointer(I.getPointer(), I.getSize(),
(AliasSet::AccessType)AS.AccessTy, X);
}
}
@@ -364,9 +368,7 @@ void AliasSetTracker::deleteValue(Value *PtrVal) {
// Unlink from the list of values...
PtrValEnt.second.removeFromList();
// Stop using the alias set
- if (--AS->RefCount == 0)
- AS->removeFromTracker(*this);
-
+ AS->dropRef(*this);
PointerMap.erase(I);
}
@@ -394,8 +396,8 @@ void AliasSet::print(std::ostream &OS) const {
OS << "Pointers: ";
for (iterator I = begin(), E = end(); I != E; ++I) {
if (I != begin()) OS << ", ";
- WriteAsOperand(OS << "(", I->first);
- OS << ", " << I->second.getSize() << ")";
+ WriteAsOperand(OS << "(", I.getPointer());
+ OS << ", " << I.getSize() << ")";
}
}
if (!CallSites.empty()) {