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
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp
index a4e7b63..d56ad01 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 @@
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 @@
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 @@
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) {