1 //===- CFGSCCPrinter.cpp --------------------------------------------------===//
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 #include "llvm/Analysis/CFGSCCPrinter.h"
10 #include "llvm/ADT/SCCIterator.h"
11 #include "llvm/IR/CFG.h"
15 PreservedAnalyses
CFGSCCPrinterPass::run(Function
&F
,
16 FunctionAnalysisManager
&AM
) {
18 OS
<< "SCCs for Function " << F
.getName() << " in PostOrder:";
19 for (scc_iterator
<Function
*> SCCI
= scc_begin(&F
); !SCCI
.isAtEnd(); ++SCCI
) {
20 const std::vector
<BasicBlock
*> &NextSCC
= *SCCI
;
21 OS
<< "\nSCC #" << ++SccNum
<< ": ";
23 for (BasicBlock
*BB
: NextSCC
) {
28 BB
->printAsOperand(OS
, false);
30 if (NextSCC
.size() == 1 && SCCI
.hasCycle())
31 OS
<< " (Has self-loop).";
35 return PreservedAnalyses::all();