mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
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
This commit is contained in:
parent
fe14568a81
commit
ef35ff066c
@ -74,12 +74,16 @@ static void ResolveNodeTo(DSNode *Node, const PointerValSet &ToVals) {
|
|||||||
// node that we can inline...
|
// node that we can inline...
|
||||||
//
|
//
|
||||||
static bool isResolvableCallNode(CallDSNode *CN) {
|
static bool isResolvableCallNode(CallDSNode *CN) {
|
||||||
// Only operate on call nodes with direct method calls
|
// Only operate on call nodes with direct function calls
|
||||||
Function *F = CN->getCall()->getCalledFunction();
|
if (CN->getArgValues(0).size() == 1 &&
|
||||||
if (F == 0) return false;
|
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.
|
// Only work on call nodes with direct calls to methods with bodies.
|
||||||
return !F->isExternal();
|
return !F->isExternal();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -100,9 +104,8 @@ void FunctionDSGraph::computeClosure(const DataStructure &DS) {
|
|||||||
NI = std::find_if(CallNodes.begin(), CallNodes.end(), isResolvableCallNode);
|
NI = std::find_if(CallNodes.begin(), CallNodes.end(), isResolvableCallNode);
|
||||||
while (NI != CallNodes.end()) {
|
while (NI != CallNodes.end()) {
|
||||||
CallDSNode *CN = *NI;
|
CallDSNode *CN = *NI;
|
||||||
// FIXME: This should work based on the pointer val set of the first arg
|
GlobalDSNode *FGDN = cast<GlobalDSNode>(CN->getArgValues(0)[0].Node);
|
||||||
// link (which is the function to call)
|
Function *F = cast<Function>(FGDN->getGlobal());
|
||||||
Function *F = CN->getCall()->getCalledFunction();
|
|
||||||
|
|
||||||
if (NumInlines++ == 100) { // CUTE hack huh?
|
if (NumInlines++ == 100) { // CUTE hack huh?
|
||||||
cerr << "Infinite (?) recursion halted\n";
|
cerr << "Infinite (?) recursion halted\n";
|
||||||
|
@ -285,7 +285,7 @@ string CallDSNode::getCaption() const {
|
|||||||
OS << "call " << CM->getName();
|
OS << "call " << CM->getName();
|
||||||
else
|
else
|
||||||
OS << "call <indirect>";
|
OS << "call <indirect>";
|
||||||
OS << "|Ret: ";
|
OS << ": ";
|
||||||
WriteTypeSymbolic(OS, getType(),
|
WriteTypeSymbolic(OS, getType(),
|
||||||
CI->getParent()->getParent()->getParent());
|
CI->getParent()->getParent()->getParent());
|
||||||
return OS.str();
|
return OS.str();
|
||||||
|
Loading…
Reference in New Issue
Block a user