diff options
author | Chris Lattner <sabre@nondot.org> | 2005-01-24 20:00:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-01-24 20:00:14 +0000 |
commit | 851b534b8986027a40a991c58c327d819949be00 (patch) | |
tree | f146d0a863f0242bcebc72dee9e8ac83edd59de4 /lib/Analysis/DataStructure/TopDownClosure.cpp | |
parent | d5af7c4df6b9e18c017ab0138c02f687d5dc84a0 (diff) |
Make -ds-aa more useful, allowing it to be updated as xforms hack on the program.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19818 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/TopDownClosure.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/TopDownClosure.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index 6271980737..cfcf52ea58 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -290,3 +290,56 @@ void TDDataStructures::inlineGraphIntoCallees(DSGraph &Graph) { << Graph.getFunctionNames() << " [" << Graph.getGraphSize() << "+" << Graph.getFunctionCalls().size() << "]\n"); } + +static const Function *getFnForValue(const Value *V) { + if (const Instruction *I = dyn_cast<Instruction>(V)) + return I->getParent()->getParent(); + else if (const Argument *A = dyn_cast<Argument>(V)) + return A->getParent(); + else if (const BasicBlock *BB = dyn_cast<BasicBlock>(V)) + return BB->getParent(); + return 0; +} + +void TDDataStructures::deleteValue(Value *V) { + if (const Function *F = getFnForValue(V)) { // Function local value? + // If this is a function local value, just delete it from the scalar map! + getDSGraph(*F).getScalarMap().eraseIfExists(V); + return; + } + + if (Function *F = dyn_cast<Function>(F)) { + assert(getDSGraph(*F).getReturnNodes().size() == 1 && + "cannot handle scc's"); + delete DSInfo[F]; + DSInfo.erase(F); + return; + } + + assert(!isa<GlobalVariable>(V) && "Do not know how to delete GV's yet!"); +} + +void TDDataStructures::copyValue(Value *From, Value *To) { + if (From == To) return; + if (const Function *F = getFnForValue(From)) { // Function local value? + // If this is a function local value, just delete it from the scalar map! + getDSGraph(*F).getScalarMap().copyScalarIfExists(From, To); + return; + } + + if (Function *FromF = dyn_cast<Function>(From)) { + Function *ToF = cast<Function>(To); + assert(!DSInfo.count(ToF) && "New Function already exists!"); + DSGraph *NG = new DSGraph(getDSGraph(*FromF)); + DSInfo[ToF] = NG; + assert(NG->getReturnNodes().size() == 1 && "Cannot copy SCC's yet!"); + + // Change the Function* is the returnnodes map to the ToF. + DSNodeHandle Ret = NG->getReturnNodes().begin()->second; + NG->getReturnNodes().clear(); + NG->getReturnNodes()[ToF] = Ret; + return; + } + + assert(!isa<GlobalVariable>(From) && "Do not know how to copy GV's yet!"); +} |