[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Jul 1 23:39:01 PDT 2003
Changes in directory llvm/lib/Analysis/DataStructure:
DataStructure.cpp updated: 1.111 -> 1.112
---
Log message:
Add support for ParentGraph only when building in debug mode
Minor cleanups, reenable folding of call nodes to external functions
---
Diffs of the changes:
Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.111 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.112
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.111 Tue Jul 1 11:28:11 2003
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Tue Jul 1 23:38:49 2003
@@ -9,6 +9,7 @@
#include "llvm/iOther.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Target/TargetData.h"
+#include "llvm/Assembly/Writer.h"
#include "Support/STLExtras.h"
#include "Support/Statistic.h"
#include "Support/Timer.h"
@@ -50,7 +51,11 @@
//===----------------------------------------------------------------------===//
DSNode::DSNode(const Type *T, DSGraph *G)
- : NumReferrers(0), Size(0), ParentGraph(G), Ty(Type::VoidTy), NodeType(0) {
+ : NumReferrers(0), Size(0),
+#ifdef INCLUDE_PARENT_GRAPH
+ ParentGraph(G),
+#endif
+ Ty(Type::VoidTy), NodeType(0) {
// Add the type entry if it is specified...
if (T) mergeTypeInfo(T, 0);
G->getNodes().push_back(this);
@@ -58,8 +63,11 @@
// DSNode copy constructor... do not copy over the referrers list!
DSNode::DSNode(const DSNode &N, DSGraph *G)
- : NumReferrers(0), Size(N.Size), ParentGraph(G), Ty(N.Ty),
- Links(N.Links), Globals(N.Globals), NodeType(N.NodeType) {
+ : NumReferrers(0), Size(N.Size),
+#ifdef INCLUDE_PARENT_GRAPH
+ ParentGraph(G),
+#endif
+ Ty(N.Ty), Links(N.Links), Globals(N.Globals), NodeType(N.NodeType) {
G->getNodes().push_back(this);
}
@@ -112,7 +120,13 @@
++NumFolds;
// Create the node we are going to forward to...
- DSNode *DestNode = new DSNode(0, ParentGraph);
+ DSNode *DestNode = new DSNode(0,
+#ifdef INCLUDE_PARENT_GRAPH
+ ParentGraph
+#else
+ 0
+#endif
+ );
DestNode->NodeType = NodeType|DSNode::Array;
DestNode->Ty = Type::VoidTy;
DestNode->Size = 1;
@@ -474,9 +488,16 @@
return false;
}
- DEBUG(std::cerr << "MergeTypeInfo Folding OrigTy: " << Ty
- << "\n due to:" << NewTy << " @ " << Offset << "!\n"
- << "SubType: " << SubType << "\n\n");
+ Module *M = 0;
+#ifdef INCLUDE_PARENT_GRAPH
+ if (getParentGraph()->getReturnNodes().size())
+ M = getParentGraph()->getReturnNodes().begin()->first->getParent();
+#endif
+ DEBUG(std::cerr << "MergeTypeInfo Folding OrigTy: ";
+ WriteTypeSymbolic(std::cerr, Ty, M) << "\n due to:";
+ WriteTypeSymbolic(std::cerr, NewTy, M) << " @ " << Offset << "!\n"
+ << "SubType: ";
+ WriteTypeSymbolic(std::cerr, SubType, M) << "\n\n");
if (FoldIfIncompatible) foldNodeCompletely();
return true;
@@ -859,6 +880,9 @@
// structure graph. Strip locals and don't copy the list of callers
ReturnNodesTy OldRetNodes;
cloneInto(Graph, OldValMap, OldRetNodes, OldNodeMap, CloneFlags);
+
+ // We need to map the arguments for the function to the cloned nodes old
+ // argument values. Do this now.
RetVal = OldRetNodes[&F];
ScalarMap = &OldValMap;
} else {
@@ -891,6 +915,20 @@
}
}
+/// getCallSiteForArguments - Get the arguments and return value bindings for
+/// the specified function in the current graph.
+///
+DSCallSite DSGraph::getCallSiteForArguments(Function &F) const {
+ std::vector<DSNodeHandle> Args;
+
+ for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I)
+ if (isPointerType(I->getType()))
+ Args.push_back(getScalarMap().find(I)->second);
+
+ return DSCallSite(*(CallInst*)0, getReturnNodeFor(F), &F, Args);
+}
+
+
// markIncompleteNodes - Mark the specified node as having contents that are not
// known with the current analysis we have performed. Because a node makes all
@@ -1023,7 +1061,7 @@
LastCalleeContainsExternalFunction = LastCalleeFunc->isExternal();
}
-#if 0
+#if 1
if (LastCalleeContainsExternalFunction ||
// This should be more than enough context sensitivity!
// FIXME: Evaluate how many times this is tripped!
@@ -1281,7 +1319,9 @@
if (!(Flags & DSGraph::RemoveUnreachableGlobals) && // Not in TD pass
Visited.count(N)) { // Visited but not alive?
GlobalsGraph->Nodes.push_back(N); // Move node to globals graph
+#ifdef INCLUDE_PARENT_GRAPH
N->setParentGraph(GlobalsGraph);
+#endif
} else { // Otherwise, delete the node
assert((!N->isGlobalNode() ||
(Flags & DSGraph::RemoveUnreachableGlobals))
More information about the llvm-commits
mailing list