[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp DataStructureAA.cpp TopDownClosure.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Jan 24 12:00:29 PST 2005
Changes in directory llvm/lib/Analysis/DataStructure:
BottomUpClosure.cpp updated: 1.84 -> 1.85
DataStructureAA.cpp updated: 1.22 -> 1.23
TopDownClosure.cpp updated: 1.70 -> 1.71
---
Log message:
Make -ds-aa more useful, allowing it to be updated as xforms hack on the program.
---
Diffs of the changes: (+119 -0)
BottomUpClosure.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
DataStructureAA.cpp | 11 ++++++++++
TopDownClosure.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 119 insertions(+)
Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.84 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.85
--- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.84 Mon Nov 8 15:08:46 2004
+++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Mon Jan 24 14:00:14 2005
@@ -331,3 +331,58 @@
//Graph.writeGraphToFile(std::cerr, "bu_" + F.getName());
}
+
+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;
+}
+
+/// deleteValue/copyValue - Interfaces to update the DSGraphs in the program.
+/// These correspond to the interfaces defined in the AliasAnalysis class.
+void BUDataStructures::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 BUDataStructures::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!");
+}
Index: llvm/lib/Analysis/DataStructure/DataStructureAA.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.22 llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.23
--- llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.22 Sun Jan 9 14:42:52 2005
+++ llvm/lib/Analysis/DataStructure/DataStructureAA.cpp Mon Jan 24 14:00:14 2005
@@ -61,6 +61,17 @@
return AliasAnalysis::getModRefInfo(CS1,CS2);
}
+ virtual void deleteValue(Value *V) {
+ BU->deleteValue(V);
+ TD->deleteValue(V);
+ }
+
+ virtual void copyValue(Value *From, Value *To) {
+ if (From == To) return;
+ BU->copyValue(From, To);
+ TD->copyValue(From, To);
+ }
+
private:
DSGraph *getGraphForValue(const Value *V);
};
Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.70 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.71
--- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.70 Sun Sep 19 23:45:25 2004
+++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Mon Jan 24 14:00:14 2005
@@ -290,3 +290,56 @@
<< 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!");
+}
More information about the llvm-commits
mailing list