From a9548d9fd99beea7d5e4dc6619cb5569b54620c0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 30 Jan 2005 23:51:02 +0000 Subject: * Make some methods more const correct. * Change the FunctionCalls and AuxFunctionCalls vectors into std::lists. This makes many operations on these lists much more natural, and avoids *exteremely* expensive copying of DSCallSites (e.g. moving nodes around between lists, erasing a node from not the end of the vector, etc). With a profile build of analyze, this speeds up BU DS from 25.14s to 12.59s on 176.gcc. I expect that it would help TD even more, but I don't have data for it. This effectively eliminates removeIdenticalCalls and children from the profile, going from 6.53 to 0.27s. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19939 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/DataStructure/TopDownClosure.cpp | 32 ++++++++++++--------------- 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'lib/Analysis/DataStructure/TopDownClosure.cpp') diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index cfcf52e..8c0db6d 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -70,13 +70,11 @@ bool TDDataStructures::runOnModule(Module &M) { // Loop over unresolved call nodes. Any functions passed into (but not // returned!) from unresolvable call nodes may be invoked outside of the // current module. - const std::vector &Calls = GlobalsGraph->getAuxFunctionCalls(); - for (unsigned i = 0, e = Calls.size(); i != e; ++i) { - const DSCallSite &CS = Calls[i]; - for (unsigned arg = 0, e = CS.getNumPtrArgs(); arg != e; ++arg) - markReachableFunctionsExternallyAccessible(CS.getPtrArg(arg).getNode(), + for (DSGraph::afc_iterator I = GlobalsGraph->afc_begin(), + E = GlobalsGraph->afc_end(); I != E; ++I) + for (unsigned arg = 0, e = I->getNumPtrArgs(); arg != e; ++arg) + markReachableFunctionsExternallyAccessible(I->getPtrArg(arg).getNode(), Visited); - } Visited.clear(); // Functions without internal linkage also have unknown incoming arguments! @@ -135,10 +133,8 @@ void TDDataStructures::ComputePostOrder(Function &F,hash_set &Visited, Visited.insert(&G); // Recursively traverse all of the callee graphs. - const std::vector &FunctionCalls = G.getFunctionCalls(); - - for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) { - Instruction *CallI = FunctionCalls[i].getCallSite().getInstruction(); + for (DSGraph::fc_iterator CI = G.fc_begin(), E = G.fc_end(); CI != E; ++CI) { + Instruction *CallI = CI->getCallSite().getInstruction(); std::pair IP = ActualCallees.equal_range(CallI); @@ -211,8 +207,7 @@ void TDDataStructures::inlineGraphIntoCallees(DSGraph &Graph) { // We are done with computing the current TD Graph! Now move on to // inlining the current graph into the graphs for its callees, if any. // - const std::vector &FunctionCalls = Graph.getFunctionCalls(); - if (FunctionCalls.empty()) { + if (Graph.fc_begin() == Graph.fc_end()) { DEBUG(std::cerr << " [TD] No callees for: " << Graph.getFunctionNames() << "\n"); return; @@ -224,7 +219,7 @@ void TDDataStructures::inlineGraphIntoCallees(DSGraph &Graph) { // would be cloned only once, this should still be better on average). // DEBUG(std::cerr << " [TD] Inlining '" << Graph.getFunctionNames() <<"' into " - << FunctionCalls.size() << " call nodes.\n"); + << Graph.getFunctionCalls().size() << " call nodes.\n"); const BUDataStructures::ActualCalleesTy &ActualCallees = getAnalysis().getActualCallees(); @@ -235,12 +230,13 @@ void TDDataStructures::inlineGraphIntoCallees(DSGraph &Graph) { // multiple call sites to the callees in the graph from this caller. std::multimap > CallSites; - for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) { - Instruction *CallI = FunctionCalls[i].getCallSite().getInstruction(); + for (DSGraph::fc_iterator CI = Graph.fc_begin(), E = Graph.fc_end(); + CI != E; ++CI) { + Instruction *CallI = CI->getCallSite().getInstruction(); // For each function in the invoked function list at this call site... std::pair - IP = ActualCallees.equal_range(CallI); + BUDataStructures::ActualCalleesTy::const_iterator> + IP = ActualCallees.equal_range(CallI); // Loop over each actual callee at this call site for (BUDataStructures::ActualCalleesTy::const_iterator I = IP.first; I != IP.second; ++I) { @@ -248,7 +244,7 @@ void TDDataStructures::inlineGraphIntoCallees(DSGraph &Graph) { assert(&CalleeGraph != &Graph && "TD need not inline graph into self!"); CallSites.insert(std::make_pair(&CalleeGraph, - std::make_pair(I->second, &FunctionCalls[i]))); + std::make_pair(I->second, &*CI))); } } -- cgit v1.1