llvm/llvm/lib/Analysis/CallPrinter.cpp

//===- CallPrinter.cpp - DOT printer for call graph -----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines '-dot-callgraph', which emit a callgraph.<fnname>.dot
// containing the call graph of a module.
//
// There is also a pass available to directly call dotty ('-view-callgraph').
//
//===----------------------------------------------------------------------===//

#include "llvm/Analysis/CallPrinter.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/HeatUtils.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/DOTGraphTraits.h"
#include "llvm/Support/GraphWriter.h"

usingnamespacellvm;

namespace llvm {
template <class GraphType> struct GraphTraits;
} // namespace llvm

// This option shows static (relative) call counts.
// FIXME:
// Need to show real counts when profile data is available
static cl::opt<bool> ShowHeatColors("callgraph-heat-colors", cl::init(false),
                                    cl::Hidden,
                                    cl::desc("Show heat colors in call-graph"));

static cl::opt<bool>
    ShowEdgeWeight("callgraph-show-weights", cl::init(false), cl::Hidden,
                       cl::desc("Show edges labeled with weights"));

static cl::opt<bool>
    CallMultiGraph("callgraph-multigraph", cl::init(false), cl::Hidden,
            cl::desc("Show call-multigraph (do not remove parallel edges)"));

static cl::opt<std::string> CallGraphDotFilenamePrefix(
    "callgraph-dot-filename-prefix", cl::Hidden,
    cl::desc("The prefix used for the CallGraph dot file names."));

namespace llvm {

class CallGraphDOTInfo {};

template <>
struct GraphTraits<CallGraphDOTInfo *>
    : public GraphTraits<const CallGraphNode *> {};

template <>
struct DOTGraphTraits<CallGraphDOTInfo *> : public DefaultDOTGraphTraits {};

} // namespace llvm

namespace {
void doCallGraphDOTPrinting(
    Module &M, function_ref<BlockFrequencyInfo *(Function &)> LookupBFI) {}

void viewCallGraph(Module &M,
                   function_ref<BlockFrequencyInfo *(Function &)> LookupBFI) {}
} // namespace

namespace llvm {
PreservedAnalyses CallGraphDOTPrinterPass::run(Module &M,
                                               ModuleAnalysisManager &AM) {}

PreservedAnalyses CallGraphViewerPass::run(Module &M,
                                           ModuleAnalysisManager &AM) {}
} // namespace llvm

namespace {
// Viewer
class CallGraphViewer : public ModulePass {};

void CallGraphViewer::getAnalysisUsage(AnalysisUsage &AU) const {}

bool CallGraphViewer::runOnModule(Module &M) {}

// DOT Printer

class CallGraphDOTPrinter : public ModulePass {};

void CallGraphDOTPrinter::getAnalysisUsage(AnalysisUsage &AU) const {}

bool CallGraphDOTPrinter::runOnModule(Module &M) {}

} // end anonymous namespace

char CallGraphViewer::ID =;
INITIALIZE_PASS()

char CallGraphDOTPrinter::ID =;
INITIALIZE_PASS()

// Create methods available outside of this file, to use them
// "include/llvm/LinkAllPasses.h". Otherwise the pass would be deleted by
// the link time optimization.

ModulePass *llvm::createCallGraphViewerPass() {}

ModulePass *llvm::createCallGraphDOTPrinterPass() {}