Stop representing scalars as explicit nodes in the graph. Now the only
nodes in the graph are memory objects, which is very nice. This also greatly
reduces the size and memory footprint for DSGraphs. For example, the local
DSGraph for llu went from 65 to 13 nodes with this change. As a side bonus,
dot seems to lay out the graphs slightly better too. :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4488 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp
index defd80e..08c86c5 100644
--- a/lib/Analysis/DataStructure/BottomUpClosure.cpp
+++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp
@@ -16,8 +16,7 @@
static RegisterAnalysis<BUDataStructures>
X("budatastructure", "Bottom-up Data Structure Analysis Closure");
-// TODO: FIXME
-namespace DataStructureAnalysis {
+namespace DataStructureAnalysis { // TODO: FIXME: Eliminate
// isPointerType - Return true if this first class type is big enough to hold
// a pointer.
//
@@ -60,14 +59,12 @@
map<Value*, DSNodeHandle> &ValueMap) {
// Resolve all of the function arguments...
Function::aiterator AI = F.abegin();
- for (unsigned i = 0, e = Call.getNumPtrArgs(); i != e; ++i) {
+ for (unsigned i = 0, e = Call.getNumPtrArgs(); i != e; ++i, ++AI) {
// Advance the argument iterator to the first pointer argument...
while (!isPointerType(AI->getType())) ++AI;
// Add the link from the argument scalar to the provided value
- DSNodeHandle &NN = ValueMap[AI];
- NN.addEdgeTo(Call.getPtrArg(i));
- ++AI;
+ ValueMap[AI].mergeWith(Call.getPtrArg(i));
}
}
@@ -118,8 +115,7 @@
DEBUG(std::cerr << "\t[BU] Self Inlining: " << F.getName() << "\n");
// Handle the return value if present...
- if (Call.getRetVal().getNode())
- Graph->getRetNode().mergeWith(Call.getRetVal());
+ Graph->getRetNode().mergeWith(Call.getRetVal());
// Resolve the arguments in the call to the actual values...
ResolveArguments(Call, F, Graph->getValueMap());
@@ -143,11 +139,12 @@
// Record that the original DSCallSite was a call site of FI.
// This may or may not have been known when the DSCallSite was
// originally created.
+#if 1 /// FIXME: Reenable
std::vector<DSCallSite> &CallSitesForFunc = CallSites[&FI];
CallSitesForFunc.push_back(Call);
CallSitesForFunc.back().setResolvingCaller(&F);
CallSitesForFunc.back().setCallee(0);
-
+#endif
// Clone the callee's graph into the current graph, keeping
// track of where scalars in the old graph _used_ to point,
// and of the new nodes matching nodes of the old graph.
@@ -163,8 +160,8 @@
// Resolve the arguments in the call to the actual values...
ResolveArguments(Call, FI, OldValMap);
- if (Call.getRetVal().getNode())// Handle the return value if present
- RetVal.mergeWith(Call.getRetVal());
+ // Handle the return value if present...
+ RetVal.mergeWith(Call.getRetVal());
// Erase the entry in the Callees vector
Callees.erase(Callees.begin()+c--);
@@ -172,9 +169,10 @@
} else if (FI.getName() == "printf" || FI.getName() == "sscanf" ||
FI.getName() == "fprintf" || FI.getName() == "open" ||
FI.getName() == "sprintf") {
- // FIXME: These special cases should go away when we can define
- // functions that take a variable number of arguments.
+ // FIXME: These special cases (eg printf) should go away when we can
+ // define functions that take a variable number of arguments.
+ // FIXME: at the very least, this should update mod/ref info
// Erase the entry in the globals vector
Callees.erase(Callees.begin()+c--);
}