Changes in directory llvm-poolalloc/include/dsa:
DSGraph.h updated: 1.110 -> 1.110.2.1 DSNode.h updated: 1.58 -> 1.58.2.1 DataStructure.h updated: 1.98 -> 1.98.2.1 --- Log message: Adjusted DSA to build within the llvm-poolalloc project. Merged in the pool inference code. --- Diffs of the changes: (+111 -7) DSGraph.h | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- DSNode.h | 9 ++++- DataStructure.h | 9 ++++- 3 files changed, 111 insertions(+), 7 deletions(-) Index: llvm-poolalloc/include/dsa/DSGraph.h diff -u llvm-poolalloc/include/dsa/DSGraph.h:1.110 llvm-poolalloc/include/dsa/DSGraph.h:1.110.2.1 --- llvm-poolalloc/include/dsa/DSGraph.h:1.110 Wed Feb 22 10:23:42 2006 +++ llvm-poolalloc/include/dsa/DSGraph.h Tue Dec 12 16:42:37 2006 @@ -19,9 +19,13 @@ #include "llvm/ADT/hash_map" #include "llvm/ADT/EquivalenceClasses.h" #include <list> - +#include <map> +#include <iostream> +#define LLVA_KERNEL 1 namespace llvm { + //typedef map<const DSNode *, Value*> PoolDescriptorMapType; + class GlobalValue; //===----------------------------------------------------------------------===// @@ -170,6 +174,62 @@ }; +#ifdef LLVA_KERNEL +class MetaPool; +class MetaPoolHandle { + MetaPool *Rep; + Instruction * Creator; +public: + MetaPoolHandle(MetaPool *mp, Instruction * Maker = 0); + + MetaPool *getMetaPool() { + return Rep; + } + void setMetaPool(MetaPool *v) { + Rep = v; + } + ~MetaPoolHandle() { + //do nothing for now + } + const std::string &getName(); + Value *getMetaPoolValue(); + void merge(MetaPoolHandle *other); +}; + + class MetaPool { + Value *MPD; + hash_set<MetaPoolHandle *> HandleSet; + + public: + MetaPool(Value *mpd) : MPD(mpd) { + } + void addMetaPoolHandles(hash_set<MetaPoolHandle *> & mpHS) { + HandleSet.insert(mpHS.begin(), mpHS.end()); + } + hash_set<MetaPoolHandle *>& getHandleSet() { + return HandleSet; + } + Value * getMetaPoolValue() { + return MPD; + } + void setMetaPoolValue(Value *V) { + MPD = V; + } + void insert(MetaPoolHandle *mph) { + HandleSet.insert(mph); + } + const std::string& getName() { + return MPD->getName(); + } + ~MetaPool() { + HandleSet.clear(); + } + }; + +#endif + + + //===----------------------------------------------------------------------===// /// DSGraph - The graph that represents a function. /// @@ -219,13 +279,18 @@ /// constructed for. const TargetData &TD; +#ifdef LLVA_KERNEL + hash_map<const DSNode*, MetaPoolHandle*> PoolDescriptors; +#endif + + + void operator=(const DSGraph &); // DO NOT IMPLEMENT DSGraph(const DSGraph&); // DO NOT IMPLEMENT public: // Create a new, empty, DSGraph. DSGraph(EquivalenceClasses<GlobalValue*> &ECs, const TargetData &td) - : GlobalsGraph(0), PrintAuxCalls(false), ScalarMap(ECs), TD(td) {} - + : GlobalsGraph(0), PrintAuxCalls(false), ScalarMap(ECs), TD(td) { } // Compute the local DSGraph DSGraph(EquivalenceClasses<GlobalValue*> &ECs, const TargetData &TD, Function &F, DSGraph *GlobalsGraph); @@ -238,13 +303,38 @@ // source. You need to set a new GlobalsGraph with the setGlobalsGraph // method. // - DSGraph(const DSGraph &DSG, EquivalenceClasses<GlobalValue*> &ECs, + DSGraph( DSGraph &DSG, EquivalenceClasses<GlobalValue*> &ECs, unsigned CloneFlags = 0); ~DSGraph(); DSGraph *getGlobalsGraph() const { return GlobalsGraph; } void setGlobalsGraph(DSGraph *G) { GlobalsGraph = G; } +#ifdef LLVA_KERNEL +#if 1 + hash_map<const DSNode *, MetaPoolHandle*>& getPoolDescriptorsMap() { + return PoolDescriptors; + } + MetaPoolHandle *getPoolForNode(const DSNode *N) { + if (PoolDescriptors.count(N) > 0) { + return PoolDescriptors[N]; + } + return 0; + } +#else + hash_map<const DSNodeHandle *, MetaPoolHandle*>& getPoolDescriptorsMap() { + return PoolDescriptors; + } + MetaPoolHandle *getPoolForNode(const DSNodeHandle *N) { + if (PoolDescriptors.count(N) > 0) { + return PoolDescriptors[N]; + } + return 0; + } +#endif + +#endif + /// getGlobalECs - Return the set of equivalence classes that the global /// variables in the program form. EquivalenceClasses<GlobalValue*> &getGlobalECs() const { @@ -469,7 +559,7 @@ /// /// The CloneFlags member controls various aspects of the cloning process. /// - void cloneInto(const DSGraph &G, unsigned CloneFlags = 0); + void cloneInto(DSGraph &G, unsigned CloneFlags = 0); /// getFunctionArgumentsForCall - Given a function that is currently in this /// graph, return the DSNodeHandles that correspond to the pointer-compatible Index: llvm-poolalloc/include/dsa/DSNode.h diff -u llvm-poolalloc/include/dsa/DSNode.h:1.58 llvm-poolalloc/include/dsa/DSNode.h:1.58.2.1 --- llvm-poolalloc/include/dsa/DSNode.h:1.58 Fri May 19 14:07:54 2006 +++ llvm-poolalloc/include/dsa/DSNode.h Tue Dec 12 16:42:37 2006 @@ -91,8 +91,9 @@ Read = 1 << 6, // This node is read in this context Array = 1 << 7, // This node is treated like an array + External = 1 << 8, // This node comes from an external source //#ifndef NDEBUG - DEAD = 1 << 8, // This node is dead and should not be pointed to + DEAD = 1 << 9, // This node is dead and should not be pointed to //#endif Composition = AllocaNode | HeapNode | GlobalNode | UnknownNode @@ -118,10 +119,14 @@ /// DSNode(const DSNode &, DSGraph *G, bool NullLinks = false); +#if 0 ~DSNode() { dropAllReferences(); assert(hasNoReferrers() && "Referrers to dead node exist!"); } +#else + ~DSNode(); +#endif // Iterator for graph interface... Defined in DSGraphTraits.h typedef DSNodeIterator<DSNode> iterator; @@ -340,12 +345,14 @@ bool isIncomplete() const { return NodeType & Incomplete; } bool isComplete() const { return !isIncomplete(); } bool isDeadNode() const { return NodeType & DEAD; } + bool isExternalNode() const { return NodeType & External; } DSNode *setAllocaNodeMarker() { NodeType |= AllocaNode; return this; } DSNode *setHeapNodeMarker() { NodeType |= HeapNode; return this; } DSNode *setGlobalNodeMarker() { NodeType |= GlobalNode; return this; } DSNode *setUnknownNodeMarker() { NodeType |= UnknownNode; return this; } + DSNode *setExternalMarker() { NodeType |= External; return this; } DSNode *setIncompleteMarker() { NodeType |= Incomplete; return this; } DSNode *setModifiedMarker() { NodeType |= Modified; return this; } DSNode *setReadMarker() { NodeType |= Read; return this; } Index: llvm-poolalloc/include/dsa/DataStructure.h diff -u llvm-poolalloc/include/dsa/DataStructure.h:1.98 llvm-poolalloc/include/dsa/DataStructure.h:1.98.2.1 --- llvm-poolalloc/include/dsa/DataStructure.h:1.98 Mon Oct 23 14:52:54 2006 +++ llvm-poolalloc/include/dsa/DataStructure.h Tue Dec 12 16:42:37 2006 @@ -21,6 +21,8 @@ #include "llvm/ADT/hash_set" #include "llvm/ADT/EquivalenceClasses.h" + + namespace llvm { class Type; @@ -30,10 +32,12 @@ class DSCallSite; class DSNode; class DSNodeHandle; +typedef std::map<const DSNode *, Value*> PoolDescriptorMapType; FunctionPass *createDataStructureStatsPass(); FunctionPass *createDataStructureGraphCheckerPass(); +#define LLVA_KERNEL 1 // FIXME: move this stuff to a private header namespace DataStructureAnalysis { @@ -43,7 +47,6 @@ bool isPointerType(const Type *Ty); } - // LocalDataStructures - The analysis that computes the local data structure // graphs for all of the functions in the program. // @@ -55,6 +58,10 @@ hash_map<Function*, DSGraph*> DSInfo; DSGraph *GlobalsGraph; +#ifdef LLVA_KERNEL + Function *AddPoolDescToMetaPool; +#endif + /// GlobalECs - The equivalence classes for each global value that is merged /// with other global values in the DSGraphs. EquivalenceClasses<GlobalValue*> GlobalECs; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits