llvm/llvm/include/llvm/IR/ModuleSummaryIndex.h

//===- llvm/ModuleSummaryIndex.h - Module Summary Index ---------*- 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
//
//===----------------------------------------------------------------------===//
//
/// @file
/// ModuleSummaryIndex.h This file contains the declarations the classes that
///  hold the module index and summary for function importing.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_IR_MODULESUMMARYINDEX_H
#define LLVM_IR_MODULESUMMARYINDEX_H

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/ScaledNumber.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <array>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>

namespace llvm {

template <class GraphType> struct GraphTraits;

namespace yaml {

template <typename T> struct MappingTraits;

} // end namespace yaml

/// Class to accumulate and hold information about a callee.
struct CalleeInfo {};

inline const char *getHotnessName(CalleeInfo::HotnessType HT) {}

class GlobalValueSummary;

GlobalValueSummaryList;

struct alignas(8) GlobalValueSummaryInfo {};

/// Map from global value GUID to corresponding summary structures. Use a
/// std::map rather than a DenseMap so that pointers to the map's value_type
/// (which are used by ValueInfo) are not invalidated by insertion. Also it will
/// likely incur less overhead, as the value type is not very small and the size
/// of the map is unknown, resulting in inefficiencies due to repeated
/// insertions and resizing.
GlobalValueSummaryMapTy;

/// Struct that holds a reference to a particular GUID in a global value
/// summary.
struct ValueInfo {};

inline raw_ostream &operator<<(raw_ostream &OS, const ValueInfo &VI) {}

inline bool operator==(const ValueInfo &A, const ValueInfo &B) {}

inline bool operator!=(const ValueInfo &A, const ValueInfo &B) {}

inline bool operator<(const ValueInfo &A, const ValueInfo &B) {}

template <> struct DenseMapInfo<ValueInfo> {};

/// Summary of memprof callsite metadata.
struct CallsiteInfo {};

inline raw_ostream &operator<<(raw_ostream &OS, const CallsiteInfo &SNI) {}

// Allocation type assigned to an allocation reached by a given context.
// More can be added, now this is cold, notcold and hot.
// Values should be powers of two so that they can be ORed, in particular to
// track allocations that have different behavior with different calling
// contexts.
enum class AllocationType : uint8_t {};

/// Summary of a single MIB in a memprof metadata on allocations.
struct MIBInfo {};

inline raw_ostream &operator<<(raw_ostream &OS, const MIBInfo &MIB) {}

/// Summary of memprof metadata on allocations.
struct AllocInfo {};

inline raw_ostream &operator<<(raw_ostream &OS, const AllocInfo &AE) {}

/// Function and variable summary information to aid decisions and
/// implementation of importing.
class GlobalValueSummary {};

GlobalValueSummaryInfo::GlobalValueSummaryInfo(bool HaveGVs) :{}

/// Alias summary information.
class AliasSummary : public GlobalValueSummary {};

const inline GlobalValueSummary *GlobalValueSummary::getBaseObject() const {}

inline GlobalValueSummary *GlobalValueSummary::getBaseObject() {}

/// Function summary information to aid decisions and implementation of
/// importing.
class FunctionSummary : public GlobalValueSummary {};

template <> struct DenseMapInfo<FunctionSummary::VFuncId> {};

template <> struct DenseMapInfo<FunctionSummary::ConstVCall> {};

/// The ValueInfo and offset for a function within a vtable definition
/// initializer array.
struct VirtFuncOffset {};
/// List of functions referenced by a particular vtable definition.
VTableFuncList;

/// Global variable summary information to aid decisions and
/// implementation of importing.
///
/// Global variable summary has two extra flag, telling if it is
/// readonly or writeonly. Both readonly and writeonly variables
/// can be optimized in the backed: readonly variables can be
/// const-folded, while writeonly vars can be completely eliminated
/// together with corresponding stores. We let both things happen
/// by means of internalizing such variables after ThinLTO import.
class GlobalVarSummary : public GlobalValueSummary {};

struct TypeTestResolution {};

struct WholeProgramDevirtResolution {};

struct TypeIdSummary {};

/// 160 bits SHA1
ModuleHash;

/// Type used for iterating through the global value summary map.
const_gvsummary_iterator;
gvsummary_iterator;

/// String table to hold/own module path strings, as well as a hash
/// of the module. The StringMap makes a copy of and owns inserted strings.
ModulePathStringTableTy;

/// Map of global value GUID to its summary, used to identify values defined in
/// a particular module, and provide efficient access to their summary.
GVSummaryMapTy;

/// Map of a module name to the GUIDs and summaries we will import from that
/// module.
ModuleToSummariesForIndexTy;

/// A set of global value summary pointers.
GVSummaryPtrSet;

/// Map of a type GUID to type id string and summary (multimap used
/// in case of GUID conflicts).
TypeIdSummaryMapTy;

/// The following data structures summarize type metadata information.
/// For type metadata overview see https://llvm.org/docs/TypeMetadata.html.
/// Each type metadata includes both the type identifier and the offset of
/// the address point of the type (the address held by objects of that type
/// which may not be the beginning of the virtual table). Vtable definitions
/// are decorated with type metadata for the types they are compatible with.
///
/// Holds information about vtable definitions decorated with type metadata:
/// the vtable definition value and its address point offset in a type
/// identifier metadata it is decorated (compatible) with.
struct TypeIdOffsetVtableInfo {};
/// List of vtable definitions decorated by a particular type identifier,
/// and their corresponding offsets in that type identifier's metadata.
/// Note that each type identifier may be compatible with multiple vtables, due
/// to inheritance, which is why this is a vector.
TypeIdCompatibleVtableInfo;

/// Class to hold module path string table and global value map,
/// and encapsulate methods for operating on them.
class ModuleSummaryIndex {};

/// GraphTraits definition to build SCC for the index
template <> struct GraphTraits<ValueInfo> {};

template <>
struct GraphTraits<ModuleSummaryIndex *> : public GraphTraits<ValueInfo> {};
} // end namespace llvm

#endif // LLVM_IR_MODULESUMMARYINDEX_H