diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2014-04-21 05:04:24 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2014-04-21 05:04:24 +0000 |
| commit | 99b756db048b7e283fc16eacd08001d79de9339d (patch) | |
| tree | b785841c7e290519647511312f3280b18fe5b252 /llvm/lib/Analysis | |
| parent | 373af73ad406eb8b8670e18f89631e396a4b1fbe (diff) | |
| download | bcm5719-llvm-99b756db048b7e283fc16eacd08001d79de9339d.tar.gz bcm5719-llvm-99b756db048b7e283fc16eacd08001d79de9339d.zip | |
[LCG] Add some basic debug output to the LCG pass.
llvm-svn: 206730
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/LazyCallGraph.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp index a981dcceaad..1b6691234b5 100644 --- a/llvm/lib/Analysis/LazyCallGraph.cpp +++ b/llvm/lib/Analysis/LazyCallGraph.cpp @@ -7,12 +7,14 @@ // //===----------------------------------------------------------------------===// +#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/Support/Debug.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -35,8 +37,11 @@ static void findCallees( // 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"); Callees.push_back(F); + } continue; } @@ -48,6 +53,9 @@ static void findCallees( 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 @@ -66,10 +74,15 @@ LazyCallGraph::Node::Node(LazyCallGraph &G, Function &F) } LazyCallGraph::LazyCallGraph(Module &M) : NextDFSNumber(0) { + DEBUG(dbgs() << "Building CG for module: " << M.getModuleIdentifier() + << "\n"); 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); + } // Now add entry nodes for functions reachable via initializers to globals. SmallVector<Constant *, 16> Worklist; @@ -79,6 +92,8 @@ LazyCallGraph::LazyCallGraph(Module &M) : NextDFSNumber(0) { 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) |

