1 //===- CallGraphSCCPass.cpp - Pass that operates BU on call graph ---------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the CallGraphSCCPass class, which is used for passes
10 // which are implemented as bottom-up traversals on the call graph. Because
11 // there may be cycles in the call graph, passes of this type operate on the
12 // call-graph in SCC order: that is, they process function bottom-up, except for
13 // recursive functions, which they process all at once.
15 //===----------------------------------------------------------------------===//
17 #include "llvm/Analysis/CallGraphSCCPass.h"
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/SCCIterator.h"
20 #include "llvm/ADT/Statistic.h"
21 #include "llvm/Analysis/CallGraph.h"
22 #include "llvm/IR/CallSite.h"
23 #include "llvm/IR/Function.h"
24 #include "llvm/IR/IRPrintingPasses.h"
25 #include "llvm/IR/Intrinsics.h"
26 #include "llvm/IR/LLVMContext.h"
27 #include "llvm/IR/LegacyPassManagers.h"
28 #include "llvm/IR/Module.h"
29 #include "llvm/IR/OptBisect.h"
30 #include "llvm/IR/PassTimingInfo.h"
31 #include "llvm/Pass.h"
32 #include "llvm/Support/CommandLine.h"
33 #include "llvm/Support/Debug.h"
34 #include "llvm/Support/Timer.h"
35 #include "llvm/Support/raw_ostream.h"
43 #define DEBUG_TYPE "cgscc-passmgr"
45 static cl::opt
<unsigned>
46 MaxIterations("max-cg-scc-iterations", cl::ReallyHidden
, cl::init(4));
48 STATISTIC(MaxSCCIterations
, "Maximum CGSCCPassMgr iterations on one SCC");
50 //===----------------------------------------------------------------------===//
53 /// CGPassManager manages FPPassManagers and CallGraphSCCPasses.
57 class CGPassManager
: public ModulePass
, public PMDataManager
{
61 explicit CGPassManager() : ModulePass(ID
), PMDataManager() {}
63 /// Execute all of the passes scheduled for execution. Keep track of
64 /// whether any of the passes modifies the module, and if so, return true.
65 bool runOnModule(Module
&M
) override
;
67 using ModulePass::doInitialization
;
68 using ModulePass::doFinalization
;
70 bool doInitialization(CallGraph
&CG
);
71 bool doFinalization(CallGraph
&CG
);
73 /// Pass Manager itself does not invalidate any analysis info.
74 void getAnalysisUsage(AnalysisUsage
&Info
) const override
{
75 // CGPassManager walks SCC and it needs CallGraph.
76 Info
.addRequired
<CallGraphWrapperPass
>();
77 Info
.setPreservesAll();
80 StringRef
getPassName() const override
{ return "CallGraph Pass Manager"; }
82 PMDataManager
*getAsPMDataManager() override
{ return this; }
83 Pass
*getAsPass() override
{ return this; }
85 // Print passes managed by this manager
86 void dumpPassStructure(unsigned Offset
) override
{
87 errs().indent(Offset
*2) << "Call Graph SCC Pass Manager\n";
88 for (unsigned Index
= 0; Index
< getNumContainedPasses(); ++Index
) {
89 Pass
*P
= getContainedPass(Index
);
90 P
->dumpPassStructure(Offset
+ 1);
91 dumpLastUses(P
, Offset
+1);
95 Pass
*getContainedPass(unsigned N
) {
96 assert(N
< PassVector
.size() && "Pass number out of range!");
97 return static_cast<Pass
*>(PassVector
[N
]);
100 PassManagerType
getPassManagerType() const override
{
101 return PMT_CallGraphPassManager
;
105 bool RunAllPassesOnSCC(CallGraphSCC
&CurSCC
, CallGraph
&CG
,
106 bool &DevirtualizedCall
);
108 bool RunPassOnSCC(Pass
*P
, CallGraphSCC
&CurSCC
,
109 CallGraph
&CG
, bool &CallGraphUpToDate
,
110 bool &DevirtualizedCall
);
111 bool RefreshCallGraph(const CallGraphSCC
&CurSCC
, CallGraph
&CG
,
112 bool IsCheckingMode
);
115 } // end anonymous namespace.
117 char CGPassManager::ID
= 0;
119 bool CGPassManager::RunPassOnSCC(Pass
*P
, CallGraphSCC
&CurSCC
,
120 CallGraph
&CG
, bool &CallGraphUpToDate
,
121 bool &DevirtualizedCall
) {
122 bool Changed
= false;
123 PMDataManager
*PM
= P
->getAsPMDataManager();
124 Module
&M
= CG
.getModule();
127 CallGraphSCCPass
*CGSP
= (CallGraphSCCPass
*)P
;
128 if (!CallGraphUpToDate
) {
129 DevirtualizedCall
|= RefreshCallGraph(CurSCC
, CG
, false);
130 CallGraphUpToDate
= true;
134 unsigned InstrCount
, SCCCount
= 0;
135 StringMap
<std::pair
<unsigned, unsigned>> FunctionToInstrCount
;
136 bool EmitICRemark
= M
.shouldEmitInstrCountChangedRemark();
137 TimeRegion
PassTimer(getPassTimer(CGSP
));
139 InstrCount
= initSizeRemarkInfo(M
, FunctionToInstrCount
);
140 Changed
= CGSP
->runOnSCC(CurSCC
);
143 // FIXME: Add getInstructionCount to CallGraphSCC.
144 SCCCount
= M
.getInstructionCount();
145 // Is there a difference in the number of instructions in the module?
146 if (SCCCount
!= InstrCount
) {
147 // Yep. Emit a remark and update InstrCount.
149 static_cast<int64_t>(SCCCount
) - static_cast<int64_t>(InstrCount
);
150 emitInstrCountChangedRemark(P
, M
, Delta
, InstrCount
,
151 FunctionToInstrCount
);
152 InstrCount
= SCCCount
;
157 // After the CGSCCPass is done, when assertions are enabled, use
158 // RefreshCallGraph to verify that the callgraph was correctly updated.
161 RefreshCallGraph(CurSCC
, CG
, true);
167 assert(PM
->getPassManagerType() == PMT_FunctionPassManager
&&
168 "Invalid CGPassManager member");
169 FPPassManager
*FPP
= (FPPassManager
*)P
;
171 // Run pass P on all functions in the current SCC.
172 for (CallGraphNode
*CGN
: CurSCC
) {
173 if (Function
*F
= CGN
->getFunction()) {
174 dumpPassInfo(P
, EXECUTION_MSG
, ON_FUNCTION_MSG
, F
->getName());
176 TimeRegion
PassTimer(getPassTimer(FPP
));
177 Changed
|= FPP
->runOnFunction(*F
);
179 F
->getContext().yield();
183 // The function pass(es) modified the IR, they may have clobbered the
185 if (Changed
&& CallGraphUpToDate
) {
186 LLVM_DEBUG(dbgs() << "CGSCCPASSMGR: Pass Dirtied SCC: " << P
->getPassName()
188 CallGraphUpToDate
= false;
193 /// Scan the functions in the specified CFG and resync the
194 /// callgraph with the call sites found in it. This is used after
195 /// FunctionPasses have potentially munged the callgraph, and can be used after
196 /// CallGraphSCC passes to verify that they correctly updated the callgraph.
198 /// This function returns true if it devirtualized an existing function call,
199 /// meaning it turned an indirect call into a direct call. This happens when
200 /// a function pass like GVN optimizes away stuff feeding the indirect call.
201 /// This never happens in checking mode.
202 bool CGPassManager::RefreshCallGraph(const CallGraphSCC
&CurSCC
, CallGraph
&CG
,
204 DenseMap
<Value
*, CallGraphNode
*> CallSites
;
206 LLVM_DEBUG(dbgs() << "CGSCCPASSMGR: Refreshing SCC with " << CurSCC
.size()
208 for (CallGraphNode
*CGN
209 : CurSCC
) CGN
->dump(););
211 bool MadeChange
= false;
212 bool DevirtualizedCall
= false;
214 // Scan all functions in the SCC.
215 unsigned FunctionNo
= 0;
216 for (CallGraphSCC::iterator SCCIdx
= CurSCC
.begin(), E
= CurSCC
.end();
217 SCCIdx
!= E
; ++SCCIdx
, ++FunctionNo
) {
218 CallGraphNode
*CGN
= *SCCIdx
;
219 Function
*F
= CGN
->getFunction();
220 if (!F
|| F
->isDeclaration()) continue;
222 // Walk the function body looking for call sites. Sync up the call sites in
223 // CGN with those actually in the function.
225 // Keep track of the number of direct and indirect calls that were
226 // invalidated and removed.
227 unsigned NumDirectRemoved
= 0, NumIndirectRemoved
= 0;
229 // Get the set of call sites currently in the function.
230 for (CallGraphNode::iterator I
= CGN
->begin(), E
= CGN
->end(); I
!= E
; ) {
231 // If this call site is null, then the function pass deleted the call
232 // entirely and the WeakTrackingVH nulled it out.
234 // If we've already seen this call site, then the FunctionPass RAUW'd
235 // one call with another, which resulted in two "uses" in the edge
236 // list of the same call.
237 CallSites
.count(I
->first
) ||
239 // If the call edge is not from a call or invoke, or it is a
240 // instrinsic call, then the function pass RAUW'd a call with
241 // another value. This can happen when constant folding happens
242 // of well known functions etc.
243 !CallSite(I
->first
) ||
244 (CallSite(I
->first
).getCalledFunction() &&
245 CallSite(I
->first
).getCalledFunction()->isIntrinsic() &&
247 CallSite(I
->first
).getCalledFunction()->getIntrinsicID()))) {
248 assert(!CheckingMode
&&
249 "CallGraphSCCPass did not update the CallGraph correctly!");
251 // If this was an indirect call site, count it.
252 if (!I
->second
->getFunction())
253 ++NumIndirectRemoved
;
257 // Just remove the edge from the set of callees, keep track of whether
258 // I points to the last element of the vector.
259 bool WasLast
= I
+ 1 == E
;
260 CGN
->removeCallEdge(I
);
262 // If I pointed to the last element of the vector, we have to bail out:
263 // iterator checking rejects comparisons of the resultant pointer with
271 assert(!CallSites
.count(I
->first
) &&
272 "Call site occurs in node multiple times");
274 CallSite
CS(I
->first
);
276 Function
*Callee
= CS
.getCalledFunction();
277 // Ignore intrinsics because they're not really function calls.
278 if (!Callee
|| !(Callee
->isIntrinsic()))
279 CallSites
.insert(std::make_pair(I
->first
, I
->second
));
284 // Loop over all of the instructions in the function, getting the callsites.
285 // Keep track of the number of direct/indirect calls added.
286 unsigned NumDirectAdded
= 0, NumIndirectAdded
= 0;
288 for (BasicBlock
&BB
: *F
)
289 for (Instruction
&I
: BB
) {
292 Function
*Callee
= CS
.getCalledFunction();
293 if (Callee
&& Callee
->isIntrinsic()) continue;
295 // If this call site already existed in the callgraph, just verify it
296 // matches up to expectations and remove it from CallSites.
297 DenseMap
<Value
*, CallGraphNode
*>::iterator ExistingIt
=
298 CallSites
.find(CS
.getInstruction());
299 if (ExistingIt
!= CallSites
.end()) {
300 CallGraphNode
*ExistingNode
= ExistingIt
->second
;
302 // Remove from CallSites since we have now seen it.
303 CallSites
.erase(ExistingIt
);
305 // Verify that the callee is right.
306 if (ExistingNode
->getFunction() == CS
.getCalledFunction())
309 // If we are in checking mode, we are not allowed to actually mutate
310 // the callgraph. If this is a case where we can infer that the
311 // callgraph is less precise than it could be (e.g. an indirect call
312 // site could be turned direct), don't reject it in checking mode, and
313 // don't tweak it to be more precise.
314 if (CheckingMode
&& CS
.getCalledFunction() &&
315 ExistingNode
->getFunction() == nullptr)
318 assert(!CheckingMode
&&
319 "CallGraphSCCPass did not update the CallGraph correctly!");
321 // If not, we either went from a direct call to indirect, indirect to
322 // direct, or direct to different direct.
323 CallGraphNode
*CalleeNode
;
324 if (Function
*Callee
= CS
.getCalledFunction()) {
325 CalleeNode
= CG
.getOrInsertFunction(Callee
);
326 // Keep track of whether we turned an indirect call into a direct
328 if (!ExistingNode
->getFunction()) {
329 DevirtualizedCall
= true;
330 LLVM_DEBUG(dbgs() << " CGSCCPASSMGR: Devirtualized call to '"
331 << Callee
->getName() << "'\n");
334 CalleeNode
= CG
.getCallsExternalNode();
337 // Update the edge target in CGN.
338 CGN
->replaceCallEdge(CS
, CS
, CalleeNode
);
343 assert(!CheckingMode
&&
344 "CallGraphSCCPass did not update the CallGraph correctly!");
346 // If the call site didn't exist in the CGN yet, add it.
347 CallGraphNode
*CalleeNode
;
348 if (Function
*Callee
= CS
.getCalledFunction()) {
349 CalleeNode
= CG
.getOrInsertFunction(Callee
);
352 CalleeNode
= CG
.getCallsExternalNode();
356 CGN
->addCalledFunction(CS
, CalleeNode
);
360 // We scanned the old callgraph node, removing invalidated call sites and
361 // then added back newly found call sites. One thing that can happen is
362 // that an old indirect call site was deleted and replaced with a new direct
363 // call. In this case, we have devirtualized a call, and CGSCCPM would like
364 // to iteratively optimize the new code. Unfortunately, we don't really
365 // have a great way to detect when this happens. As an approximation, we
366 // just look at whether the number of indirect calls is reduced and the
367 // number of direct calls is increased. There are tons of ways to fool this
368 // (e.g. DCE'ing an indirect call and duplicating an unrelated block with a
369 // direct call) but this is close enough.
370 if (NumIndirectRemoved
> NumIndirectAdded
&&
371 NumDirectRemoved
< NumDirectAdded
)
372 DevirtualizedCall
= true;
374 // After scanning this function, if we still have entries in callsites, then
375 // they are dangling pointers. WeakTrackingVH should save us for this, so
378 assert(CallSites
.empty() && "Dangling pointers found in call sites map");
380 // Periodically do an explicit clear to remove tombstones when processing
382 if ((FunctionNo
& 15) == 15)
386 LLVM_DEBUG(if (MadeChange
) {
387 dbgs() << "CGSCCPASSMGR: Refreshed SCC is now:\n";
388 for (CallGraphNode
*CGN
: CurSCC
)
390 if (DevirtualizedCall
)
391 dbgs() << "CGSCCPASSMGR: Refresh devirtualized a call!\n";
393 dbgs() << "CGSCCPASSMGR: SCC Refresh didn't change call graph.\n";
397 return DevirtualizedCall
;
400 /// Execute the body of the entire pass manager on the specified SCC.
401 /// This keeps track of whether a function pass devirtualizes
402 /// any calls and returns it in DevirtualizedCall.
403 bool CGPassManager::RunAllPassesOnSCC(CallGraphSCC
&CurSCC
, CallGraph
&CG
,
404 bool &DevirtualizedCall
) {
405 bool Changed
= false;
407 // Keep track of whether the callgraph is known to be up-to-date or not.
408 // The CGSSC pass manager runs two types of passes:
409 // CallGraphSCC Passes and other random function passes. Because other
410 // random function passes are not CallGraph aware, they may clobber the
411 // call graph by introducing new calls or deleting other ones. This flag
412 // is set to false when we run a function pass so that we know to clean up
413 // the callgraph when we need to run a CGSCCPass again.
414 bool CallGraphUpToDate
= true;
416 // Run all passes on current SCC.
417 for (unsigned PassNo
= 0, e
= getNumContainedPasses();
418 PassNo
!= e
; ++PassNo
) {
419 Pass
*P
= getContainedPass(PassNo
);
421 // If we're in -debug-pass=Executions mode, construct the SCC node list,
422 // otherwise avoid constructing this string as it is expensive.
423 if (isPassDebuggingExecutionsOrMore()) {
424 std::string Functions
;
426 raw_string_ostream
OS(Functions
);
427 for (CallGraphSCC::iterator I
= CurSCC
.begin(), E
= CurSCC
.end();
429 if (I
!= CurSCC
.begin()) OS
<< ", ";
434 dumpPassInfo(P
, EXECUTION_MSG
, ON_CG_MSG
, Functions
);
438 initializeAnalysisImpl(P
);
440 // Actually run this pass on the current SCC.
441 Changed
|= RunPassOnSCC(P
, CurSCC
, CG
,
442 CallGraphUpToDate
, DevirtualizedCall
);
445 dumpPassInfo(P
, MODIFICATION_MSG
, ON_CG_MSG
, "");
448 verifyPreservedAnalysis(P
);
449 removeNotPreservedAnalysis(P
);
450 recordAvailableAnalysis(P
);
451 removeDeadPasses(P
, "", ON_CG_MSG
);
454 // If the callgraph was left out of date (because the last pass run was a
455 // functionpass), refresh it before we move on to the next SCC.
456 if (!CallGraphUpToDate
)
457 DevirtualizedCall
|= RefreshCallGraph(CurSCC
, CG
, false);
461 /// Execute all of the passes scheduled for execution. Keep track of
462 /// whether any of the passes modifies the module, and if so, return true.
463 bool CGPassManager::runOnModule(Module
&M
) {
464 CallGraph
&CG
= getAnalysis
<CallGraphWrapperPass
>().getCallGraph();
465 bool Changed
= doInitialization(CG
);
467 // Walk the callgraph in bottom-up SCC order.
468 scc_iterator
<CallGraph
*> CGI
= scc_begin(&CG
);
470 CallGraphSCC
CurSCC(CG
, &CGI
);
471 while (!CGI
.isAtEnd()) {
472 // Copy the current SCC and increment past it so that the pass can hack
473 // on the SCC if it wants to without invalidating our iterator.
474 const std::vector
<CallGraphNode
*> &NodeVec
= *CGI
;
475 CurSCC
.initialize(NodeVec
);
478 // At the top level, we run all the passes in this pass manager on the
479 // functions in this SCC. However, we support iterative compilation in the
480 // case where a function pass devirtualizes a call to a function. For
481 // example, it is very common for a function pass (often GVN or instcombine)
482 // to eliminate the addressing that feeds into a call. With that improved
483 // information, we would like the call to be an inline candidate, infer
484 // mod-ref information etc.
486 // Because of this, we allow iteration up to a specified iteration count.
487 // This only happens in the case of a devirtualized call, so we only burn
488 // compile time in the case that we're making progress. We also have a hard
489 // iteration count limit in case there is crazy code.
490 unsigned Iteration
= 0;
491 bool DevirtualizedCall
= false;
493 LLVM_DEBUG(if (Iteration
) dbgs()
494 << " SCCPASSMGR: Re-visiting SCC, iteration #" << Iteration
496 DevirtualizedCall
= false;
497 Changed
|= RunAllPassesOnSCC(CurSCC
, CG
, DevirtualizedCall
);
498 } while (Iteration
++ < MaxIterations
&& DevirtualizedCall
);
500 if (DevirtualizedCall
)
501 LLVM_DEBUG(dbgs() << " CGSCCPASSMGR: Stopped iteration after "
503 << " times, due to -max-cg-scc-iterations\n");
505 MaxSCCIterations
.updateMax(Iteration
);
507 Changed
|= doFinalization(CG
);
512 bool CGPassManager::doInitialization(CallGraph
&CG
) {
513 bool Changed
= false;
514 for (unsigned i
= 0, e
= getNumContainedPasses(); i
!= e
; ++i
) {
515 if (PMDataManager
*PM
= getContainedPass(i
)->getAsPMDataManager()) {
516 assert(PM
->getPassManagerType() == PMT_FunctionPassManager
&&
517 "Invalid CGPassManager member");
518 Changed
|= ((FPPassManager
*)PM
)->doInitialization(CG
.getModule());
520 Changed
|= ((CallGraphSCCPass
*)getContainedPass(i
))->doInitialization(CG
);
527 bool CGPassManager::doFinalization(CallGraph
&CG
) {
528 bool Changed
= false;
529 for (unsigned i
= 0, e
= getNumContainedPasses(); i
!= e
; ++i
) {
530 if (PMDataManager
*PM
= getContainedPass(i
)->getAsPMDataManager()) {
531 assert(PM
->getPassManagerType() == PMT_FunctionPassManager
&&
532 "Invalid CGPassManager member");
533 Changed
|= ((FPPassManager
*)PM
)->doFinalization(CG
.getModule());
535 Changed
|= ((CallGraphSCCPass
*)getContainedPass(i
))->doFinalization(CG
);
541 //===----------------------------------------------------------------------===//
542 // CallGraphSCC Implementation
543 //===----------------------------------------------------------------------===//
545 /// This informs the SCC and the pass manager that the specified
546 /// Old node has been deleted, and New is to be used in its place.
547 void CallGraphSCC::ReplaceNode(CallGraphNode
*Old
, CallGraphNode
*New
) {
548 assert(Old
!= New
&& "Should not replace node with self");
549 for (unsigned i
= 0; ; ++i
) {
550 assert(i
!= Nodes
.size() && "Node not in SCC");
551 if (Nodes
[i
] != Old
) continue;
556 // Update the active scc_iterator so that it doesn't contain dangling
557 // pointers to the old CallGraphNode.
558 scc_iterator
<CallGraph
*> *CGI
= (scc_iterator
<CallGraph
*>*)Context
;
559 CGI
->ReplaceNode(Old
, New
);
562 //===----------------------------------------------------------------------===//
563 // CallGraphSCCPass Implementation
564 //===----------------------------------------------------------------------===//
566 /// Assign pass manager to manage this pass.
567 void CallGraphSCCPass::assignPassManager(PMStack
&PMS
,
568 PassManagerType PreferredType
) {
569 // Find CGPassManager
570 while (!PMS
.empty() &&
571 PMS
.top()->getPassManagerType() > PMT_CallGraphPassManager
)
574 assert(!PMS
.empty() && "Unable to handle Call Graph Pass");
577 if (PMS
.top()->getPassManagerType() == PMT_CallGraphPassManager
)
578 CGP
= (CGPassManager
*)PMS
.top();
580 // Create new Call Graph SCC Pass Manager if it does not exist.
581 assert(!PMS
.empty() && "Unable to create Call Graph Pass Manager");
582 PMDataManager
*PMD
= PMS
.top();
584 // [1] Create new Call Graph Pass Manager
585 CGP
= new CGPassManager();
587 // [2] Set up new manager's top level manager
588 PMTopLevelManager
*TPM
= PMD
->getTopLevelManager();
589 TPM
->addIndirectPassManager(CGP
);
591 // [3] Assign manager to manage this new manager. This may create
592 // and push new managers into PMS
594 TPM
->schedulePass(P
);
596 // [4] Push new manager into PMS
603 /// For this class, we declare that we require and preserve the call graph.
604 /// If the derived class implements this method, it should
605 /// always explicitly call the implementation here.
606 void CallGraphSCCPass::getAnalysisUsage(AnalysisUsage
&AU
) const {
607 AU
.addRequired
<CallGraphWrapperPass
>();
608 AU
.addPreserved
<CallGraphWrapperPass
>();
611 //===----------------------------------------------------------------------===//
612 // PrintCallGraphPass Implementation
613 //===----------------------------------------------------------------------===//
617 /// PrintCallGraphPass - Print a Module corresponding to a call graph.
619 class PrintCallGraphPass
: public CallGraphSCCPass
{
621 raw_ostream
&OS
; // raw_ostream to print on.
626 PrintCallGraphPass(const std::string
&B
, raw_ostream
&OS
)
627 : CallGraphSCCPass(ID
), Banner(B
), OS(OS
) {}
629 void getAnalysisUsage(AnalysisUsage
&AU
) const override
{
630 AU
.setPreservesAll();
633 bool runOnSCC(CallGraphSCC
&SCC
) override
{
634 bool BannerPrinted
= false;
635 auto PrintBannerOnce
= [&]() {
639 BannerPrinted
= true;
642 bool NeedModule
= llvm::forcePrintModuleIR();
643 if (isFunctionInPrintList("*") && NeedModule
) {
646 SCC
.getCallGraph().getModule().print(OS
, nullptr);
649 bool FoundFunction
= false;
650 for (CallGraphNode
*CGN
: SCC
) {
651 if (Function
*F
= CGN
->getFunction()) {
652 if (!F
->isDeclaration() && isFunctionInPrintList(F
->getName())) {
653 FoundFunction
= true;
659 } else if (isFunctionInPrintList("*")) {
661 OS
<< "\nPrinting <null> Function\n";
664 if (NeedModule
&& FoundFunction
) {
667 SCC
.getCallGraph().getModule().print(OS
, nullptr);
672 StringRef
getPassName() const override
{ return "Print CallGraph IR"; }
675 } // end anonymous namespace.
677 char PrintCallGraphPass::ID
= 0;
679 Pass
*CallGraphSCCPass::createPrinterPass(raw_ostream
&OS
,
680 const std::string
&Banner
) const {
681 return new PrintCallGraphPass(Banner
, OS
);
684 bool CallGraphSCCPass::skipSCC(CallGraphSCC
&SCC
) const {
685 return !SCC
.getCallGraph().getModule()
688 .shouldRunPass(this, SCC
);
691 char DummyCGSCCPass::ID
= 0;
693 INITIALIZE_PASS(DummyCGSCCPass
, "DummyCGSCCPass", "DummyCGSCCPass", false,