[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Feb 15 10:41:08 PST 2005



Changes in directory llvm/lib/Analysis/DataStructure:

DataStructure.cpp updated: 1.191 -> 1.192
---
Log message:

Add a new method to make it easy to update graphs.



---
Diffs of the changes:  (+23 -1)

 DataStructure.cpp |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletion(-)


Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.191 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.192
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.191	Tue Feb  8 21:20:43 2005
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp	Tue Feb 15 12:40:55 2005
@@ -147,7 +147,6 @@
     std::lower_bound(Globals.begin(), Globals.end(), GV);
 
   if (I == Globals.end() || *I != GV) {
-    //assert(GV->getType()->getElementType() == Ty);
     Globals.insert(I, GV);
     NodeType |= GlobalNode;
   }
@@ -1141,6 +1140,29 @@
     }
 }
 
+/// addObjectToGraph - This method can be used to add global, stack, and heap
+/// objects to the graph.  This can be used when updating DSGraphs due to the
+/// introduction of new temporary objects.  The new object is not pointed to
+/// and does not point to any other objects in the graph.
+DSNode *DSGraph::addObjectToGraph(Value *Ptr, bool UseDeclaredType) {
+  assert(isa<PointerType>(Ptr->getType()) && "Ptr is not a pointer!");
+  const Type *Ty = cast<PointerType>(Ptr->getType())->getElementType();
+  DSNode *N = new DSNode(UseDeclaredType ? Ty : 0, this);
+  ScalarMap[Ptr] = N;
+
+  if (GlobalValue *GV = dyn_cast<GlobalValue>(Ptr)) {
+    N->addGlobal(GV);
+  } else if (MallocInst *MI = dyn_cast<MallocInst>(Ptr)) {
+    N->setHeapNodeMarker();
+  } else if (AllocaInst *AI = dyn_cast<AllocaInst>(Ptr)) {
+    N->setAllocaNodeMarker();
+  } else {
+    assert(0 && "Illegal memory object input!");
+  }
+  return N;
+}
+
+
 /// cloneInto - Clone the specified DSGraph into the current graph.  The
 /// translated ScalarMap for the old function is filled into the OldValMap
 /// member, and the translated ReturnNodes map is returned into ReturnNodes.






More information about the llvm-commits mailing list