[llvm-commits] CVS: llvm-poolalloc/lib/DSA/BottomUpClosure.cpp CallTargets.cpp CompleteBottomUp.cpp DataStructure.cpp DataStructureAA.cpp DataStructureOpt.cpp DataStructureStats.cpp EquivClassGraphs.cpp GraphChecker.cpp Local.cpp Makefile Printer.cpp Steensgaard.cpp TopDownClosure.cpp

John Criswell criswell at cs.uiuc.edu
Wed Dec 13 21:51:55 PST 2006



Changes in directory llvm-poolalloc/lib/DSA:

BottomUpClosure.cpp updated: 1.127 -> 1.128
CallTargets.cpp updated: 1.7 -> 1.8
CompleteBottomUp.cpp updated: 1.39 -> 1.40
DataStructure.cpp updated: 1.255 -> 1.256
DataStructureAA.cpp updated: 1.40 -> 1.41
DataStructureOpt.cpp updated: 1.14 -> 1.15
DataStructureStats.cpp updated: 1.24 -> 1.25
EquivClassGraphs.cpp updated: 1.53 -> 1.54
GraphChecker.cpp updated: 1.23 -> 1.24
Local.cpp updated: 1.163 -> 1.164
Makefile updated: 1.5 -> 1.6
Printer.cpp updated: 1.91 -> 1.92
Steensgaard.cpp updated: 1.67 -> 1.68
TopDownClosure.cpp updated: 1.95 -> 1.96
---
Log message:

Merged from release_19 branch.
This adds correct compilation of DSA, pool inference, and configure script
fixes to mainline.



---
Diffs of the changes:  (+708 -62)

 BottomUpClosure.cpp    |   14 -
 CallTargets.cpp        |    6 
 CompleteBottomUp.cpp   |    4 
 DataStructure.cpp      |  249 ++++++++++++++++++++++++++
 DataStructureAA.cpp    |    4 
 DataStructureOpt.cpp   |    4 
 DataStructureStats.cpp |    4 
 EquivClassGraphs.cpp   |    4 
 GraphChecker.cpp       |    4 
 Local.cpp              |  456 ++++++++++++++++++++++++++++++++++++++++++++++---
 Makefile               |    4 
 Printer.cpp            |    6 
 Steensgaard.cpp        |    5 
 TopDownClosure.cpp     |    6 
 14 files changed, 708 insertions(+), 62 deletions(-)


Index: llvm-poolalloc/lib/DSA/BottomUpClosure.cpp
diff -u llvm-poolalloc/lib/DSA/BottomUpClosure.cpp:1.127 llvm-poolalloc/lib/DSA/BottomUpClosure.cpp:1.128
--- llvm-poolalloc/lib/DSA/BottomUpClosure.cpp:1.127	Wed Dec  6 19:30:31 2006
+++ llvm-poolalloc/lib/DSA/BottomUpClosure.cpp	Wed Dec 13 23:51:06 2006
@@ -15,8 +15,8 @@
 //===----------------------------------------------------------------------===//
 
 #define DEBUG_TYPE "bu_dsa"
-#include "llvm/Analysis/DataStructure/DataStructure.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "dsa/DataStructure.h"
+#include "dsa/DSGraph.h"
 #include "llvm/Module.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/ADT/Statistic.h"
@@ -588,11 +588,11 @@
         ++NumBUInlines;
       } else {
         if (!Printed)
-          cerr << "In Fns: " << Graph.getFunctionNames() << "\n";
-        cerr << "  calls " << CalledFuncs.size()
-             << " fns from site: " << CS.getCallSite().getInstruction()
-             << "  " << *CS.getCallSite().getInstruction();
-        cerr << "   Fns =";
+          DEBUG(std::cerr << "In Fns: " << Graph.getFunctionNames() << "\n");
+          DEBUG(std::cerr << "  calls " << CalledFuncs.size()
+                  << " fns from site: " << CS.getCallSite().getInstruction()
+                  << "  " << *CS.getCallSite().getInstruction());
+        DEBUG(std::cerr << "   Fns =");
         unsigned NumPrinted = 0;
 
         for (std::vector<Function*>::iterator I = CalledFuncs.begin(),


Index: llvm-poolalloc/lib/DSA/CallTargets.cpp
diff -u llvm-poolalloc/lib/DSA/CallTargets.cpp:1.7 llvm-poolalloc/lib/DSA/CallTargets.cpp:1.8
--- llvm-poolalloc/lib/DSA/CallTargets.cpp:1.7	Wed Dec  6 19:30:31 2006
+++ llvm-poolalloc/lib/DSA/CallTargets.cpp	Wed Dec 13 23:51:06 2006
@@ -17,11 +17,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/DataStructure/CallTargets.h"
 #include "llvm/Module.h"
 #include "llvm/Instructions.h"
-#include "llvm/Analysis/DataStructure/DataStructure.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "dsa/DataStructure.h"
+#include "dsa/DSGraph.h"
+#include "dsa/CallTargets.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/Constants.h"


Index: llvm-poolalloc/lib/DSA/CompleteBottomUp.cpp
diff -u llvm-poolalloc/lib/DSA/CompleteBottomUp.cpp:1.39 llvm-poolalloc/lib/DSA/CompleteBottomUp.cpp:1.40
--- llvm-poolalloc/lib/DSA/CompleteBottomUp.cpp:1.39	Wed Dec  6 11:46:31 2006
+++ llvm-poolalloc/lib/DSA/CompleteBottomUp.cpp	Wed Dec 13 23:51:06 2006
@@ -14,9 +14,9 @@
 //===----------------------------------------------------------------------===//
 
 #define DEBUG_TYPE "cbudatastructure"
-#include "llvm/Analysis/DataStructure/DataStructure.h"
+#include "dsa/DataStructure.h"
 #include "llvm/Module.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "dsa/DSGraph.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/ADT/SCCIterator.h"
 #include "llvm/ADT/Statistic.h"


Index: llvm-poolalloc/lib/DSA/DataStructure.cpp
diff -u llvm-poolalloc/lib/DSA/DataStructure.cpp:1.255 llvm-poolalloc/lib/DSA/DataStructure.cpp:1.256
--- llvm-poolalloc/lib/DSA/DataStructure.cpp:1.255	Thu Dec  7 14:28:15 2006
+++ llvm-poolalloc/lib/DSA/DataStructure.cpp	Wed Dec 13 23:51:06 2006
@@ -1,3 +1,4 @@
+#define JTC 0
 //===- DataStructure.cpp - Implement the core data structure analysis -----===//
 //
 //                     The LLVM Compiler Infrastructure
@@ -11,7 +12,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/DataStructure/DSGraphTraits.h"
+#include "dsa/DSGraphTraits.h"
+#include "dsa/DataStructure.h"
+#include "dsa/DSGraph.h"
 #include "llvm/Constants.h"
 #include "llvm/Function.h"
 #include "llvm/GlobalVariable.h"
@@ -26,11 +29,14 @@
 #include "llvm/ADT/SCCIterator.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Timer.h"
+#include "llvm/ADT/hash_map"
+#include "poolalloc/Config/config.h"
+
+#include <iostream>
 #include <algorithm>
 using namespace llvm;
 
 #define COLLAPSE_ARRAYS_AGGRESSIVELY 0
-
 namespace {
   Statistic NumFolds          ("dsa", "Number of nodes completely folded");
   Statistic NumCallNodesMerged("dsa", "Number of call nodes merged");
@@ -38,6 +44,9 @@
   Statistic NumDNE            ("dsa", "Number of nodes removed by reachability");
   Statistic NumTrivialDNE     ("dsa", "Number of nodes trivially removed");
   Statistic NumTrivialGlobalDNE("dsa", "Number of globals trivially removed");
+#ifdef LLVA_KERNEL
+  Statistic LostPools         ("dsa", "Number of pools lost to DSNode Merge");
+#endif
   static cl::opt<unsigned>
   DSAFieldLimit("dsa-field-limit", cl::Hidden,
                 cl::desc("Number of fields to track before collapsing a node"),
@@ -128,6 +137,9 @@
   if (T) mergeTypeInfo(T, 0);
   if (G) G->addNode(this);
   ++NumNodeAllocated;
+#if JTC
+std::cerr << "LLVA: Creating (1) DSNode " << this << "\n";
+#endif
 }
 
 // DSNode copy constructor... do not copy over the referrers list!
@@ -140,6 +152,27 @@
     Links.resize(N.Links.size()); // Create the appropriate number of null links
   G->addNode(this);
   ++NumNodeAllocated;
+#if JTC
+std::cerr << "LLVA: Creating (2) DSNode " << this << "\n";
+#endif
+}
+
+DSNode::~DSNode() {
+  dropAllReferences();
+  assert(hasNoReferrers() && "Referrers to dead node exist!");
+
+#ifdef LLVA_KERNEL
+  //
+  // Remove all references to this node from the Pool Descriptor Map.
+  //
+#if JTC
+  std::cerr << "LLVA: Removing " << this << "\n";
+#endif
+  if (ParentGraph) {
+    hash_map<const DSNode *, MetaPoolHandle*> &pdm=ParentGraph->getPoolDescriptorsMap();
+    pdm.erase (this);
+  }
+#endif
 }
 
 /// getTargetData - Get the target data object used to construct this node.
@@ -235,10 +268,26 @@
     DestNode->Ty = Type::VoidTy;
     DestNode->Size = 1;
     DestNode->Globals.swap(Globals);
+    
+#if JTC
+    std::cerr << "LLVA: foldNode: " << this << " becomes " << DestNode << "\n";
+#endif
+#ifdef LLVA_KERNEL
+    //Again we have created a new DSNode, we need to fill in the
+    // pool desc map appropriately
+    assert(ParentGraph && "parent graph is not null \n"); 
+    hash_map<const DSNode *, MetaPoolHandle*> &pdm = ParentGraph->getPoolDescriptorsMap();
+    if (pdm.count(this) > 0) {
+      pdm[DestNode] = pdm[this];
+    } else {
+      //do nothing 
+    }
+#endif    
 
     // Start forwarding to the destination node...
     forwardNode(DestNode, 0);
 
+
     if (!Links.empty()) {
       DestNode->Links.reserve(1);
 
@@ -833,7 +882,62 @@
     }
 #endif
   }
-
+#ifdef LLVA_KERNEL
+  DSNode *currNode  = CurNodeH.getNode();
+  DSNode *NNode  = NH.getNode();
+  DSGraph *pGraph =  currNode->getParentGraph();
+  assert((pGraph == NNode->getParentGraph()) && "LLVA_KERNEL : merging nodes in two different graphs?");
+  //get the pooldescriptor map
+  hash_map<const DSNode *, MetaPoolHandle*> &pdm = pGraph->getPoolDescriptorsMap();
+  if (pdm.count(currNode) == 0) {
+    if (pdm.count(NNode) == 0) {
+      //do nothing  (common case)
+    } else {
+      if (pdm[NNode]) {
+#if JTC
+	std::cerr << "LLVA: 1: currNode (" << currNode << ") becomes " << pdm[NNode]->getName() << "(" << NNode << ")\n";
+#endif
+	pdm[currNode] = pdm[NNode];
+      }
+    }
+  } else {
+    if (pdm.count(NNode) == 0) {
+#if 1
+      //
+      // FIXME:
+      //  Verify that this is correct.  I believe it is; it seems to make sense
+      //  since either node can be used after the merge.
+      //
+#if JTC
+std::cerr << "LLVA: MergeNodes: currnode has something, newnode has nothing\n";
+	std::cerr << "LLVA: 2: currNode (" << currNode << ") becomes <no name>" << "(" << NNode << ")\n";
+#endif
+      pdm[NNode] = pdm[currNode];
+#endif
+      //do nothing 
+    } else {
+      if (pdm[currNode] != pdm[NNode]) {
+	//The following is commented because pdm[..] could be null!
+	//std::cerr << "LLVA: OldPool: " << pdm[currNode]->getName() << "("
+        //                       << pdm[currNode] << ") "
+	//          << " NewPool: "      << pdm[NNode]->getName() << "("
+	//                               << pdm[NNode] << ")" << std::endl;
+        pdm[NNode]->merge(pdm[currNode]);
+        /*
+        Value *currN = pdm[currNode]->getMetaPoolValue();
+        Value *NN = pdm[NNode]->getMetaPoolValue();
+        if (currN != NN) {
+          std::cerr << "LLVA: Two Pools for one DSNode\n";
+          currN->replaceAllUsesWith(NN);
+          pdm[currNode]->merge(pdm[NNode]);
+        } else {
+          //The nodes are same
+        }
+        */
+      }
+    }
+  }
+#endif  
   // Merge the type entries of the two nodes together...
   if (NH.getNode()->Ty != Type::VoidTy)
     CurNodeH.getNode()->mergeTypeInfo(NH.getNode()->Ty, NOffset);
@@ -912,6 +1016,9 @@
 /// point to this node).
 ///
 void DSNode::mergeWith(const DSNodeHandle &NH, unsigned Offset) {
+#if JTC
+std::cerr << "LLVA: mergeWith: " << this << " becomes " << NH.getNode() << "\n";
+#endif
   DSNode *N = NH.getNode();
   if (N == this && NH.getOffset() == Offset)
     return;  // Noop
@@ -991,6 +1098,21 @@
   DSNode *DN = new DSNode(*SN, &Dest, true /* Null out all links */);
   DN->maskNodeTypes(BitsToKeep);
   NH = DN;
+#if JTC
+std::cerr << "LLVA: getClonedNH: " << SN << " becomes " << DN << "\n";
+#endif
+#if 1
+#ifdef LLVA_KERNEL
+    //Again we have created a new DSNode, we need to fill in the
+    // pool desc map appropriately
+    hash_map<const DSNode *, MetaPoolHandle*> &pdm = Dest.getPoolDescriptorsMap();
+    if (pdm.count(SN) > 0) {
+      pdm[DN] = pdm[SN];
+    } else {
+      //do nothing 
+    }
+#endif    
+#endif
 
   // Next, recursively clone all outgoing links as necessary.  Note that
   // adding these links can cause the node to collapse itself at any time, and
@@ -1149,7 +1271,58 @@
     }
   }
 
+#if JTC
+std::cerr << "LLVA: mergeWith: " << SN << " becomes " << DN << "\n";
+#endif
 
+#ifdef LLVA_KERNEL
+  //Here some merge is going on just like in DSNode::merge
+  //I think because of the inplace merging we don't update the pool desc maps
+  //This is modification from DSNode::MergeNodes
+  //Here DN and SN may belong to different graphs
+ DN = NH.getNode(); 
+#if 0
+  DSGraph *destGraph =  DN->getParentGraph();
+  DSGraph *srcGraph =  SN->getParentGraph();
+#else
+  DSGraph *destGraph = NH.getNode()->getParentGraph();
+  DSGraph *srcGraph =  SN->getParentGraph();
+#endif
+  if (destGraph && srcGraph) {
+    //get the pooldescriptor map
+    hash_map<const DSNode *, MetaPoolHandle*> &destpdm = destGraph->getPoolDescriptorsMap();
+    hash_map<const DSNode *, MetaPoolHandle*> &srcpdm = srcGraph->getPoolDescriptorsMap();
+    if (destpdm.count(DN) == 0) {
+      if (srcpdm.count(SN) == 0) {
+        //do nothing  (common case)
+      } else {
+        if (srcpdm[SN]) {
+#if JTC
+          std::cerr << "LLVA: DN becomes " << srcpdm[SN]->getName() << std::endl;
+#endif
+          destpdm[DN] = srcpdm[SN];
+        }
+      }
+    } else {
+      if (srcpdm.count(SN) == 0) {
+        srcpdm[SN] = destpdm[DN];
+      } else {
+        if (destpdm[DN] != srcpdm[SN]) {
+          srcpdm[SN]->merge(destpdm[DN]);
+          /*
+          Value *dnv = destpdm[DN]->getMetaPoolValue();
+          Value *snv = srcpdm[SN]->getMetaPoolValue();
+          if (dnv != snv) {
+            DEBUG(std::cerr << "LLVA: Two Pools for one DSNode\n");
+            dnv->replaceAllUsesWith(snv);
+            destpdm[DN]->setMetaPoolValue(snv);
+          }
+          */
+        }
+      }
+    }
+  }
+#endif  
   // Next, recursively merge all outgoing links as necessary.  Note that
   // adding these links can cause the destination node to collapse itself at
   // any time, and the current node may be merged with arbitrary other nodes.
@@ -1218,6 +1391,53 @@
   NH = RC.getClonedNH(Src);
 }
 
+#ifdef LLVA_KERNEL
+// MetaPoolHandle Implementation
+  //The following should go in a cpp file later
+   MetaPoolHandle::MetaPoolHandle(MetaPool *mp, Instruction * Maker) {
+    Rep = mp;
+    Rep->insert(this);
+    Creator = Maker;
+  }
+  const std::string& MetaPoolHandle::getName() {
+    assert(Rep != 0 && "Null meta pool ??\n");
+    return Rep->getName();
+  }
+  Value *MetaPoolHandle::getMetaPoolValue() {
+    assert(Rep != 0 && "Null meta pool ??\n");
+    return Rep->getMetaPoolValue();
+  }
+  void MetaPoolHandle::merge(MetaPoolHandle *other) {
+    //after this operation other points to what this points to .
+    //first replace all uses 
+     Value *dest = getMetaPoolValue();
+     Value *curr = other->getMetaPoolValue();
+     if (dest != curr) {
+       std::cerr << "LLVA: Merging metapools: " << this->Creator->getParent()->getParent()->getName() << " : " << other->Creator->getParent()->getParent()->getName() << "\n"
+                 << "LLVA:   " << *(this->Creator) << "\n"
+                 << "LLVA:   " << *(other->Creator) << "\n";
+       curr->replaceAllUsesWith(dest);
+     }
+   
+     //merge the hash sets in to other
+     hash_set<MetaPoolHandle *> &otherHandleSet = other->getMetaPool()->getHandleSet();
+     hash_set<MetaPoolHandle *>::iterator ohsI = otherHandleSet.begin(), ohsE = otherHandleSet.end();
+     for (; ohsI != ohsE; ++ohsI) {
+     MetaPoolHandle *omph = *ohsI;
+     //now make sure that this omph points to what we point to
+     omph->setMetaPool(Rep);
+     Rep->insert(omph);
+     }
+
+     //now delete others MetaPool
+     //gd     delete other->getMetaPool(); 
+
+     //Assign our metapool to other 
+     other->setMetaPool(Rep);
+}
+
+#endif
+
 //===----------------------------------------------------------------------===//
 // DSGraph Implementation
 //===----------------------------------------------------------------------===//
@@ -1239,7 +1459,7 @@
 }
 
 
-DSGraph::DSGraph(const DSGraph &G, EquivalenceClasses<GlobalValue*> &ECs,
+DSGraph::DSGraph(DSGraph &G, EquivalenceClasses<GlobalValue*> &ECs,
                  unsigned CloneFlags)
   : GlobalsGraph(0), ScalarMap(ECs), TD(G.TD) {
   PrintAuxCalls = false;
@@ -1251,7 +1471,9 @@
   AuxFunctionCalls.clear();
   ScalarMap.clear();
   ReturnNodes.clear();
-
+#ifdef LLVA_KERNEL
+  PoolDescriptors.clear();
+#endif  
   // Drop all intra-node references, so that assertions don't fail...
   for (node_iterator NI = node_begin(), E = node_end(); NI != E; ++NI)
     NI->dropAllReferences();
@@ -1309,7 +1531,7 @@
 ///
 /// The CloneFlags member controls various aspects of the cloning process.
 ///
-void DSGraph::cloneInto(const DSGraph &G, unsigned CloneFlags) {
+void DSGraph::cloneInto( DSGraph &G, unsigned CloneFlags) {
   TIME_REGION(X, "cloneInto");
   assert(&G != this && "Cannot clone graph into itself!");
 
@@ -1327,6 +1549,10 @@
     DSNode *New = new DSNode(*I, this);
     New->maskNodeTypes(~BitsToClear);
     OldNodeMap[I] = New;
+#ifdef LLVA_KERNEL
+    if (G.getPoolForNode(&*I)) 
+      PoolDescriptors[New] = G.getPoolForNode(&*I);
+#endif    
   }
 
 #ifndef NDEBUG
@@ -1404,6 +1630,17 @@
 
   // Merge the scalar map in.
   ScalarMap.spliceFrom(RHS.ScalarMap);
+
+#ifdef LLVA_KERNEL
+  //Take all from the pooldescriptor map
+#if 0
+  PoolDescriptors.swap(RHS.getPoolDescriptorsMap());
+#else
+  hash_map<const DSNode *, MetaPoolHandle*>& rhsmap = RHS.getPoolDescriptorsMap();
+  PoolDescriptors.insert(rhsmap.begin(), rhsmap.end());
+#endif
+  RHS.getPoolDescriptorsMap().clear();
+#endif  
 }
 
 /// spliceFrom - Copy all entries from RHS, then clear RHS.


Index: llvm-poolalloc/lib/DSA/DataStructureAA.cpp
diff -u llvm-poolalloc/lib/DSA/DataStructureAA.cpp:1.40 llvm-poolalloc/lib/DSA/DataStructureAA.cpp:1.41
--- llvm-poolalloc/lib/DSA/DataStructureAA.cpp:1.40	Sun Aug 27 19:42:29 2006
+++ llvm-poolalloc/lib/DSA/DataStructureAA.cpp	Wed Dec 13 23:51:06 2006
@@ -17,8 +17,8 @@
 #include "llvm/Module.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/Passes.h"
-#include "llvm/Analysis/DataStructure/DataStructure.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "dsa/DataStructure.h"
+#include "dsa/DSGraph.h"
 using namespace llvm;
 
 namespace {


Index: llvm-poolalloc/lib/DSA/DataStructureOpt.cpp
diff -u llvm-poolalloc/lib/DSA/DataStructureOpt.cpp:1.14 llvm-poolalloc/lib/DSA/DataStructureOpt.cpp:1.15
--- llvm-poolalloc/lib/DSA/DataStructureOpt.cpp:1.14	Wed Dec  6 11:46:31 2006
+++ llvm-poolalloc/lib/DSA/DataStructureOpt.cpp	Wed Dec 13 23:51:06 2006
@@ -12,8 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/DataStructure/DataStructure.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "dsa/DataStructure.h"
+#include "dsa/DSGraph.h"
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Module.h"
 #include "llvm/Constant.h"


Index: llvm-poolalloc/lib/DSA/DataStructureStats.cpp
diff -u llvm-poolalloc/lib/DSA/DataStructureStats.cpp:1.24 llvm-poolalloc/lib/DSA/DataStructureStats.cpp:1.25
--- llvm-poolalloc/lib/DSA/DataStructureStats.cpp:1.24	Wed Dec  6 19:30:31 2006
+++ llvm-poolalloc/lib/DSA/DataStructureStats.cpp	Wed Dec 13 23:51:06 2006
@@ -11,8 +11,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/DataStructure/DataStructure.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "dsa/DataStructure.h"
+#include "dsa/DSGraph.h"
 #include "llvm/Function.h"
 #include "llvm/Instructions.h"
 #include "llvm/Pass.h"


Index: llvm-poolalloc/lib/DSA/EquivClassGraphs.cpp
diff -u llvm-poolalloc/lib/DSA/EquivClassGraphs.cpp:1.53 llvm-poolalloc/lib/DSA/EquivClassGraphs.cpp:1.54
--- llvm-poolalloc/lib/DSA/EquivClassGraphs.cpp:1.53	Wed Dec  6 19:30:31 2006
+++ llvm-poolalloc/lib/DSA/EquivClassGraphs.cpp	Wed Dec 13 23:51:06 2006
@@ -15,11 +15,11 @@
 //===----------------------------------------------------------------------===//
 
 #define DEBUG_TYPE "ECGraphs"
-#include "llvm/Analysis/DataStructure/DataStructure.h"
+#include "dsa/DataStructure.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
 #include "llvm/Pass.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "dsa/DSGraph.h"
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/ADT/SCCIterator.h"


Index: llvm-poolalloc/lib/DSA/GraphChecker.cpp
diff -u llvm-poolalloc/lib/DSA/GraphChecker.cpp:1.23 llvm-poolalloc/lib/DSA/GraphChecker.cpp:1.24
--- llvm-poolalloc/lib/DSA/GraphChecker.cpp:1.23	Wed Dec  6 19:30:31 2006
+++ llvm-poolalloc/lib/DSA/GraphChecker.cpp	Wed Dec 13 23:51:06 2006
@@ -23,8 +23,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/DataStructure/DataStructure.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "dsa/DataStructure.h"
+#include "dsa/DSGraph.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/Value.h"


Index: llvm-poolalloc/lib/DSA/Local.cpp
diff -u llvm-poolalloc/lib/DSA/Local.cpp:1.163 llvm-poolalloc/lib/DSA/Local.cpp:1.164
--- llvm-poolalloc/lib/DSA/Local.cpp:1.163	Wed Dec  6 19:30:31 2006
+++ llvm-poolalloc/lib/DSA/Local.cpp	Wed Dec 13 23:51:06 2006
@@ -1,3 +1,4 @@
+#define JTC 0
 //===- Local.cpp - Compute a local data structure graph for a function ----===//
 //
 //                     The LLVM Compiler Infrastructure
@@ -12,8 +13,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/DataStructure/DataStructure.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "llvm/ADT/Statistic.h"
+#include "dsa/DataStructure.h"
+#include "dsa/DSGraph.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Instructions.h"
@@ -24,6 +26,8 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Timer.h"
+#include "poolalloc/Config/config.h"
+#include <iostream>
 
 // FIXME: This should eventually be a FunctionPass that is automatically
 // aggregated into a Pass.
@@ -32,6 +36,12 @@
 
 using namespace llvm;
 
+#ifdef LLVA_KERNEL
+static Statistic CacheAllocs ("dsa", "Number of kmem_cache_alloc calls");
+static Statistic KMallocs    ("dsa", "Number of kmalloc calls");
+static Statistic GlobalPools ("dsa", "Number of global pools");
+#endif
+
 static RegisterPass<LocalDataStructures>
 X("datastructure", "Local Data Structure Analysis");
 
@@ -90,27 +100,59 @@
     DSNodeHandle *RetNode;               // Node that gets returned...
     DSScalarMap &ScalarMap;
     std::list<DSCallSite> *FunctionCalls;
-
+    Value * KMallocPool;
   public:
     GraphBuilder(Function &f, DSGraph &g, DSNodeHandle &retNode,
                  std::list<DSCallSite> &fc)
       : G(g), RetNode(&retNode), ScalarMap(G.getScalarMap()),
         FunctionCalls(&fc) {
-
+      // Find the type unsafe pool in the program
+      KMallocPool = f.getParent()->getNamedGlobal ("KmallocPool");
+      
+#if 1
+      //
+      // Determine if the function somehow escapes
+      //
+      bool escapes = false;
+      if (!(f.hasInternalLinkage())) {
+        escapes = true;
+      }
+      Value::use_iterator U;
+      for (U=f.use_begin(); U != f.use_end(); ++U) {
+        if (isa<GlobalValue>(U)) {
+          std::cerr << "LLVA: isa: " << f.getName() << " " << *U << std::endl;
+          escapes = true;
+          break;
+        }
+      }
+#endif
       // Create scalar nodes for all pointer arguments...
       for (Function::arg_iterator I = f.arg_begin(), E = f.arg_end();
-           I != E; ++I)
-        if (isPointerType(I->getType()))
-          getValueDest(*I);
+           I != E; ++I) {
+        if (isPointerType(I->getType())) {
+          DSNode * Node = getValueDest(*I).getNode();
+          if (!(f.hasInternalLinkage())) {
+            Node->setExternalMarker();
+          }
+        }
+      }
 
       visit(f);  // Single pass over the function
+#if JTC
+std::cerr << "LLVA: Function " << f.getName() << "\n";
+      for (DSScalarMap::iterator I = ScalarMap.begin(), E=ScalarMap.end();
+           I != E;
+           ++I)
+      {
+        std::cerr << "LLVA:\t" << I->first->getName() << ": " << (void *)(I->second.getNode()) << "\n";
+      }
+#endif
     }
 
     // GraphBuilder ctor for working on the globals graph
     GraphBuilder(DSGraph &g)
       : G(g), RetNode(0), ScalarMap(G.getScalarMap()), FunctionCalls(0) {
     }
-
     void mergeInGlobalInitializer(GlobalVariable *GV);
 
   private:
@@ -345,6 +387,26 @@
 
 
 void GraphBuilder::visitGetElementPtrInst(User &GEP) {
+
+#ifdef LLVA_KERNEL
+#if 1
+  int debug = 0;
+  if (isa<Instruction>(GEP)) {
+    Instruction * IGEP = (Instruction *)(&GEP);
+    if (IGEP->getParent()->getParent()->getName() == "alloc_vfsmnt")
+    {
+#if 0
+      if (G.getPoolDescriptorsMap().count(N) != 0)
+        if (G.getPoolDescriptorsMap()[N])
+  std::cerr << "LLVA: GEP[" << count << "]: Pool for " << GEP.getName() << " is " << G.getPoolDescriptorsMap()[N]->getMetaPoolValue()->getName() << "\n";
+#else
+    debug = 1;
+#endif
+    }
+  }
+#endif
+#endif
+
   DSNodeHandle Value = getValueDest(*GEP.getOperand(0));
   if (Value.isNull())
     Value = createNode();
@@ -364,6 +426,11 @@
   if (AllZeros || (!Value.isNull() &&
                    Value.getNode()->isNodeCompletelyFolded())) {
     setDestTo(GEP, Value);
+#if 0
+if (debug) std::cerr << "LLVA: GEP: All Zeros\n";
+  if (G.getPoolDescriptorsMap()[Value.getNode()])
+    std::cerr << "LLVA: GEP: Pool for " << GEP.getName() << " is " << G.getPoolDescriptorsMap()[Value.getNode()]->getName() << "\n";
+#endif
     return;
   }
 
@@ -374,6 +441,7 @@
   if (Value.getNode()->mergeTypeInfo(CurTy, Value.getOffset())) {
     // If the node had to be folded... exit quickly
     setDestTo(GEP, Value);  // GEP result points to folded node
+
     return;
   }
 
@@ -472,9 +540,22 @@
       N->foldNodeCompletely();
     }
   }
-  
+
   // Value is now the pointer we want to GEP to be...  
   setDestTo(GEP, Value);
+#if 0
+  if (debug && (isa<Instruction>(GEP))) {
+    Instruction * IGEP = (Instruction *)(&GEP);
+    DSNode * N = Value.getNode();
+    if (IGEP->getParent()->getParent()->getName() == "alloc_vfsmnt")
+    {
+      if (G.getPoolDescriptorsMap().count(N) != 0)
+        if (G.getPoolDescriptorsMap()[N])
+  std::cerr << "LLVA: GEP[" << 0 << "]: Pool for " << GEP.getName() << " is " << G.getPoolDescriptorsMap()[N]->getName() << "\n";
+    }
+  }
+#endif
+
 }
 
 void GraphBuilder::visitLoadInst(LoadInst &LI) {
@@ -490,6 +571,10 @@
 
   if (isPointerType(LI.getType()))
     setDestTo(LI, getLink(Ptr));
+#if 0
+  if (G.getPoolDescriptorsMap()[getLink(Ptr).getNode()])
+    std::cerr << "LLVA: Load: Pool for " << LI.getName() << " is " << G.getPoolDescriptorsMap()[getLink(Ptr).getNode()]->getName() << "\n";
+#endif
 }
 
 void GraphBuilder::visitStoreInst(StoreInst &SI) {
@@ -506,6 +591,18 @@
   // Avoid adding edges from null, or processing non-"pointer" stores
   if (isPointerType(StoredTy))
     Dest.addEdgeTo(getValueDest(*SI.getOperand(0)));
+#ifdef LLVA_KERNEL
+#if 1
+  {
+    if (SI.getParent()->getParent()->getName() == "alloc_vfsmnt") {
+      DSNode * N = getValueDest(*SI.getOperand(1)).getNode();
+      if (G.getPoolDescriptorsMap().count(N) != 0)
+        if (G.getPoolDescriptorsMap()[N])
+          std::cerr << "LLVA: Store: Pool for " << SI.getName() << " is " << G.getPoolDescriptorsMap()[N]->getName() << "\n";
+    }
+  }
+#endif
+#endif
 }
 
 void GraphBuilder::visitReturnInst(ReturnInst &RI) {
@@ -1004,7 +1101,155 @@
     if (DSNode *N = getValueDest(**(CS.arg_begin() + 1)).getNode())
             N->setReadMarker();
     return true;
+#ifdef LLVA_KERNEL_0
+  } else if (F->getName() == "kmem_cache_alloc") {
+    DEBUG(std::cerr << "LLVA: kmem_cache_alloc" << std::endl);
+    // Update the statistics count
+    ++CacheAllocs;
+
+    // Create a new DSNode for this memory allocation
+    DSNode *N = createNode();
+    N->setHeapNodeMarker();
+    setDestTo(*CS.getInstruction(), N);
+
+    // Get the pool handle
+    if (CS.arg_begin() == CS.arg_end()) {
+      abort(); //Hanlde this later
+      // Treat it as  a kmalloc
+      N->foldNodeCompletely();
+      //This becomes a kmalloc pool
+      MetaPoolHandle* tmpvh = new MetaPoolHandle(new MetaPool(KMallocPool));
+      G.getPoolDescriptorsMap()[N] = tmpvh;
+    } else {
+      Value *actualPD = *(CS.arg_begin());
+      if (!isa<GlobalValue>(actualPD)) {
+        std::cerr << "WARNING: Pool is not global.  Function = " << CS.getCaller()->getName() << "\n";
+      } else {
+        ++GlobalPools;
+      }
+      Value *TheMetaPool = actualPD;
+      if (G.getPoolDescriptorsMap().count(N)== 0) {
+        //Here we insert a global meta pool
+        //Get the Module first
+        Module * M = F->getParent();
+        //Now create a meta pool for this value, DSN Node
+        const Type * VoidPtrType = PointerType::get(Type::SByteTy);              
+        TheMetaPool = new GlobalVariable(
+                                 /*type=*/ VoidPtrType,
+                                 /*isConstant=*/ false,
+                                 /*Linkage=*/ GlobalValue::InternalLinkage,
+                                 /*initializer=*/ Constant::getNullValue(VoidPtrType),
+                                 /*name=*/ "_metaPool_",
+                                 /*parent=*/ M );
+        //Inserted a global meta pool 
+      }
+      //Now insert a function call that takes care of adding this pool to the global pool
+      
+      //First get the Insert point
+      Instruction *InsertPoint = CS.getInstruction();
+      
+      //Assumes AddPoolDescToMetaPool is in the module
+      CastInst *CastMetaPool = 
+        CastInst::createPointerCast (TheMetaPool, 
+                     PointerType::get(Type::SByteTy), "metapool.casted", InsertPoint);
+      CastInst *CastActualPD = 
+        CastInst::createPointerCast (actualPD, 
+                     PointerType::get(Type::SByteTy), "poolhandle.lscasted", InsertPoint);
+      
+      // Create the call to AddPoolDescToMetaPool 
+      std::vector<Value *> args(1,CastMetaPool);
+      args.push_back(CastActualPD);
+      new CallInst(AddPoolDescToMetaPool,args,"", InsertPoint);
+      MetaPoolHandle* tmpvh = new MetaPoolHandle(new MetaPool(TheMetaPool));
+      G.getPoolDescriptorsMap()[N] = tmpvh;
+    }
+  } else if (F->getName() == "poolalloc") {
+    if (CS.getCaller()->getName() == "kmem_cache_alloc")
+      return;
+    // Update the statistics
+    ++KMallocs;
+
+    // Create a DSNode for the memory allocated by this function call
+    DSNode *N = createNode();
+    N->setHeapNodeMarker();
+    setDestTo(*CS.getInstruction(), N);
+
+    // Get the pool handle, if possible
+    if (CS.arg_begin() == CS.arg_end()) {
+      abort(); //handle later
+      // Treat it as kmalloc
+      N->foldNodeCompletely();
+      //This becomes a kmalloc pool
+      //So get the kmalloc pool
+      MetaPoolHandle* tmpvh = new MetaPoolHandle(new MetaPool(KMallocPool));
+      G.getPoolDescriptorsMap()[N] = tmpvh;
+    } else {
+      Value *actualPD = *(CS.arg_begin());
+      if (!isa<GlobalValue>(actualPD)) {
+        std::cerr << "WARNING: Pool is not global.  Function = " << CS.getCaller()->getName() << "\n";
+      } else {
+        ++GlobalPools;
+      }
+      Value *TheMetaPool = actualPD;
+      if (G.getPoolDescriptorsMap().count(N)== 0) {
+        //Here we insert a global meta pool
+        //Get the Module first
+        Module * M = F->getParent();
+        //Now create a meta pool for this value, DSN Node
+        const Type * VoidPtrType = PointerType::get(Type::SByteTy);              
+        TheMetaPool = new GlobalVariable(
+                                 /*type=*/ VoidPtrType,
+                                 /*isConstant=*/ false,
+                                 /*Linkage=*/ GlobalValue::InternalLinkage,
+                                 /*initializer=*/ Constant::getNullValue(VoidPtrType),
+                                 /*name=*/ "_metaPool_",
+                                 /*parent=*/ M );
+        //Inserted a global meta pool 
+      }
+      //Now insert a function call that takes care of adding this pool to the global pool
+      //First get the Insert point
+      Instruction *InsertPoint = CS.getInstruction();
+
+      //Assumes AddPoolDescToMetaPool is in the module
+      CastInst *CastMetaPool = 
+        CastInst::createPointerCast (TheMetaPool, 
+                     PointerType::get(Type::SByteTy), "metapool.casted", InsertPoint);
+      CastInst *CastActualPD = 
+        CastInst::createPointerCast (actualPD, 
+                     PointerType::get(Type::SByteTy), "poolhandle.lscasted", InsertPoint);
+      
+      // Create the call to AddPoolDescToMetaPool 
+      std::vector<Value *> args(1,CastMetaPool);
+      args.push_back(CastActualPD);
+      new CallInst(AddPoolDescToMetaPool,args,"", InsertPoint);
+      MetaPoolHandle* tmpvh = new MetaPoolHandle(new MetaPool(TheMetaPool));
+      G.getPoolDescriptorsMap()[N] = tmpvh;
+    }
+#endif
+#ifdef LLVA_KERNEL
+  } else if (F->getName() == "llva_memcpy") {
+    if (CS.getCaller()->getName() == "kmem_cache_alloc")
+        return false;
+    // Merge the first & second arguments, and mark the memory read and
+    // modified.
+    DSNodeHandle RetNH = getValueDest(**CS.arg_begin());
+    RetNH.mergeWith(getValueDest(**(CS.arg_begin()+1)));
+    if (DSNode *N = RetNH.getNode())
+      N->setModifiedMarker()->setReadMarker();
+    return true;
+  } else if (F->getName() == "__generic_copy_from_user") {
+    if (CS.getCaller()->getName() == "kmem_cache_alloc")
+        return false;
+    // Merge the first & second arguments, and mark the memory read and
+    // modified.
+    DSNodeHandle RetNH = getValueDest(**CS.arg_begin());
+    RetNH.mergeWith(getValueDest(**(CS.arg_begin()+1)));
+    if (DSNode *N = RetNH.getNode())
+      N->setModifiedMarker()->setReadMarker();
+    return true;
+#endif
   }
+
   return false;
 }
 
@@ -1012,29 +1257,192 @@
   Value *Callee = CS.getCalledValue();
 
   // Special case handling of certain libc allocation functions here.
-  if (Function *F = dyn_cast<Function>(Callee))
+  if (Function *F = dyn_cast<Function>(Callee)) {
+#ifdef LLVA_KERNEL    
+    if (F->getName() == "kmem_cache_alloc") {
+      DEBUG(std::cerr << "LLVA: kmem_cache_alloc" << std::endl);
+      // Update the statistics count
+      ++CacheAllocs;
+      
+      // Create a new DSNode for this memory allocation
+      DSNode *N = createNode();
+      N->setHeapNodeMarker();
+      setDestTo(*CS.getInstruction(), N);
+
+      // Get the pool handle
+      if (CS.arg_begin() == CS.arg_end()) {
+        abort(); //Handle this later
+        // Treat it as  a kmalloc
+        N->foldNodeCompletely();
+        //This becomes a kmalloc pool
+        MetaPoolHandle* mpvh = new MetaPoolHandle(new MetaPool(KMallocPool));
+        G.getPoolDescriptorsMap()[N] = mpvh;
+      } else {
+        Value *actualPD = *(CS.arg_begin());
+        if (!isa<GlobalValue>(actualPD)) {
+          std::cerr << "WARNING: Pool is not global.  Function = " << CS.getCaller()->getName() << "\n";
+        } else {
+          ++GlobalPools;
+        }
+        Value *TheMetaPool = actualPD;
+        //Get the Module first
+        Module * M = F->getParent();
+        if (G.getPoolDescriptorsMap().count(N)== 0) {
+          //Here we insert a global meta pool
+          //Now create a meta pool for this value, DSN Node
+          const Type * VoidPtrType = PointerType::get(Type::SByteTy);              
+          TheMetaPool = new GlobalVariable(
+                                           /*type=*/ VoidPtrType,
+                                           /*isConstant=*/ false,
+                                           /*Linkage=*/ GlobalValue::InternalLinkage,
+                                           /*initializer=*/ Constant::getNullValue(VoidPtrType),
+                                           /*name=*/ "_metaPool_",
+                                           /*parent=*/ M );
+          //Inserted a global meta pool 
+        }
+#if 1
+        else {
+          // Lookup the meta pool
+          TheMetaPool = G.getPoolForNode(N)->getMetaPoolValue();
+        }
+#endif
+        //Now insert a function call that takes care of adding this pool to the global pool
+        
+        //First get the Insert point
+        Instruction *InsertPoint = CS.getInstruction();
+        
+        //Assumes AddPoolDescToMetaPool is in the module
+        const Type * VoidPtrType = PointerType::get(Type::SByteTy);
+        const Type * VoidPtrPtrType = PointerType::get(VoidPtrType);
+        CastInst *CastMetaPool = 
+          CastInst::createPointerCast (TheMetaPool, 
+                       VoidPtrPtrType, "metapool.casted", InsertPoint);
+        CastInst *CastActualPD = 
+          CastInst::createPointerCast (actualPD, 
+                       PointerType::get(Type::SByteTy), "poolhandle.lscasted", InsertPoint);
+        
+        // Create the call to AddPoolDescToMetaPool 
+        std::vector<Value *> args(1,CastMetaPool);
+        args.push_back(CastActualPD);
+
+        //Get the AddPoolDescToMetaPool function from the module
+        //FIXME optimize it by getting it once per module 
+        std::vector<const Type *> Arg(1, VoidPtrPtrType);
+        Arg.push_back(VoidPtrType);
+        FunctionType *AddPoolDescToMetaPoolTy =
+          FunctionType::get(Type::VoidTy,Arg, false);
+        Function *AddPoolDescToMetaPool = M->getOrInsertFunction("AddPoolDescToMetaPool", AddPoolDescToMetaPoolTy);
+
+        
+        new CallInst(AddPoolDescToMetaPool,args,"", InsertPoint);
+#if 0
+        MetaPoolHandle* tmpvh = new MetaPoolHandle(new MetaPool(TheMetaPool));
+#else
+        MetaPoolHandle* tmpvh = new MetaPoolHandle(new MetaPool(TheMetaPool), CS.getInstruction());
+#endif
+        G.getPoolDescriptorsMap()[N] = tmpvh;
+      }
+      return;
+    } else if (F->getName() == "poolalloc") {
+      if (CS.getCaller()->getName() == "kmem_cache_alloc")
+        return;
+      // Update the statistics
+      ++KMallocs;
+      
+      // Create a DSNode for the memory allocated by this function call
+      DSNode *N = createNode();
+      N->setHeapNodeMarker();
+      setDestTo(*CS.getInstruction(), N);
+      
+      // Get the pool handle, if possible
+      if (CS.arg_begin() == CS.arg_end()) {
+        abort() ; //Handle this later
+        // Treat it as kmalloc
+        N->foldNodeCompletely();
+        //This becomes a kmalloc pool
+        //So get the kmalloc pool
+        MetaPoolHandle* tmpvh = new MetaPoolHandle(new MetaPool(KMallocPool));
+        G.getPoolDescriptorsMap()[N] = tmpvh;
+      } else {
+        Value *actualPD = *(CS.arg_begin());
+        if (!isa<GlobalValue>(actualPD)) {
+          std::cerr << "WARNING: Pool is not global.  Function = " << CS.getCaller()->getName() << "\n";
+        } else {
+          ++GlobalPools;
+        }
+        Value *TheMetaPool = actualPD;
+        Module * M = F->getParent();
+        if (G.getPoolDescriptorsMap().count(N)== 0) {
+          //Here we insert a global meta pool
+          //Get the Module first
+          //Now create a meta pool for this value, DSN Node
+          const Type * VoidPtrType = PointerType::get(Type::SByteTy);              
+          TheMetaPool = new GlobalVariable(
+                                           /*type=*/ VoidPtrType,
+                                           /*isConstant=*/ false,
+                                           /*Linkage=*/ GlobalValue::InternalLinkage,
+                                           /*initializer=*/ Constant::getNullValue(VoidPtrType),
+                                           /*name=*/ "_metaPool_",
+                                           /*parent=*/ M );
+          //Inserted a global meta pool 
+        }
+        //Now insert a function call that takes care of adding this pool to the global pool
+        //First get the Insert point
+        Instruction *InsertPoint = CS.getInstruction();
+        
+        //Assumes AddPoolDescToMetaPool is in the module
+        const Type * VoidPtrType = PointerType::get(Type::SByteTy);
+        const Type * VoidPtrPtrType = PointerType::get(VoidPtrType);
+        CastInst *CastMetaPool = 
+          CastInst::createPointerCast (TheMetaPool, 
+                       VoidPtrPtrType, "metapool.casted", InsertPoint);
+        CastInst *CastActualPD = 
+          CastInst::createPointerCast (actualPD, 
+                       PointerType::get(Type::SByteTy), "poolhandle.lscasted", InsertPoint);
+        
+        // Create the call to AddPoolDescToMetaPool 
+        std::vector<Value *> args(1,CastMetaPool);
+        args.push_back(CastActualPD);
+
+        //FIXME optimize it by getting it once per module 
+        std::vector<const Type *> Arg(1, VoidPtrPtrType);
+        Arg.push_back(VoidPtrType);
+        FunctionType *AddPoolDescToMetaPoolTy =
+          FunctionType::get(Type::VoidTy,Arg, false);
+        Function *AddPoolDescToMetaPool = M->getOrInsertFunction("AddPoolDescToMetaPool", AddPoolDescToMetaPoolTy);
+        
+        new CallInst(AddPoolDescToMetaPool,args,"", InsertPoint);
+        MetaPoolHandle* tmpvh = new MetaPoolHandle(new MetaPool(TheMetaPool));
+        G.getPoolDescriptorsMap()[N] = tmpvh;
+      }
+      return;
+    }
+#endif
     if (F->isExternal())
       if (F->isIntrinsic() && visitIntrinsic(CS, F))
         return;
       else {
         // Determine if the called function is one of the specified heap
         // allocation functions
-	if (AllocList.end() != std::find(AllocList.begin(), AllocList.end(), F->getName())) {
-	  setDestTo(*CS.getInstruction(),
-		    createNode()->setHeapNodeMarker()->setModifiedMarker());
-	  return;
-	}
+        if (AllocList.end() != std::find(AllocList.begin(), AllocList.end(), F->getName())) {
+          setDestTo(*CS.getInstruction(),
+                    createNode()->setHeapNodeMarker()->setModifiedMarker());
+          return;
+        }
 
         // Determine if the called function is one of the specified heap
         // free functions
-	if (FreeList.end() != std::find(FreeList.begin(), FreeList.end(), F->getName())) {
-	  // Mark that the node is written to...
-	  if (DSNode *N = getValueDest(*(CS.getArgument(0))).getNode())
-	    N->setModifiedMarker()->setHeapNodeMarker();
-	  return;
-	}
-	if (visitExternal(CS,F))
-	  return;
+        if (FreeList.end() != std::find(FreeList.begin(), FreeList.end(),
+                                        F->getName())) {
+          // Mark that the node is written to...
+          if (DSNode *N = getValueDest(*(CS.getArgument(0))).getNode())
+            N->setModifiedMarker()->setHeapNodeMarker();
+          return;
+        }
+
+        if (visitExternal(CS,F))
+          return;
+
         // Unknown function, warn if it returns a pointer type or takes a
         // pointer argument.
         bool Warn = isPointerType(CS.getInstruction()->getType());
@@ -1050,6 +1458,7 @@
                << F->getName() << "' will cause pessimistic results!\n";
         }
       }
+  }
 
   // Set up the return value...
   DSNodeHandle RetVal;
@@ -1294,7 +1703,6 @@
     if (!I->isExternal())
       DSInfo.insert(std::make_pair(I, new DSGraph(GlobalECs, TD, *I,
                                                   GlobalsGraph)));
-
   GlobalsGraph->removeTriviallyDeadNodes();
   GlobalsGraph->markIncompleteNodes(DSGraph::MarkFormalArgs);
 


Index: llvm-poolalloc/lib/DSA/Makefile
diff -u llvm-poolalloc/lib/DSA/Makefile:1.5 llvm-poolalloc/lib/DSA/Makefile:1.6
--- llvm-poolalloc/lib/DSA/Makefile:1.5	Sun Oct 23 20:08:20 2005
+++ llvm-poolalloc/lib/DSA/Makefile	Wed Dec 13 23:51:06 2006
@@ -1,4 +1,4 @@
-##===- lib/Analysis/DataStructure/Makefile -----------------*- Makefile -*-===##
+##===- lib/DSA/Makefile ------------------------------------*- Makefile -*-===##
 # 
 #                     The LLVM Compiler Infrastructure
 #
@@ -7,7 +7,7 @@
 # 
 ##===----------------------------------------------------------------------===##
 
-LEVEL = ../../..
+LEVEL = ../..
 LIBRARYNAME = LLVMDataStructure
 
 include $(LEVEL)/Makefile.common


Index: llvm-poolalloc/lib/DSA/Printer.cpp
diff -u llvm-poolalloc/lib/DSA/Printer.cpp:1.91 llvm-poolalloc/lib/DSA/Printer.cpp:1.92
--- llvm-poolalloc/lib/DSA/Printer.cpp:1.91	Wed Dec  6 19:30:31 2006
+++ llvm-poolalloc/lib/DSA/Printer.cpp	Wed Dec 13 23:51:06 2006
@@ -11,9 +11,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/DataStructure/DataStructure.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
-#include "llvm/Analysis/DataStructure/DSGraphTraits.h"
+#include "dsa/DataStructure.h"
+#include "dsa/DSGraph.h"
+#include "dsa/DSGraphTraits.h"
 #include "llvm/Module.h"
 #include "llvm/Constants.h"
 #include "llvm/Assembly/Writer.h"


Index: llvm-poolalloc/lib/DSA/Steensgaard.cpp
diff -u llvm-poolalloc/lib/DSA/Steensgaard.cpp:1.67 llvm-poolalloc/lib/DSA/Steensgaard.cpp:1.68
--- llvm-poolalloc/lib/DSA/Steensgaard.cpp:1.67	Wed Dec  6 19:30:31 2006
+++ llvm-poolalloc/lib/DSA/Steensgaard.cpp	Wed Dec 13 23:51:06 2006
@@ -14,8 +14,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/DataStructure/DataStructure.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "dsa/DataStructure.h"
+#include "dsa/DSGraph.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Module.h"
@@ -28,6 +28,7 @@
     DSGraph *ResultGraph;
 
     EquivalenceClasses<GlobalValue*> GlobalECs;  // Always empty
+    PoolDescriptorMapType PoolDescriptors; 
   public:
     Steens() : ResultGraph(0) {}
     ~Steens() {


Index: llvm-poolalloc/lib/DSA/TopDownClosure.cpp
diff -u llvm-poolalloc/lib/DSA/TopDownClosure.cpp:1.95 llvm-poolalloc/lib/DSA/TopDownClosure.cpp:1.96
--- llvm-poolalloc/lib/DSA/TopDownClosure.cpp:1.95	Wed Dec  6 11:46:31 2006
+++ llvm-poolalloc/lib/DSA/TopDownClosure.cpp	Wed Dec 13 23:51:06 2006
@@ -14,10 +14,11 @@
 //
 //===----------------------------------------------------------------------===//
 #define DEBUG_TYPE "td_dsa"
-#include "llvm/Analysis/DataStructure/DataStructure.h"
+
+#include "dsa/DataStructure.h"
 #include "llvm/Module.h"
 #include "llvm/DerivedTypes.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "dsa/DSGraph.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/ADT/Statistic.h"
@@ -372,7 +373,6 @@
     } else {
       // Otherwise, create a new DSGraph to represent this.
       IndCallGraph = new DSGraph(DSG.getGlobalECs(), DSG.getTargetData());
-
       // Make a nullary dummy call site, which will eventually get some content
       // merged into it.  The actual callee function doesn't matter here, so we
       // just pass it something to keep the ctor happy.






More information about the llvm-commits mailing list