diff options
author | Chris Lattner <sabre@nondot.org> | 2005-02-15 18:40:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-02-15 18:40:55 +0000 |
commit | d672ab936f32a6eef0d7a099e6ef6ceb1a131e49 (patch) | |
tree | 359dfd8d520741ad59c3d297be860bfb74016686 /lib/Analysis/DataStructure/DataStructure.cpp | |
parent | 5ad907a5e1b032a89ad0cc48ea75a578cf82ba25 (diff) |
Add a new method to make it easy to update graphs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20194 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/DataStructure.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/DataStructure.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index df5530c15d..c0e3ef46b2 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -147,7 +147,6 @@ void DSNode::addGlobal(GlobalValue *GV) { 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 @@ void DSGraph::updateFromGlobalGraph() { } } +/// 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. |