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/Local.cpp | |
parent | bbe5ac1458f3719fd51785f086e9166ccbb0c464 (diff) |
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/Local.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/Local.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index a4e7b63181..d56ad01f0a 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -19,6 +19,7 @@ #include "llvm/Target/TargetData.h" #include "Support/Statistic.h" #include "Support/Timer.h" +#include "Support/CommandLine.h" // FIXME: This should eventually be a FunctionPass that is automatically // aggregated into a Pass. @@ -45,6 +46,11 @@ using namespace DS; namespace { + cl::opt<bool> + DisableDirectCallOpt("disable-direct-call-dsopt", cl::Hidden, + cl::desc("Disable direct call optimization in " + "DSGraph construction")); + //===--------------------------------------------------------------------===// // GraphBuilder Class //===--------------------------------------------------------------------===// @@ -375,7 +381,9 @@ void GraphBuilder::visitCallInst(CallInst &CI) { if (isPointerType(CI.getType())) RetVal = getValueDest(CI); - DSNodeHandle Callee = getValueDest(*CI.getOperand(0)); + DSNode *Callee = 0; + if (DisableDirectCallOpt || !isa<Function>(CI.getOperand(0))) + Callee = getValueDest(*CI.getOperand(0)).getNode(); std::vector<DSNodeHandle> Args; Args.reserve(CI.getNumOperands()-1); @@ -386,7 +394,11 @@ void GraphBuilder::visitCallInst(CallInst &CI) { Args.push_back(getValueDest(*CI.getOperand(i))); // Add a new function call entry... - FunctionCalls.push_back(DSCallSite(CI, RetVal, Callee, Args)); + if (Callee) + FunctionCalls.push_back(DSCallSite(CI, RetVal, Callee, Args)); + else + FunctionCalls.push_back(DSCallSite(CI, RetVal, + cast<Function>(CI.getOperand(0)), Args)); } void GraphBuilder::visitFreeInst(FreeInst &FI) { |