From 923fc05b3a95efad270b283f97b2670152a41efb Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 5 Feb 2003 21:59:58 +0000 Subject: 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 --- lib/Analysis/DataStructure/Local.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/Analysis/DataStructure/Local.cpp') 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 + 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(CI.getOperand(0))) + Callee = getValueDest(*CI.getOperand(0)).getNode(); std::vector 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(CI.getOperand(0)), Args)); } void GraphBuilder::visitFreeInst(FreeInst &FI) { -- cgit v1.2.3