//===- DSGraphStats.cpp - Various statistics for DS Graphs ----------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/InstVisitor.h"
#include "Support/Statistic.h"
#include <vector>
+using namespace llvm;
namespace {
Statistic<> TotalNumCallees("totalcallees",
const DSGraph *TDGraph;
DSNode *getNodeForValue(Value *V);
+ bool isNodeForValueCollapsed(Value *V);
public:
/// Driver functions to compute the Load/Store Dep. Graph per function.
bool runOnFunction(Function& F);
const std::vector<DSCallSite> &callSites = TDGraph->getFunctionCalls();
for (unsigned i = 0, N = callSites.size(); i != N; ++i)
- if (isIndirectCallee(callSites[i].getCallInst().getCalledValue())) {
+ if (isIndirectCallee(callSites[i].getCallSite().getCalledValue())) {
// This is an indirect function call
const std::vector<GlobalValue*> &Callees =
callSites[i].getCalleeNode()->getGlobals();
totalNumCallees += Callees.size();
++numIndirectCalls;
} else
- std::cerr << "WARNING: No callee in Function " << F.getName()
- << "at call:\n" << callSites[i].getCallInst();
+ std::cerr << "WARNING: No callee in Function '" << F.getName()
+ << "' at call: \n"
+ << *callSites[i].getCallSite().getInstruction();
}
TotalNumCallees += totalNumCallees;
DSNode *DSGraphStats::getNodeForValue(Value *V) {
const DSGraph *G = TDGraph;
- if (isa<GlobalValue>(V))
+ if (isa<GlobalValue>(V) || isa<Constant>(V))
G = TDGraph->getGlobalsGraph();
- return G->getNodeForValue(V).getNode();
+ const DSGraph::ScalarMapTy &ScalarMap = G->getScalarMap();
+ DSGraph::ScalarMapTy::const_iterator I = ScalarMap.find(V);
+ if (I != ScalarMap.end())
+ return I->second.getNode();
+ return 0;
+}
+
+bool DSGraphStats::isNodeForValueCollapsed(Value *V) {
+ if (DSNode *N = getNodeForValue(V))
+ return N->isNodeCompletelyFolded() || N->isIncomplete();
+ return false;
}
void DSGraphStats::visitLoad(LoadInst &LI) {
- if (getNodeForValue(LI.getOperand(0))->isNodeCompletelyFolded()) {
+ if (isNodeForValueCollapsed(LI.getOperand(0))) {
NumUntypedMemAccesses++;
} else {
NumTypedMemAccesses++;
}
void DSGraphStats::visitStore(StoreInst &SI) {
- if (getNodeForValue(SI.getOperand(1))->isNodeCompletelyFolded()) {
+ if (isNodeForValueCollapsed(SI.getOperand(1))) {
NumUntypedMemAccesses++;
} else {
NumTypedMemAccesses++;