aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis
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
commitef35ff066c8c301acd10db3daa263e119528b260 (patch)
treed0c60fe3bf00738d2966e272c88da94a40c0b60f /lib/Analysis
parentfe14568a8122b7c9b832795594b7bae11b2b6cc4 (diff)
downloadexternal_llvm-ef35ff066c8c301acd10db3daa263e119528b260.zip
external_llvm-ef35ff066c8c301acd10db3daa263e119528b260.tar.gz
external_llvm-ef35ff066c8c301acd10db3daa263e119528b260.tar.bz2
Inline indirect function calls that are only capable of calling one function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2275 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/DataStructure/ComputeClosure.cpp21
-rw-r--r--lib/Analysis/DataStructure/NodeImpl.cpp2
2 files changed, 13 insertions, 10 deletions
diff --git a/lib/Analysis/DataStructure/ComputeClosure.cpp b/lib/Analysis/DataStructure/ComputeClosure.cpp
index 67309e8..4327baa 100644
--- a/lib/Analysis/DataStructure/ComputeClosure.cpp
+++ b/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";
diff --git a/lib/Analysis/DataStructure/NodeImpl.cpp b/lib/Analysis/DataStructure/NodeImpl.cpp
index 4451f6e..66bd889 100644
--- a/lib/Analysis/DataStructure/NodeImpl.cpp
+++ b/lib/Analysis/DataStructure/NodeImpl.cpp
@@ -285,7 +285,7 @@ string CallDSNode::getCaption() const {
OS << "call " << CM->getName();
else
OS << "call <indirect>";
- OS << "|Ret: ";
+ OS << ": ";
WriteTypeSymbolic(OS, getType(),
CI->getParent()->getParent()->getParent());
return OS.str();