git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206730
91177308-0d34-0410-b5e6-
96231b3b80d8
//
//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "lcg"
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
// alias. Then a test of the address of the weak function against the new
// strong definition's address would be an effective way to determine the
// safety of optimizing a direct call edge.
// alias. Then a test of the address of the weak function against the new
// strong definition's address would be an effective way to determine the
// safety of optimizing a direct call edge.
- if (!F->isDeclaration() && CalleeSet.insert(F))
+ if (!F->isDeclaration() && CalleeSet.insert(F)) {
+ DEBUG(dbgs() << " Added callable function: " << F->getName()
+ << "\n");
LazyCallGraph::Node::Node(LazyCallGraph &G, Function &F)
: G(&G), F(F), DFSNumber(0), LowLink(0) {
LazyCallGraph::Node::Node(LazyCallGraph &G, Function &F)
: G(&G), F(F), DFSNumber(0), LowLink(0) {
+ DEBUG(dbgs() << " Adding functions called by '" << F.getName()
+ << "' to the graph.\n");
+
SmallVector<Constant *, 16> Worklist;
SmallPtrSet<Constant *, 16> Visited;
// Find all the potential callees in this function. First walk the
SmallVector<Constant *, 16> Worklist;
SmallPtrSet<Constant *, 16> Visited;
// Find all the potential callees in this function. First walk the
}
LazyCallGraph::LazyCallGraph(Module &M) : NextDFSNumber(0) {
}
LazyCallGraph::LazyCallGraph(Module &M) : NextDFSNumber(0) {
+ DEBUG(dbgs() << "Building CG for module: " << M.getModuleIdentifier()
+ << "\n");
for (Function &F : M)
if (!F.isDeclaration() && !F.hasLocalLinkage())
for (Function &F : M)
if (!F.isDeclaration() && !F.hasLocalLinkage())
- if (EntryNodeSet.insert(&F))
+ if (EntryNodeSet.insert(&F)) {
+ DEBUG(dbgs() << " Adding '" << F.getName()
+ << "' to entry set of the graph.\n");
EntryNodes.push_back(&F);
EntryNodes.push_back(&F);
// Now add entry nodes for functions reachable via initializers to globals.
SmallVector<Constant *, 16> Worklist;
// Now add entry nodes for functions reachable via initializers to globals.
SmallVector<Constant *, 16> Worklist;
if (Visited.insert(GV.getInitializer()))
Worklist.push_back(GV.getInitializer());
if (Visited.insert(GV.getInitializer()))
Worklist.push_back(GV.getInitializer());
+ DEBUG(dbgs() << " Adding functions referenced by global initializers to the "
+ "entry set.\n");
findCallees(Worklist, Visited, EntryNodes, EntryNodeSet);
for (auto &Entry : EntryNodes)
findCallees(Worklist, Visited, EntryNodes, EntryNodeSet);
for (auto &Entry : EntryNodes)