diff options
author | Dan Gohman <gohman@apple.com> | 2009-07-30 20:21:41 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-07-30 20:21:41 +0000 |
commit | b5b56ba9d4df47e618d4e0f9e1e09bf216733ee8 (patch) | |
tree | 51b88036976afa291af99dbf4ea8e5a0fc68fd05 /include/llvm/Analysis/AliasSetTracker.h | |
parent | d8c95b5ac2ae0619c22434dbdd993196ea82489b (diff) | |
download | llvm-b5b56ba9d4df47e618d4e0f9e1e09bf216733ee8.tar.gz llvm-b5b56ba9d4df47e618d4e0f9e1e09bf216733ee8.tar.bz2 llvm-b5b56ba9d4df47e618d4e0f9e1e09bf216733ee8.tar.xz |
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 'include/llvm/Analysis/AliasSetTracker.h')
-rw-r--r-- | include/llvm/Analysis/AliasSetTracker.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/include/llvm/Analysis/AliasSetTracker.h b/include/llvm/Analysis/AliasSetTracker.h index 0a9e278b4d..99d7ce80e5 100644 --- a/include/llvm/Analysis/AliasSetTracker.h +++ b/include/llvm/Analysis/AliasSetTracker.h @@ -18,6 +18,7 @@ #define LLVM_ANALYSIS_ALIASSETTRACKER_H #include "llvm/Support/CallSite.h" +#include "llvm/Support/ValueHandle.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/ilist.h" @@ -251,11 +252,24 @@ inline std::ostream& operator<<(std::ostream &OS, const AliasSet &AS) { class AliasSetTracker { + /// CallbackVH - A CallbackVH to arrange for AliasSetTracker to be + /// notified whenever a Value is deleted. + class ASTCallbackVH : public CallbackVH { + AliasSetTracker *AST; + virtual void deleted(); + public: + ASTCallbackVH(Value *V, AliasSetTracker *AST = 0); + }; + AliasAnalysis &AA; ilist<AliasSet> AliasSets; + typedef DenseMap<ASTCallbackVH, AliasSet::PointerRec*, DenseMapInfo<Value*> > + PointerMapType; + // Map from pointers to their node - DenseMap<Value*, AliasSet::PointerRec*> PointerMap; + PointerMapType PointerMap; + public: /// AliasSetTracker ctor - Create an empty collection of AliasSets, and use /// the specified alias analysis object to disambiguate load and store @@ -364,7 +378,7 @@ private: // getEntryFor - Just like operator[] on the map, except that it creates an // entry for the pointer if it doesn't already exist. AliasSet::PointerRec &getEntryFor(Value *V) { - AliasSet::PointerRec *&Entry = PointerMap[V]; + AliasSet::PointerRec *&Entry = PointerMap[ASTCallbackVH(V, this)]; if (Entry == 0) Entry = new AliasSet::PointerRec(V); return *Entry; |