llvm/llvm/include/llvm/Analysis/Utils/ImportedFunctionsInliningStatistics.h

//===-- ImportedFunctionsInliningStatistics.h -------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
// Generating inliner statistics for imported functions, mostly useful for
// ThinLTO.
//===----------------------------------------------------------------------===//

#ifndef LLVM_ANALYSIS_UTILS_IMPORTEDFUNCTIONSINLININGSTATISTICS_H
#define LLVM_ANALYSIS_UTILS_IMPORTEDFUNCTIONSINLININGSTATISTICS_H

#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include <memory>
#include <vector>

namespace llvm {
class Module;
class Function;
/// Calculate and dump ThinLTO specific inliner stats.
/// The main statistics are:
/// (1) Number of inlined imported functions,
/// (2) Number of imported functions inlined into importing module (indirect),
/// (3) Number of non imported functions inlined into importing module
/// (indirect).
/// The difference between first and the second is that first stat counts
/// all performed inlines on imported functions, but the second one only the
/// functions that have been eventually inlined to a function in the importing
/// module (by a chain of inlines). Because llvm uses bottom-up inliner, it is
/// possible to e.g. import function `A`, `B` and then inline `B` to `A`,
/// and after this `A` might be too big to be inlined into some other function
/// that calls it. It calculates this statistic by building graph, where
/// the nodes are functions, and edges are performed inlines and then by marking
/// the edges starting from not imported function.
///
/// If `Verbose` is set to true, then it also dumps statistics
/// per each inlined function, sorted by the greatest inlines count like
/// - number of performed inlines
/// - number of performed inlines to importing module
class ImportedFunctionsInliningStatistics {};

enum class InlinerFunctionImportStatsOpts {};

} // llvm

#endif // LLVM_ANALYSIS_UTILS_IMPORTEDFUNCTIONSINLININGSTATISTICS_H