[llvm-commits] CVS: llvm/include/llvm/Analysis/AliasSetTracker.h
Chris Lattner
lattner at cs.uiuc.edu
Thu Jul 22 00:58:24 PDT 2004
Changes in directory llvm/include/llvm/Analysis:
AliasSetTracker.h updated: 1.15 -> 1.16
---
Log message:
Clean up reference counting to stop "leaking" alias sets
---
Diffs of the changes: (+14 -14)
Index: llvm/include/llvm/Analysis/AliasSetTracker.h
diff -u llvm/include/llvm/Analysis/AliasSetTracker.h:1.15 llvm/include/llvm/Analysis/AliasSetTracker.h:1.16
--- llvm/include/llvm/Analysis/AliasSetTracker.h:1.15 Wed Jul 21 02:03:57 2004
+++ llvm/include/llvm/Analysis/AliasSetTracker.h Thu Jul 22 02:58:14 2004
@@ -62,9 +62,8 @@
if (AS->Forward) {
AliasSet *OldAS = AS;
AS = OldAS->getForwardedTarget(AST);
- if (--OldAS->RefCount == 0)
- OldAS->removeFromTracker(AST);
- AS->RefCount++;
+ AS->addRef();
+ OldAS->dropRef(AST);
}
return AS;
}
@@ -118,6 +117,13 @@
void setPrev(AliasSet *P) { Prev = P; }
void setNext(AliasSet *N) { Next = N; }
+ void addRef() { ++RefCount; }
+ void dropRef(AliasSetTracker &AST) {
+ assert(RefCount >= 1 && "Invalid reference count detected!");
+ if (--RefCount == 0)
+ removeFromTracker(AST);
+ }
+
public:
/// Accessors...
bool isRef() const { return AccessTy & Refs; }
@@ -187,15 +193,10 @@
AliasSet() : PtrList(0), PtrListEnd(&PtrList), Forward(0), RefCount(0),
AccessTy(NoModRef), AliasTy(MustAlias), Volatile(false) {
}
+
AliasSet(const AliasSet &AS) {
- // AliasSet's only get copy constructed in simple circumstances. In
- // particular, they cannot have any pointers in their list. Despite this,
- // we have to be sure to update the PtrListEnd to not point to the source
- // AliasSet's list.
- assert(AS.PtrList == 0 && "AliasSet has pointers in it!");
- PtrList = 0; PtrListEnd = &PtrList;
- Forward = AS.Forward; RefCount = AS.RefCount;
- AccessTy = AS.AccessTy; AliasTy = AS.AliasTy; Volatile = AS.Volatile;
+ assert(0 && "Copy ctor called!?!?!");
+ abort();
}
HashNodePair *getSomePointer() const {
@@ -210,9 +211,8 @@
AliasSet *Dest = Forward->getForwardedTarget(AST);
if (Dest != Forward) {
- Dest->RefCount++;
- if (--Forward->RefCount == 0)
- Forward->removeFromTracker(AST);
+ Dest->addRef();
+ Forward->dropRef(AST);
Forward = Dest;
}
return Dest;
More information about the llvm-commits
mailing list