[llvm-commits] [poolalloc] r96953 - in /poolalloc/trunk: include/dsa/DSNode.h lib/DSA/BottomUpClosure.cpp lib/DSA/DataStructure.cpp lib/DSA/Local.cpp

alenhar2 at llvm.org alenhar2 at llvm.org
Tue Feb 23 08:45:35 PST 2010


Author: alenhar2
Date: Tue Feb 23 10:45:34 2010
New Revision: 96953

URL: http://llvm.org/viewvc/llvm-project?rev=96953&view=rev
Log:
cache external function in node info.  reduces peak memory by 1GB and runtime by 66% on the linux kernel

Modified:
    poolalloc/trunk/include/dsa/DSNode.h
    poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
    poolalloc/trunk/lib/DSA/DataStructure.cpp
    poolalloc/trunk/lib/DSA/Local.cpp

Modified: poolalloc/trunk/include/dsa/DSNode.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSNode.h?rev=96953&r1=96952&r2=96953&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DSNode.h (original)
+++ poolalloc/trunk/include/dsa/DSNode.h Tue Feb 23 10:45:34 2010
@@ -85,20 +85,21 @@
     AllocaNode      = 1 << 0,   // This node was allocated with alloca
     HeapNode        = 1 << 1,   // This node was allocated with malloc
     GlobalNode      = 1 << 2,   // This node was allocated by a global var decl
-    UnknownNode     = 1 << 3,   // This node points to unknown allocated memory
-    IncompleteNode  = 1 << 4,   // This node may not be complete
-
-    ModifiedNode    = 1 << 5,   // This node is modified in this context
-    ReadNode        = 1 << 6,   // This node is read in this context
-
-    ArrayNode       = 1 << 7,   // This node is treated like an array
-    ExternalNode    = 1 << 8,   // This node comes from an external source
-    IntToPtrNode    = 1 << 9,   // This node comes from an int cast
-    PtrToIntNode    = 1 << 10,  // This node excapes to an int cast
-    VAStartNode     = 1 << 11,  // This node excapes to an int cast
+    ExternFuncNode  = 1 << 3,   // This node contains external functions
+    UnknownNode     = 1 << 4,   // This node points to unknown allocated memory
+    IncompleteNode  = 1 << 5,   // This node may not be complete
+
+    ModifiedNode    = 1 << 6,   // This node is modified in this context
+    ReadNode        = 1 << 7,   // This node is read in this context
+
+    ArrayNode       = 1 << 8,   // This node is treated like an array
+    ExternalNode    = 1 << 9,   // This node comes from an external source
+    IntToPtrNode    = 1 << 10,   // This node comes from an int cast
+    PtrToIntNode    = 1 << 11,  // This node excapes to an int cast
+    VAStartNode     = 1 << 12,  // This node excapes to an int cast
 
     //#ifndef NDEBUG
-    DeadNode        = 1 << 12,   // This node is dead and should not be pointed to
+    DeadNode        = 1 << 13,   // This node is dead and should not be pointed to
     //#endif
 
     Composition = AllocaNode | HeapNode | GlobalNode | UnknownNode
@@ -328,6 +329,7 @@
   bool isAllocaNode()     const { return NodeType & AllocaNode;    }
   bool isHeapNode()       const { return NodeType & HeapNode;      }
   bool isGlobalNode()     const { return NodeType & GlobalNode;    }
+  bool isExternFuncNode() const { return NodeType & ExternFuncNode; }
   bool isUnknownNode()    const { return NodeType & UnknownNode;   }
   bool isModifiedNode()   const { return NodeType & ModifiedNode;  }
   bool isReadNode()       const { return NodeType & ReadNode;      }
@@ -343,6 +345,7 @@
   DSNode* setAllocaMarker()     { NodeType |= AllocaNode;     return this; }
   DSNode* setHeapMarker()       { NodeType |= HeapNode;       return this; }
   DSNode* setGlobalMarker()     { NodeType |= GlobalNode;     return this; }
+  DSNode* setExternFuncMarker() { NodeType |= ExternFuncNode; return this; }
   DSNode* setUnknownMarker()    { NodeType |= UnknownNode;    return this; }
   DSNode* setModifiedMarker()   { NodeType |= ModifiedNode;   return this; }
   DSNode* setReadMarker()       { NodeType |= ReadNode;       return this; }

Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=96953&r1=96952&r2=96953&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Tue Feb 23 10:45:34 2010
@@ -119,14 +119,6 @@
   return false;
 }
 
-static inline bool nodeContainsExternalFunction(const DSNode *N) {
-  std::vector<const Function*> Funcs;
-  N->addFullFunctionList(Funcs);
-  for (unsigned i = 0, e = Funcs.size(); i != e; ++i)
-    if (Funcs[i]->isDeclaration()) return true;
-  return false;
-}
-
 void BUDataStructures::finalizeGlobals(void) {
   // Any unresolved call can be removed (resolved) if it does not contain
   // external functions and it is not reachable from any call that does
@@ -134,8 +126,7 @@
   std::set<DSCallSite> GoodCalls, BadCalls;
   for (DSGraph::afc_iterator ii = GlobalsGraph->afc_begin(), 
          ee = GlobalsGraph->afc_end(); ii != ee; ++ii)
-    if (ii->isDirectCall() ||
-        nodeContainsExternalFunction(ii->getCalleeNode()))
+    if (ii->isDirectCall() || ii->getCalleeNode()->isExternFuncNode())
       BadCalls.insert(*ii);
     else
       GoodCalls.insert(*ii);
@@ -163,15 +154,8 @@
       Callees.push_back(CS.getCalleeFunc());
   } else if (!CS.getCalleeNode()->isIncompleteNode()) {
     // Get all callees.
-    unsigned OldSize = Callees.size();
-    CS.getCalleeNode()->addFullFunctionList(Callees);
-    
-    // If any of the callees are unresolvable, remove the whole batch!
-    for (unsigned i = OldSize, e = Callees.size(); i != e; ++i)
-      if (Callees[i]->isDeclaration()) {
-        Callees.erase(Callees.begin()+OldSize, Callees.end());
-        return;
-      }
+    if (!CS.getCalleeNode()->isExternFuncNode())
+      CS.getCalleeNode()->addFullFunctionList(Callees);
   }
 }
 
@@ -181,15 +165,15 @@
     if (!CS.getCalleeFunc()->isDeclaration())
       Callees.push_back(CS.getCalleeFunc());
   } else {
-    // Get all callees.
+    // Get any callees.
     unsigned OldSize = Callees.size();
     CS.getCalleeNode()->addFullFunctionList(Callees);
-    
+
     // If any of the callees are unresolvable, remove them
-    for (unsigned i = OldSize; i != Callees.size(); )
+    for (unsigned i = OldSize; i != Callees.size();)
       if (Callees[i]->isDeclaration()) {
-        Callees.erase(Callees.begin()+i);
-      } else 
+        Callees.erase(Callees.begin() + i);
+      } else
         ++i;
   }
 }
@@ -202,14 +186,6 @@
     GetAllCallees(*I, Callees);
 }
 
-/// GetAnyAuxCallees - Return a list containing all of the callees in
-/// the aux list for the specified graph in the Callees vector.
-static void GetAnyAuxCallees(DSGraph* G, std::vector<const Function*> &Callees) {
-  Callees.clear();
-  for (DSGraph::afc_iterator I = G->afc_begin(), E = G->afc_end(); I != E; ++I)
-    GetAnyCallees(*I, Callees);
-}
-
 unsigned BUDataStructures::calculateGraphs(const Function *F,
                                            std::vector<const Function*> &Stack,
                                            unsigned &NextID,
@@ -233,17 +209,8 @@
 
   // Find all callee functions.
   std::vector<const Function*> CalleeFunctions;
-  GetAnyAuxCallees(Graph, CalleeFunctions);
-  std::sort(CalleeFunctions.begin(), CalleeFunctions.end());
-  std::vector<const Function*>::iterator uid = std::unique(CalleeFunctions.begin(), CalleeFunctions.end());
-  CalleeFunctions.resize(uid - CalleeFunctions.begin());
-
-  std::vector<const Function*> PreResolvedFuncs;
-  GetAllAuxCallees(Graph, PreResolvedFuncs);
-  std::sort(PreResolvedFuncs.begin(), PreResolvedFuncs.end());
-  uid = std::unique(PreResolvedFuncs.begin(), PreResolvedFuncs.end());
-  PreResolvedFuncs.resize(uid - PreResolvedFuncs.begin());
-  
+  GetAllAuxCallees(Graph, CalleeFunctions);
+
   // The edges out of the current node are the call site targets...
   for (unsigned i = 0, e = CalleeFunctions.size(); i != e; ++i) {
     const Function *Callee = CalleeFunctions[i];
@@ -275,36 +242,15 @@
     if (MaxSCC < 1) MaxSCC = 1;
 
     // Should we revisit the graph?  Only do it if there are now new resolvable
-    // callees or new callees
-    std::vector<const Function*> NewCalleeFuncs;
-    GetAnyAuxCallees(Graph, NewCalleeFuncs);
-    std::sort(NewCalleeFuncs.begin(), NewCalleeFuncs.end());
-    std::vector<const Function*>::iterator uid = std::unique(NewCalleeFuncs.begin(), NewCalleeFuncs.end());
-    NewCalleeFuncs.resize(uid - NewCalleeFuncs.begin());
-    uid = std::set_difference(NewCalleeFuncs.begin(), NewCalleeFuncs.end(),
-                              CalleeFunctions.begin(), CalleeFunctions.end(),
-                              NewCalleeFuncs.begin());
-    NewCalleeFuncs.resize(uid - NewCalleeFuncs.begin());
-
-    std::vector<const Function*> ResolvedFuncs;
-    GetAllAuxCallees(Graph, ResolvedFuncs);
-    std::sort(ResolvedFuncs.begin(), ResolvedFuncs.end());
-    uid = std::unique(ResolvedFuncs.begin(), ResolvedFuncs.end());
-    ResolvedFuncs.resize(uid - ResolvedFuncs.begin());
-    uid = std::set_difference(ResolvedFuncs.begin(), ResolvedFuncs.end(),
-                              PreResolvedFuncs.begin(), PreResolvedFuncs.end(),
-                              ResolvedFuncs.begin());
-    ResolvedFuncs.resize(uid - ResolvedFuncs.begin());
-
-    if (ResolvedFuncs.size() || NewCalleeFuncs.size()) {
+    // callees
+    GetAllAuxCallees(Graph, CalleeFunctions);
+    if (!CalleeFunctions.empty()) {
       DEBUG(errs() << "Recalculating " << F->getName() << " due to new knowledge\n");
       ValMap.erase(F);
       return calculateGraphs(F, Stack, NextID, ValMap);
     } else {
       ValMap[F] = ~0U;
     }
-    //propagate incomplete call nodes
-    inlineUnresolved(Graph);
     return MyID;
 
   } else {
@@ -359,8 +305,6 @@
 	  << "DONE with SCC #: " << MyID << "\n");
 
     // We never have to revisit "SCC" processed functions...
-    //propagate incomplete call nodes
-    inlineUnresolved(SCCGraph);
     return MyID;
   }
 
@@ -628,7 +572,8 @@
 	    << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+"
 	    << Graph->getAuxFunctionCalls().size() << "]\n");
       Graph->mergeInGraph(CS, *Callee, *GI,
-                         DSGraph::StripAllocaBit|DSGraph::DontCloneCallNodes);
+                         DSGraph::StripAllocaBit|DSGraph::DontCloneCallNodes |
+                          DSGraph::DontCloneAuxCallNodes);
       ++NumInlines;
     } else {
       DEBUG(errs() << "In Fns: " << Graph->getFunctionNames() << "\n");
@@ -710,7 +655,8 @@
       
       Graph->mergeInGraph(CS, IndCallGraph.second, *GI,
                           DSGraph::StripAllocaBit |
-                          DSGraph::DontCloneCallNodes);
+                          DSGraph::DontCloneCallNodes |
+                          DSGraph::DontCloneAuxCallNodes);
       ++NumInlines;
     }
   }

Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=96953&r1=96952&r2=96953&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Tue Feb 23 10:45:34 2010
@@ -117,7 +117,6 @@
   return ValueMap.insert(std::make_pair(GV, DSNodeHandle())).first->second;
 }
 
-
 //===----------------------------------------------------------------------===//
 // DSNode Implementation
 //===----------------------------------------------------------------------===//
@@ -212,7 +211,7 @@
 
   if (I == Globals.end() || *I != GV) {
     Globals.insert(I, GV);
-    NodeType |= GlobalNode;
+    setGlobalMarker();
   }
 }
 
@@ -853,11 +852,6 @@
   std::set_union(Globals.begin(), Globals.end(), 
                  RHS.Globals.begin(), RHS.Globals.end(), 
                  back_it);
-  DEBUG(
-        for (std::vector<const GlobalValue*>::iterator ii = Temp.begin(), 
-               ee = Temp.end(); ii != ee; ++ii)
-          assert(isa<GlobalValue>(*ii) && "Non global merged");
-        );
   Globals.swap(Temp);
 }
 
@@ -1011,12 +1005,10 @@
   N->Links.clear();
 
   // Merge the globals list...
-  if (!N->Globals.empty()) {
-    CurNodeH.getNode()->mergeGlobals(*N);
+  CurNodeH.getNode()->mergeGlobals(*N);
 
-    // Delete the globals from the old node...
-    N->Globals.clear();
-  }
+  // Delete the globals from the old node...
+  N->Globals.clear();
 }
 
 
@@ -2050,14 +2042,6 @@
         Edge.setTo(0, 0);  // Kill the edge!
 }
 
-static inline bool nodeContainsExternalFunction(const DSNode *N) {
-  std::vector<const Function*> Funcs;
-  N->addFullFunctionList(Funcs);
-  for (unsigned i = 0, e = Funcs.size(); i != e; ++i)
-    if (Funcs[i]->isDeclaration()) return true;
-  return false;
-}
-
 static void removeIdenticalCalls(std::list<DSCallSite> &Calls) {
   // Remove trivially identical function calls
   Calls.sort();  // Sort by callee as primary key!
@@ -2095,8 +2079,7 @@
       // if the callee contains an external function, it will never be
       // resolvable, just merge the call sites.
       if (!LastCalleeNode.isNull() && LastCalleeNode.getNode() == Callee) {
-        LastCalleeContainsExternalFunction =
-          nodeContainsExternalFunction(Callee);
+        LastCalleeContainsExternalFunction = Callee->isExternFuncNode();
 
         std::list<DSCallSite>::iterator PrevIt = OldIt;
         --PrevIt;
@@ -2834,7 +2817,10 @@
     for( ; i != I->globals_end(); ++i) {
       GlobalECs.unionSets(First, *i);
       ECGlobals.insert(*i);
-      SM.erase(SM.find(*i));
+      if (SM.find(*i) != SM.end())
+        SM.erase(SM.find(*i));
+      else
+        errs() << "Global missing in scalar map " << (*i)->getName() << "\n";
     }
 
     // Next, get the leader element.

Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=96953&r1=96952&r2=96953&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Tue Feb 23 10:45:34 2010
@@ -76,7 +76,7 @@
 
     /// getValueDest - Return the DSNode that the actual value points to.
     ///
-    DSNodeHandle getValueDest(Value &V);
+    DSNodeHandle getValueDest(Value* V);
 
     /// getLink - This method is used to return the specified link in the
     /// specified node if one exists.  If a link does not already exist (it's
@@ -95,7 +95,7 @@
     { setDestTo(AI, createNode()->setAllocaMarker()); }
 
     void visitFreeInst(FreeInst &FI)
-    { if (DSNode *N = getValueDest(*FI.getOperand(0)).getNode())
+    { if (DSNode *N = getValueDest(FI.getOperand(0)).getNode())
         N->setHeapMarker();
     }
 
@@ -129,7 +129,7 @@
       for (Function::arg_iterator I = f.arg_begin(), E = f.arg_end();
            I != E; ++I) {
         if (isa<PointerType>(I->getType())) {
-          DSNode * Node = getValueDest(*I).getNode();
+          DSNode * Node = getValueDest(I).getNode();
 
           if (!f.hasInternalLinkage())
             Node->setExternalMarker();
@@ -167,7 +167,7 @@
     {}
 
     void mergeInGlobalInitializer(GlobalVariable *GV);
-    void mergeFunction(Function& F) { getValueDest(F); }
+    void mergeFunction(Function* F) { getValueDest(F); }
   };
 
   /// Traverse the whole DSGraph, and propagate the unknown flags through all 
@@ -200,8 +200,7 @@
 ///
 /// getValueDest - Return the DSNode that the actual value points to.
 ///
-DSNodeHandle GraphBuilder::getValueDest(Value &Val) {
-  Value *V = &Val;
+DSNodeHandle GraphBuilder::getValueDest(Value* V) {
   if (isa<Constant>(V) && cast<Constant>(V)->isNullValue()) 
     return 0;  // Null doesn't point to anything, don't add to ScalarMap!
 
@@ -218,14 +217,16 @@
     N = createNode(GV->getType()->getElementType());
     N->addGlobal(GV);
   } else if (Function* GV = dyn_cast<Function>(V)) {
-    // Create a new global node for this global variable.
+    // Create a new global node for this function.
     N = createNode();
     N->addGlobal(GV);
+    if (GV->isDeclaration())
+      N->setExternFuncMarker();
   } else if (Constant *C = dyn_cast<Constant>(V)) {
     if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
       if (CE->isCast()) {
         if (isa<PointerType>(CE->getOperand(0)->getType()))
-          NH = getValueDest(*CE->getOperand(0));
+          NH = getValueDest(CE->getOperand(0));
         else
           NH = createNode()->setUnknownMarker();
       } else if (CE->getOpcode() == Instruction::GetElementPtr) {
@@ -249,10 +250,10 @@
       // According to Andrew, DSA is broken on global aliasing, since it does
       // not handle the aliases of parameters correctly. Here is only a quick
       // fix for some special cases.
-      NH = getValueDest(*(cast<GlobalAlias>(C)->getAliasee()));
+      NH = getValueDest(cast<GlobalAlias>(C)->getAliasee());
       return 0;
     } else {
-      DEBUG(errs() << "Unknown constant: " << *C << "\n");
+      errs() << "Unknown constant: " << *C << "\n";
       assert(0 && "Unknown constant type!");
     }
     N = createNode(); // just create a shadow node
@@ -304,7 +305,7 @@
 
   DSNodeHandle &PNDest = G.getNodeForValue(&PN);
   for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
-    PNDest.mergeWith(getValueDest(*PN.getIncomingValue(i)));
+    PNDest.mergeWith(getValueDest(PN.getIncomingValue(i)));
 }
 
 void GraphBuilder::visitSelectInst(SelectInst &SI) {
@@ -312,14 +313,14 @@
     return; // Only pointer Selects
 
   DSNodeHandle &Dest = G.getNodeForValue(&SI);
-  DSNodeHandle S1 = getValueDest(*SI.getOperand(1));
-  DSNodeHandle S2 = getValueDest(*SI.getOperand(2));
+  DSNodeHandle S1 = getValueDest(SI.getOperand(1));
+  DSNodeHandle S2 = getValueDest(SI.getOperand(2));
   Dest.mergeWith(S1);
   Dest.mergeWith(S2);
 }
 
 void GraphBuilder::visitLoadInst(LoadInst &LI) {
-  DSNodeHandle Ptr = getValueDest(*LI.getOperand(0));
+  DSNodeHandle Ptr = getValueDest(LI.getOperand(0));
 
   if (Ptr.isNull()) return; // Load from null
 
@@ -335,7 +336,7 @@
 
 void GraphBuilder::visitStoreInst(StoreInst &SI) {
   const Type *StoredTy = SI.getOperand(0)->getType();
-  DSNodeHandle Dest = getValueDest(*SI.getOperand(1));
+  DSNodeHandle Dest = getValueDest(SI.getOperand(1));
   if (Dest.isNull()) return;
 
   // Mark that the node is written to...
@@ -346,17 +347,17 @@
 
   // Avoid adding edges from null, or processing non-"pointer" stores
   if (isa<PointerType>(StoredTy))
-    Dest.addEdgeTo(getValueDest(*SI.getOperand(0)));
+    Dest.addEdgeTo(getValueDest(SI.getOperand(0)));
 }
 
 void GraphBuilder::visitReturnInst(ReturnInst &RI) {
   if (RI.getNumOperands() && isa<PointerType>(RI.getOperand(0)->getType()))
-    G.getOrCreateReturnNodeFor(*FB).mergeWith(getValueDest(*RI.getOperand(0)));
+    G.getOrCreateReturnNodeFor(*FB).mergeWith(getValueDest(RI.getOperand(0)));
 }
 
 void GraphBuilder::visitVAArgInst(VAArgInst &I) {
   //FIXME: also updates the argument
-  DSNodeHandle Ptr = getValueDest(*I.getOperand(0));
+  DSNodeHandle Ptr = getValueDest(I.getOperand(0));
   if (Ptr.isNull()) return;
 
   // Make that the node is read and written
@@ -377,14 +378,14 @@
 }
 
 void GraphBuilder::visitPtrToIntInst(PtrToIntInst& I) {
-  if (DSNode* N = getValueDest(*I.getOperand(0)).getNode())
+  if (DSNode* N = getValueDest(I.getOperand(0)).getNode())
     N->setPtrToIntMarker();
 }
 
 
 void GraphBuilder::visitBitCastInst(BitCastInst &I) {
   if (!isa<PointerType>(I.getType())) return; // Only pointers
-  DSNodeHandle Ptr = getValueDest(*I.getOperand(0));
+  DSNodeHandle Ptr = getValueDest(I.getOperand(0));
   if (Ptr.isNull()) return;
   setDestTo(I, Ptr);
 }
@@ -397,8 +398,8 @@
   setDestTo(I, createNode()->setAllocaMarker());
 
   const Type *StoredTy = I.getInsertedValueOperand()->getType();
-  DSNodeHandle Dest = getValueDest(I);
-  Dest.mergeWith(getValueDest(*I.getAggregateOperand()));
+  DSNodeHandle Dest = getValueDest(&I);
+  Dest.mergeWith(getValueDest(I.getAggregateOperand()));
 
   // Mark that the node is written to...
   Dest.getNode()->setModifiedMarker();
@@ -409,11 +410,11 @@
 
   // Avoid adding edges from null, or processing non-"pointer" stores
   if (isa<PointerType>(StoredTy))
-    Dest.addEdgeTo(getValueDest(*I.getInsertedValueOperand()));
+    Dest.addEdgeTo(getValueDest(I.getInsertedValueOperand()));
 }
 
 void GraphBuilder::visitExtractValueInst(ExtractValueInst& I) {
-  DSNodeHandle Ptr = getValueDest(*I.getOperand(0));
+  DSNodeHandle Ptr = getValueDest(I.getOperand(0));
 
   // Make that the node is read from...
   Ptr.getNode()->setReadMarker();
@@ -427,7 +428,7 @@
 }
 
 void GraphBuilder::visitGetElementPtrInst(User &GEP) {
-  DSNodeHandle Value = getValueDest(*GEP.getOperand(0));
+  DSNodeHandle Value = getValueDest(GEP.getOperand(0));
   if (Value.isNull())
     Value = createNode();
 
@@ -594,7 +595,7 @@
   switch (F->getIntrinsicID()) {
   case Intrinsic::vastart: {
     // Mark the memory written by the vastart intrinsic as incomplete
-    DSNodeHandle RetNH = getValueDest(**CS.arg_begin());
+    DSNodeHandle RetNH = getValueDest(*CS.arg_begin());
     if (DSNode *N = RetNH.getNode()) {
       N->setModifiedMarker()->setAllocaMarker()->setIncompleteMarker()
        ->setVAStartMarker()->setUnknownMarker()->foldNodeCompletely();
@@ -614,7 +615,7 @@
       Value * Operand = CS.getInstruction()->getOperand(1);
       if (CastInst * CI = dyn_cast<CastInst>(Operand))
         Operand = CI->getOperand (0);
-      RetNH = getValueDest(*Operand);
+      RetNH = getValueDest(Operand);
       if (DSNode *N = RetNH.getNode()) {
         N->setModifiedMarker()->setAllocaMarker()->setIncompleteMarker()
          ->setVAStartMarker()->setUnknownMarker()->foldNodeCompletely();
@@ -624,8 +625,8 @@
     return true;
   }
   case Intrinsic::vacopy:
-    getValueDest(*CS.getInstruction()).
-      mergeWith(getValueDest(**(CS.arg_begin())));
+    getValueDest(CS.getInstruction()).
+      mergeWith(getValueDest(*(CS.arg_begin())));
     return true;
   case Intrinsic::stacksave: {
     DSNode * Node = createNode();
@@ -635,10 +636,10 @@
     return true;
   }
   case Intrinsic::stackrestore:
-    getValueDest(*CS.getInstruction()).getNode()->setAllocaMarker()
-                                                ->setIncompleteMarker()
-                                                ->setUnknownMarker()
-                                                ->foldNodeCompletely();
+    getValueDest(CS.getInstruction()).getNode()->setAllocaMarker()
+                                               ->setIncompleteMarker()
+                                               ->setUnknownMarker()
+                                               ->foldNodeCompletely();
     return true;
   case Intrinsic::vaend:
   case Intrinsic::dbg_func_start:
@@ -651,15 +652,15 @@
   case Intrinsic::memmove: {
     // 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)));
+    DSNodeHandle RetNH = getValueDest(*CS.arg_begin());
+    RetNH.mergeWith(getValueDest(*(CS.arg_begin()+1)));
     if (DSNode *N = RetNH.getNode())
       N->setModifiedMarker()->setReadMarker();
     return true;
   }
   case Intrinsic::memset:
     // Mark the memory modified.
-    if (DSNode *N = getValueDest(**CS.arg_begin()).getNode())
+    if (DSNode *N = getValueDest(*CS.arg_begin()).getNode())
       N->setModifiedMarker();
     return true;
 
@@ -672,13 +673,13 @@
   }
 
   case Intrinsic::atomic_cmp_swap: {
-    DSNodeHandle Ptr = getValueDest(**CS.arg_begin());
+    DSNodeHandle Ptr = getValueDest(*CS.arg_begin());
     Ptr.getNode()->setReadMarker();
     Ptr.getNode()->setModifiedMarker();
     if (isa<PointerType>(F->getReturnType())) {
-      setDestTo(*(CS.getInstruction()), getValueDest(**(CS.arg_begin() + 1)));
-      getValueDest(**(CS.arg_begin() + 1))
-        .mergeWith(getValueDest(**(CS.arg_begin() + 2)));
+      setDestTo(*(CS.getInstruction()), getValueDest(*(CS.arg_begin() + 1)));
+      getValueDest(*(CS.arg_begin() + 1))
+        .mergeWith(getValueDest(*(CS.arg_begin() + 2)));
     }
   }
   case Intrinsic::atomic_swap:
@@ -693,11 +694,11 @@
   case Intrinsic::atomic_load_umax:
   case Intrinsic::atomic_load_umin:
     {
-      DSNodeHandle Ptr = getValueDest(**CS.arg_begin());
+      DSNodeHandle Ptr = getValueDest(*CS.arg_begin());
       Ptr.getNode()->setReadMarker();
       Ptr.getNode()->setModifiedMarker();
       if (isa<PointerType>(F->getReturnType()))
-        setDestTo(*(CS.getInstruction()), getValueDest(**(CS.arg_begin() + 1)));
+        setDestTo(*CS.getInstruction(), getValueDest(*(CS.arg_begin() + 1)));
     }
    
               
@@ -753,7 +754,7 @@
   DSNodeHandle RetVal;
   Instruction *I = CS.getInstruction();
   if (isa<PointerType>(I->getType()))
-    RetVal = getValueDest(*I);
+    RetVal = getValueDest(I);
 
   if (!isa<Function>(Callee))
     if (ConstantExpr* EX = dyn_cast<ConstantExpr>(Callee))
@@ -762,7 +763,7 @@
 
   DSNode *CalleeNode = 0;
   if (!isa<Function>(Callee)) {
-    CalleeNode = getValueDest(*Callee).getNode();
+    CalleeNode = getValueDest(Callee).getNode();
     if (CalleeNode == 0) {
       DEBUG(errs() << "WARNING: Program is calling through a null pointer?\n" << *I);
       return;  // Calling a null pointer?
@@ -775,7 +776,7 @@
   // Calculate the arguments vector...
   for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); I != E; ++I)
     if (isa<PointerType>((*I)->getType()))
-      Args.push_back(getValueDest(**I));
+      Args.push_back(getValueDest(*I));
 
   // Add a new function call entry...
   if (CalleeNode) {
@@ -792,10 +793,10 @@
 void GraphBuilder::visitInstruction(Instruction &Inst) {
   DSNodeHandle CurNode;
   if (isa<PointerType>(Inst.getType()))
-    CurNode = getValueDest(Inst);
+    CurNode = getValueDest(&Inst);
   for (User::op_iterator I = Inst.op_begin(), E = Inst.op_end(); I != E; ++I)
     if (isa<PointerType>((*I)->getType()))
-      CurNode.mergeWith(getValueDest(**I));
+      CurNode.mergeWith(getValueDest(*I));
 
   if (DSNode *N = CurNode.getNode())
     N->setUnknownMarker();
@@ -816,7 +817,7 @@
 
   if (isa<PointerType>(Ty)) {
     // Avoid adding edges from null, or processing non-"pointer" stores
-    NH.addEdgeTo(getValueDest(*C));
+    NH.addEdgeTo(getValueDest(C));
     return;
   }
 
@@ -853,7 +854,7 @@
 void GraphBuilder::mergeInGlobalInitializer(GlobalVariable *GV) {
   assert(!GV->isDeclaration() && "Cannot merge in external global!");
   // Get a node handle to the global node and merge the initializer into it.
-  DSNodeHandle NH = getValueDest(*GV);
+  DSNodeHandle NH = getValueDest(GV);
   MergeConstantInitIntoNode(NH, GV->getType()->getElementType(), GV->getInitializer());
 }
 
@@ -874,7 +875,7 @@
     // Add Functions to the globals graph.
     for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
       if (!I->isDeclaration() && I->hasAddressTaken())
-        GGB.mergeFunction(*I);
+        GGB.mergeFunction(I);
   }
 
   // Next step, iterate through the nodes in the globals graph, unioning





More information about the llvm-commits mailing list