diff options
author | Chris Lattner <sabre@nondot.org> | 2004-02-26 22:07:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-02-26 22:07:22 +0000 |
commit | 5ef1638da25ae168632ecaac0cef7f6b80167a01 (patch) | |
tree | ea095b33a0a6456e97436b6c98e529423ce3fb71 /llvm/lib/Analysis/DataStructure/Local.cpp | |
parent | 61719d48d2cec6fbfcd68a4a7aabf12a0a681b38 (diff) | |
download | bcm5719-llvm-5ef1638da25ae168632ecaac0cef7f6b80167a01.tar.gz bcm5719-llvm-5ef1638da25ae168632ecaac0cef7f6b80167a01.zip |
Be a good little compiler and handle direct calls efficiently, even if there
are beastly ConstantPointerRefs in the way...
llvm-svn: 11883
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/Local.cpp')
-rw-r--r-- | llvm/lib/Analysis/DataStructure/Local.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/DataStructure/Local.cpp b/llvm/lib/Analysis/DataStructure/Local.cpp index 6760c3704d2..791a1b4e5a5 100644 --- a/llvm/lib/Analysis/DataStructure/Local.cpp +++ b/llvm/lib/Analysis/DataStructure/Local.cpp @@ -465,8 +465,12 @@ void GraphBuilder::visitInvokeInst(InvokeInst &II) { } void GraphBuilder::visitCallSite(CallSite CS) { + Value *Callee = CS.getCalledValue(); + if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Callee)) + Callee = CPR->getValue(); + // Special case handling of certain libc allocation functions here. - if (Function *F = CS.getCalledFunction()) + if (Function *F = dyn_cast<Function>(Callee)) if (F->isExternal()) switch (F->getIntrinsicID()) { case Intrinsic::memmove: @@ -809,12 +813,11 @@ void GraphBuilder::visitCallSite(CallSite CS) { if (isPointerType(I->getType())) RetVal = getValueDest(*I); - DSNode *Callee = 0; - if (DisableDirectCallOpt || !isa<Function>(CS.getCalledValue())) { - Callee = getValueDest(*CS.getCalledValue()).getNode(); - if (Callee == 0) { - std::cerr << "WARNING: Program is calling through a null pointer?\n" - << *I; + DSNode *CalleeNode = 0; + if (DisableDirectCallOpt || !isa<Function>(Callee)) { + CalleeNode = getValueDest(*Callee).getNode(); + if (CalleeNode == 0) { + std::cerr << "WARNING: Program is calling through a null pointer?\n"<< *I; return; // Calling a null pointer? } } @@ -828,10 +831,10 @@ void GraphBuilder::visitCallSite(CallSite CS) { Args.push_back(getValueDest(**I)); // Add a new function call entry... - if (Callee) - FunctionCalls->push_back(DSCallSite(CS, RetVal, Callee, Args)); + if (CalleeNode) + FunctionCalls->push_back(DSCallSite(CS, RetVal, CalleeNode, Args)); else - FunctionCalls->push_back(DSCallSite(CS, RetVal, CS.getCalledFunction(), + FunctionCalls->push_back(DSCallSite(CS, RetVal, cast<Function>(Callee), Args)); } |