CallGraphSCCPass.cpp (208954) | CallGraphSCCPass.cpp (212904) |
---|---|
1//===- CallGraphSCCPass.cpp - Pass that operates BU on call graph ---------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 31 unchanged lines hidden (view full) --- 40/// CGPassManager manages FPPassManagers and CallGraphSCCPasses. 41 42namespace { 43 44class CGPassManager : public ModulePass, public PMDataManager { 45public: 46 static char ID; 47 explicit CGPassManager(int Depth) | 1//===- CallGraphSCCPass.cpp - Pass that operates BU on call graph ---------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 31 unchanged lines hidden (view full) --- 40/// CGPassManager manages FPPassManagers and CallGraphSCCPasses. 41 42namespace { 43 44class CGPassManager : public ModulePass, public PMDataManager { 45public: 46 static char ID; 47 explicit CGPassManager(int Depth) |
48 : ModulePass(&ID), PMDataManager(Depth) { } | 48 : ModulePass(ID), PMDataManager(Depth) { } |
49 50 /// run - Execute all of the passes scheduled for execution. Keep track of 51 /// whether any of the passes modifies the module, and if so, return true. 52 bool runOnModule(Module &M); 53 54 bool doInitialization(CallGraph &CG); 55 bool doFinalization(CallGraph &CG); 56 --- 147 unchanged lines hidden (view full) --- 204 // If we've already seen this call site, then the FunctionPass RAUW'd 205 // one call with another, which resulted in two "uses" in the edge 206 // list of the same call. 207 CallSites.count(I->first) || 208 209 // If the call edge is not from a call or invoke, then the function 210 // pass RAUW'd a call with another value. This can happen when 211 // constant folding happens of well known functions etc. | 49 50 /// run - Execute all of the passes scheduled for execution. Keep track of 51 /// whether any of the passes modifies the module, and if so, return true. 52 bool runOnModule(Module &M); 53 54 bool doInitialization(CallGraph &CG); 55 bool doFinalization(CallGraph &CG); 56 --- 147 unchanged lines hidden (view full) --- 204 // If we've already seen this call site, then the FunctionPass RAUW'd 205 // one call with another, which resulted in two "uses" in the edge 206 // list of the same call. 207 CallSites.count(I->first) || 208 209 // If the call edge is not from a call or invoke, then the function 210 // pass RAUW'd a call with another value. This can happen when 211 // constant folding happens of well known functions etc. |
212 CallSite::get(I->first).getInstruction() == 0) { | 212 !CallSite(I->first)) { |
213 assert(!CheckingMode && 214 "CallGraphSCCPass did not update the CallGraph correctly!"); 215 216 // If this was an indirect call site, count it. 217 if (I->second->getFunction() == 0) 218 ++NumIndirectRemoved; 219 else 220 ++NumDirectRemoved; --- 19 unchanged lines hidden (view full) --- 240 } 241 242 // Loop over all of the instructions in the function, getting the callsites. 243 // Keep track of the number of direct/indirect calls added. 244 unsigned NumDirectAdded = 0, NumIndirectAdded = 0; 245 246 for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) 247 for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { | 213 assert(!CheckingMode && 214 "CallGraphSCCPass did not update the CallGraph correctly!"); 215 216 // If this was an indirect call site, count it. 217 if (I->second->getFunction() == 0) 218 ++NumIndirectRemoved; 219 else 220 ++NumDirectRemoved; --- 19 unchanged lines hidden (view full) --- 240 } 241 242 // Loop over all of the instructions in the function, getting the callsites. 243 // Keep track of the number of direct/indirect calls added. 244 unsigned NumDirectAdded = 0, NumIndirectAdded = 0; 245 246 for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) 247 for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { |
248 CallSite CS = CallSite::get(I); 249 if (!CS.getInstruction() || isa<DbgInfoIntrinsic>(I)) continue; | 248 CallSite CS(cast<Value>(I)); 249 if (!CS || isa |
250 251 // If this call site already existed in the callgraph, just verify it 252 // matches up to expectations and remove it from CallSites. 253 DenseMap<Value*, CallGraphNode*>::iterator ExistingIt = 254 CallSites.find(CS.getInstruction()); 255 if (ExistingIt != CallSites.end()) { 256 CallGraphNode *ExistingNode = ExistingIt->second; 257 --- 319 unchanged lines hidden (view full) --- 577 /// PrintCallGraphPass - Print a Module corresponding to a call graph. 578 /// 579 class PrintCallGraphPass : public CallGraphSCCPass { 580 std::string Banner; 581 raw_ostream &Out; // raw_ostream to print on. 582 583 public: 584 static char ID; | 250 251 // If this call site already existed in the callgraph, just verify it 252 // matches up to expectations and remove it from CallSites. 253 DenseMap<Value*, CallGraphNode*>::iterator ExistingIt = 254 CallSites.find(CS.getInstruction()); 255 if (ExistingIt != CallSites.end()) { 256 CallGraphNode *ExistingNode = ExistingIt->second; 257 --- 319 unchanged lines hidden (view full) --- 577 /// PrintCallGraphPass - Print a Module corresponding to a call graph. 578 /// 579 class PrintCallGraphPass : public CallGraphSCCPass { 580 std::string Banner; 581 raw_ostream &Out; // raw_ostream to print on. 582 583 public: 584 static char ID; |
585 PrintCallGraphPass() : CallGraphSCCPass(&ID), Out(dbgs()) {} | 585 PrintCallGraphPass() : CallGraphSCCPass(ID), Out(dbgs()) {} |
586 PrintCallGraphPass(const std::string &B, raw_ostream &o) | 586 PrintCallGraphPass(const std::string &B, raw_ostream &o) |
587 : CallGraphSCCPass(&ID), Banner(B), Out(o) {} | 587 : CallGraphSCCPass(ID), Banner(B), Out(o) {} |
588 589 virtual void getAnalysisUsage(AnalysisUsage &AU) const { 590 AU.setPreservesAll(); 591 } 592 593 bool runOnSCC(CallGraphSCC &SCC) { 594 Out << Banner; 595 for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) --- 14 unchanged lines hidden --- | 588 589 virtual void getAnalysisUsage(AnalysisUsage &AU) const { 590 AU.setPreservesAll(); 591 } 592 593 bool runOnSCC(CallGraphSCC &SCC) { 594 Out << Banner; 595 for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) --- 14 unchanged lines hidden --- |