summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DataStructure/ComputeClosure.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-17 03:42:51 +0000
committerChris Lattner <sabre@nondot.org>2002-04-17 03:42:51 +0000
commitbda898420b56049d374319cd9d1d0baf7f4695d6 (patch)
treefee1f9c135872930f44e605f4b1322eba65f595c /llvm/lib/Analysis/DataStructure/ComputeClosure.cpp
parent79db55028c50a275f38264b11c2ae9bff5daa348 (diff)
downloadbcm5719-llvm-bda898420b56049d374319cd9d1d0baf7f4695d6.tar.gz
bcm5719-llvm-bda898420b56049d374319cd9d1d0baf7f4695d6.zip
Inline indirect function calls that are only capable of calling one function
llvm-svn: 2275
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/ComputeClosure.cpp')
-rw-r--r--llvm/lib/Analysis/DataStructure/ComputeClosure.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/llvm/lib/Analysis/DataStructure/ComputeClosure.cpp b/llvm/lib/Analysis/DataStructure/ComputeClosure.cpp
index 67309e8c77d..4327baaa80b 100644
--- a/llvm/lib/Analysis/DataStructure/ComputeClosure.cpp
+++ b/llvm/lib/Analysis/DataStructure/ComputeClosure.cpp
@@ -74,12 +74,16 @@ static void ResolveNodeTo(DSNode *Node, const PointerValSet &ToVals) {
// node that we can inline...
//
static bool isResolvableCallNode(CallDSNode *CN) {
- // Only operate on call nodes with direct method calls
- Function *F = CN->getCall()->getCalledFunction();
- if (F == 0) return false;
-
- // Only work on call nodes with direct calls to methods with bodies.
- return !F->isExternal();
+ // Only operate on call nodes with direct function calls
+ if (CN->getArgValues(0).size() == 1 &&
+ isa<GlobalDSNode>(CN->getArgValues(0)[0].Node)) {
+ GlobalDSNode *GDN = cast<GlobalDSNode>(CN->getArgValues(0)[0].Node);
+ Function *F = cast<Function>(GDN->getGlobal());
+
+ // Only work on call nodes with direct calls to methods with bodies.
+ return !F->isExternal();
+ }
+ return false;
}
@@ -100,9 +104,8 @@ void FunctionDSGraph::computeClosure(const DataStructure &DS) {
NI = std::find_if(CallNodes.begin(), CallNodes.end(), isResolvableCallNode);
while (NI != CallNodes.end()) {
CallDSNode *CN = *NI;
- // FIXME: This should work based on the pointer val set of the first arg
- // link (which is the function to call)
- Function *F = CN->getCall()->getCalledFunction();
+ GlobalDSNode *FGDN = cast<GlobalDSNode>(CN->getArgValues(0)[0].Node);
+ Function *F = cast<Function>(FGDN->getGlobal());
if (NumInlines++ == 100) { // CUTE hack huh?
cerr << "Infinite (?) recursion halted\n";
OpenPOWER on IntegriCloud