Path: blob/main/contrib/llvm-project/llvm/lib/Analysis/CFGSCCPrinter.cpp
35233 views
//===- CFGSCCPrinter.cpp --------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/Analysis/CFGSCCPrinter.h"9#include "llvm/ADT/SCCIterator.h"10#include "llvm/IR/CFG.h"1112using namespace llvm;1314PreservedAnalyses CFGSCCPrinterPass::run(Function &F,15FunctionAnalysisManager &AM) {16unsigned SccNum = 0;17OS << "SCCs for Function " << F.getName() << " in PostOrder:";18for (scc_iterator<Function *> SCCI = scc_begin(&F); !SCCI.isAtEnd(); ++SCCI) {19const std::vector<BasicBlock *> &NextSCC = *SCCI;20OS << "\nSCC #" << ++SccNum << ": ";21bool First = true;22for (BasicBlock *BB : NextSCC) {23if (First)24First = false;25else26OS << ", ";27BB->printAsOperand(OS, false);28}29if (NextSCC.size() == 1 && SCCI.hasCycle())30OS << " (Has self-loop).";31}32OS << "\n";3334return PreservedAnalyses::all();35}363738