aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-10-21 15:04:18 +0000
committerChris Lattner <sabre@nondot.org>2002-10-21 15:04:18 +0000
commit99a22847ba3bb8e868fd13cc1d0ca30fff956e57 (patch)
tree4806dc77b9665cf04180c25edd822c86d517e44d /lib/Analysis/DataStructure
parent448f4949dc686d22feb81281560f1c43bca15639 (diff)
As it turns out, we don't need a fully generic mapping copy ctor, we just need
something that maps through a std::map. Since this simplified the client and implementation code, do so now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure')
-rw-r--r--lib/Analysis/DataStructure/DataStructure.cpp20
-rw-r--r--lib/Analysis/DataStructure/TopDownClosure.cpp24
2 files changed, 8 insertions, 36 deletions
diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp
index d40be44811..cc0b8d8fc5 100644
--- a/lib/Analysis/DataStructure/DataStructure.cpp
+++ b/lib/Analysis/DataStructure/DataStructure.cpp
@@ -361,18 +361,6 @@ Function &DSCallSite::getCaller() const {
return *Inst->getParent()->getParent();
}
-template <typename CopyFunctor>
-DSCallSite::DSCallSite(const DSCallSite &FromCall, CopyFunctor nodeCopier)
- : Inst(FromCall.Inst) {
-
- RetVal = nodeCopier(&FromCall.RetVal);
- Callee = nodeCopier(&FromCall.Callee);
-
- CallArgs.reserve(FromCall.CallArgs.size());
- for (unsigned j = 0, ej = FromCall.CallArgs.size(); j != ej; ++j)
- CallArgs.push_back(nodeCopier(&FromCall.CallArgs[j]));
-}
-
//===----------------------------------------------------------------------===//
// DSGraph Implementation
@@ -402,11 +390,6 @@ DSGraph::~DSGraph() {
void DSGraph::dump() const { print(std::cerr); }
-static DSNodeHandle copyHelper(const DSNodeHandle* fromNode,
- std::map<const DSNode*, DSNode*> *NodeMap) {
- return DSNodeHandle((*NodeMap)[fromNode->getNode()], fromNode->getOffset());
-}
-
// Helper function used to clone a function list.
//
static void CopyFunctionCallsList(const vector<DSCallSite>& fromCalls,
@@ -415,8 +398,7 @@ static void CopyFunctionCallsList(const vector<DSCallSite>& fromCalls,
unsigned FC = toCalls.size(); // FirstCall
toCalls.reserve(FC+fromCalls.size());
for (unsigned i = 0, ei = fromCalls.size(); i != ei; ++i)
- toCalls.push_back(DSCallSite(fromCalls[i],
- std::bind2nd(std::ptr_fun(&copyHelper), &NodeMap)));
+ toCalls.push_back(DSCallSite(fromCalls[i], NodeMap));
}
/// remapLinks - Change all of the Links in the current node according to the
diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp
index e8a720eb66..653d2ca8f6 100644
--- a/lib/Analysis/DataStructure/TopDownClosure.cpp
+++ b/lib/Analysis/DataStructure/TopDownClosure.cpp
@@ -57,8 +57,8 @@ void TDDataStructures::ResolveCallSite(DSGraph &Graph,
// TD ...Merge the formal arg scalar with the actual arg node
DSNodeHandle &NodeForFormal = Graph.getNodeForValue(AI);
- if (NodeForFormal.getNode())
- NodeForFormal.mergeWith(CallSite.getPtrArg(i));
+ assert(NodeForFormal.getNode() && "Pointer argument has no dest node!");
+ NodeForFormal.mergeWith(CallSite.getPtrArg(i));
}
// Merge returned node in the caller with the "return" node in callee
@@ -67,12 +67,6 @@ void TDDataStructures::ResolveCallSite(DSGraph &Graph,
}
-static DSNodeHandle copyHelper(const DSNodeHandle* fromNode,
- std::map<const DSNode*, DSNode*> *NodeMap) {
- return DSNodeHandle((*NodeMap)[fromNode->getNode()], fromNode->getOffset());
-}
-
-
DSGraph &TDDataStructures::calculateGraph(Function &F) {
// Make sure this graph has not already been calculated, or that we don't get
// into an infinite loop with mutually recursive functions.
@@ -103,12 +97,9 @@ DSGraph &TDDataStructures::calculateGraph(Function &F) {
DEBUG(std::cerr << "\t [TD] Inlining caller #" << c << " '"
<< Caller.getName() << "' into callee: " << F.getName() << "\n");
- if (&Caller == &F) {
- // Self-recursive call: this can happen after a cycle of calls is inlined.
- ResolveCallSite(*Graph, CallSite);
- } else {
- // Recursively compute the graph for the Caller. That should
- // be fully resolved except if there is mutual recursion...
+ if (&Caller != &F) {
+ // Recursively compute the graph for the Caller. It should be fully
+ // resolved except if there is mutual recursion...
//
DSGraph &CG = calculateGraph(Caller); // Graph to inline
@@ -133,10 +124,9 @@ DSGraph &TDDataStructures::calculateGraph(Function &F) {
// Make a temporary copy of the call site, and transform the argument node
// pointers.
- DSCallSite TmpCallSite(CallSite, std::bind2nd(std::ptr_fun(&copyHelper),
- &OldNodeMap));
- ResolveCallSite(*Graph, CallSite);
+ //
}
+ ResolveCallSite(*Graph, CallSite);
}
// Recompute the Incomplete markers and eliminate unreachable nodes.