コード例 #1
0
ファイル: CallGraph.cpp プロジェクト: dshah22/swift
void CallGraph::printStats(llvm::raw_ostream &OS) {
  Histogram<256> CallSitesPerFunction;
  Histogram<256> CallersPerFunction;
  Histogram<256> CalleesPerCallSite;
  unsigned CountNodes = 0;
  unsigned CountCallSites = 0;

  auto const &Funcs = getBottomUpFunctionOrder();
  for (auto *F : Funcs) {
    ++CountNodes;
    auto *Node = getCallGraphNode(F);
    if (Node) {
      CallSitesPerFunction.increment(Node->getCalleeEdges().size());
      CallersPerFunction.increment(Node->getCallerEdges().size());

      CountCallSites += Node->getCalleeEdges().size();

      for (auto *Edge : Node->getCalleeEdges())
        CalleesPerCallSite.increment(Edge->getCalleeSet().size());
    } else {
      OS << "!!! Missing node for " << F->getName() << "!!!";
    }
  }

  OS << CallGraphFileCheckPrefix << "*** Call Graph Statistics ***\n";

  OS << CallGraphFileCheckPrefix << "Number of call graph nodes: " <<
    CountNodes << "\n";
  OS << CallGraphFileCheckPrefix << "Number of call graph edges: " <<
    CountCallSites << "\n";

  OS << CallGraphFileCheckPrefix <<
    "Histogram of number of call sites per function:\n";
  CallSitesPerFunction.print(OS);

  OS << CallGraphFileCheckPrefix <<
    "Histogram of number of callees per call site:\n";
  CalleesPerCallSite.print(OS);

  OS << CallGraphFileCheckPrefix <<
    "Histogram of number of callers per function:\n";
  CallersPerFunction.print(OS);

  OS << CallGraphFileCheckPrefix << "Bump pointer allocated memory (bytes): " <<
    Allocator.getTotalMemory() << "\n";

  OS << CallGraphFileCheckPrefix << "Number of callee sets allocated: " <<
    CalleeSetCache.size() << "\n";
}