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 | 219002ed8f5e72fbfda6e29245b852ea01012684 (patch) | |
| tree | 2f1b59fc290130589fea050f02970f0158183663 /llvm/lib/Analysis/DataStructure | |
| parent | 385a47394a7d1426b7bd655740539ec1fe639c58 (diff) | |
| download | bcm5719-llvm-219002ed8f5e72fbfda6e29245b852ea01012684.tar.gz bcm5719-llvm-219002ed8f5e72fbfda6e29245b852ea01012684.zip | |
Add a new method to make it easy to update graphs.
llvm-svn: 20194
Diffstat (limited to 'llvm/lib/Analysis/DataStructure')
| -rw-r--r-- | llvm/lib/Analysis/DataStructure/DataStructure.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/DataStructure/DataStructure.cpp b/llvm/lib/Analysis/DataStructure/DataStructure.cpp index df5530c15df..c0e3ef46b21 100644 --- a/llvm/lib/Analysis/DataStructure/DataStructure.cpp +++ b/llvm/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. |

