diff options
| author | Chris Lattner <sabre@nondot.org> | 2003-02-05 21:59:58 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2003-02-05 21:59:58 +0000 |
| commit | 923fc05b3a95efad270b283f97b2670152a41efb (patch) | |
| tree | f57c34bd5de4a4e4b59c46847c9da54894f2bf9e /lib/Analysis/DataStructure/TopDownClosure.cpp | |
| parent | bbe5ac1458f3719fd51785f086e9166ccbb0c464 (diff) | |
| download | llvm-923fc05b3a95efad270b283f97b2670152a41efb.tar.gz llvm-923fc05b3a95efad270b283f97b2670152a41efb.tar.bz2 llvm-923fc05b3a95efad270b283f97b2670152a41efb.tar.xz | |
Implement optimization for direct function call case. This dramatically
reduces the number of function nodes created and speeds up analysis by
about 10% overall.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5495 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/TopDownClosure.cpp')
| -rw-r--r-- | lib/Analysis/DataStructure/TopDownClosure.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index 460088f6d2..8df60ba2fa 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -116,17 +116,22 @@ void TDDataStructures::calculateGraph(Function &F) { std::multimap<Function*, const DSCallSite*> CalleeSites; for (unsigned i = 0, e = CallSites.size(); i != e; ++i) { const DSCallSite &CS = CallSites[i]; - const std::vector<GlobalValue*> Callees = - CS.getCallee().getNode()->getGlobals(); - - // Loop over all of the functions that this call may invoke... - for (unsigned c = 0, e = Callees.size(); c != e; ++c) - if (Function *F = dyn_cast<Function>(Callees[c])) // If this is a fn... - if (!F->isExternal()) // If it's not external - CalleeSites.insert(std::make_pair(F, &CS)); // Keep track of it! + if (CS.isDirectCall()) { + if (!CS.getCalleeFunc()->isExternal()) // If it's not external + CalleeSites.insert(std::make_pair(CS.getCalleeFunc(), &CS)); // Keep it + } else { + const std::vector<GlobalValue*> &Callees = + CS.getCalleeNode()->getGlobals(); + + // Loop over all of the functions that this call may invoke... + for (unsigned c = 0, e = Callees.size(); c != e; ++c) + if (Function *F = dyn_cast<Function>(Callees[c])) // If this is a fn... + if (!F->isExternal()) // If it's not extern + CalleeSites.insert(std::make_pair(F, &CS)); // Keep track of it! + } } - // Now that we have information about all of the callees, propogate the + // Now that we have information about all of the callees, propagate the // current graph into the callees. // DEBUG(std::cerr << " [TD] Inlining '" << F.getName() << "' into " |
