llvm.org GIT mirror llvm / 29e0c0b
[LCG] Add some basic debug output to the LCG pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206730 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 6 years ago
1 changed file(s) with 17 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
66 //
77 //===----------------------------------------------------------------------===//
88
9 #define DEBUG_TYPE "lcg"
910 #include "llvm/Analysis/LazyCallGraph.h"
1011 #include "llvm/ADT/STLExtras.h"
1112 #include "llvm/IR/CallSite.h"
1213 #include "llvm/IR/InstVisitor.h"
1314 #include "llvm/IR/Instructions.h"
1415 #include "llvm/IR/PassManager.h"
16 #include "llvm/Support/Debug.h"
1517 #include "llvm/Support/raw_ostream.h"
1618
1719 using namespace llvm;
3436 // alias. Then a test of the address of the weak function against the new
3537 // strong definition's address would be an effective way to determine the
3638 // safety of optimizing a direct call edge.
37 if (!F->isDeclaration() && CalleeSet.insert(F))
39 if (!F->isDeclaration() && CalleeSet.insert(F)) {
40 DEBUG(dbgs() << " Added callable function: " << F->getName()
41 << "\n");
3842 Callees.push_back(F);
43 }
3944 continue;
4045 }
4146
4752
4853 LazyCallGraph::Node::Node(LazyCallGraph &G, Function &F)
4954 : G(&G), F(F), DFSNumber(0), LowLink(0) {
55 DEBUG(dbgs() << " Adding functions called by '" << F.getName()
56 << "' to the graph.\n");
57
5058 SmallVector Worklist;
5159 SmallPtrSet Visited;
5260 // Find all the potential callees in this function. First walk the
6573 }
6674
6775 LazyCallGraph::LazyCallGraph(Module &M) : NextDFSNumber(0) {
76 DEBUG(dbgs() << "Building CG for module: " << M.getModuleIdentifier()
77 << "\n");
6878 for (Function &F : M)
6979 if (!F.isDeclaration() && !F.hasLocalLinkage())
70 if (EntryNodeSet.insert(&F))
80 if (EntryNodeSet.insert(&F)) {
81 DEBUG(dbgs() << " Adding '" << F.getName()
82 << "' to entry set of the graph.\n");
7183 EntryNodes.push_back(&F);
84 }
7285
7386 // Now add entry nodes for functions reachable via initializers to globals.
7487 SmallVector Worklist;
7891 if (Visited.insert(GV.getInitializer()))
7992 Worklist.push_back(GV.getInitializer());
8093
94 DEBUG(dbgs() << " Adding functions referenced by global initializers to the "
95 "entry set.\n");
8196 findCallees(Worklist, Visited, EntryNodes, EntryNodeSet);
8297
8398 for (auto &Entry : EntryNodes)