LLVM 22.0.0git
MemProfSummary.h
Go to the documentation of this file.
1//===- MemProfSummary.h - MemProf summary support ---------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains MemProf summary support.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_PROFILEDATA_MEMPROFSUMMARY_H
14#define LLVM_PROFILEDATA_MEMPROFSUMMARY_H
15
18
19namespace llvm {
20namespace memprof {
21
23private:
24 /// The number of summary fields below, which is used to enable some forwards
25 /// and backwards compatibility for the summary when serialized in the indexed
26 /// MemProf format. As long as no existing summary fields are removed or
27 /// reordered, and new summary fields are added after existing summary fields,
28 /// the MemProf indexed profile version does not need to be bumped to
29 /// accommodate new summary fields.
30 static constexpr unsigned NumSummaryFields = 6;
31
32 const uint64_t NumContexts, NumColdContexts, NumHotContexts;
33 const uint64_t MaxColdTotalSize, MaxWarmTotalSize, MaxHotTotalSize;
34
35public:
36 MemProfSummary(uint64_t NumContexts, uint64_t NumColdContexts,
37 uint64_t NumHotContexts, uint64_t MaxColdTotalSize,
38 uint64_t MaxWarmTotalSize, uint64_t MaxHotTotalSize)
39 : NumContexts(NumContexts), NumColdContexts(NumColdContexts),
40 NumHotContexts(NumHotContexts), MaxColdTotalSize(MaxColdTotalSize),
41 MaxWarmTotalSize(MaxWarmTotalSize), MaxHotTotalSize(MaxHotTotalSize) {}
42
43 static constexpr unsigned getNumSummaryFields() { return NumSummaryFields; }
44 uint64_t getNumContexts() const { return NumContexts; }
45 uint64_t getNumColdContexts() const { return NumColdContexts; }
46 uint64_t getNumHotContexts() const { return NumHotContexts; }
47 uint64_t getMaxColdTotalSize() const { return MaxColdTotalSize; }
48 uint64_t getMaxWarmTotalSize() const { return MaxWarmTotalSize; }
49 uint64_t getMaxHotTotalSize() const { return MaxHotTotalSize; }
51 /// Write to indexed MemProf profile.
52 LLVM_ABI void write(ProfOStream &OS) const;
53 /// Read from indexed MemProf profile.
54 LLVM_ABI static std::unique_ptr<MemProfSummary>
55 deserialize(const unsigned char *&);
56};
57
58} // namespace memprof
59} // namespace llvm
60
61#endif // LLVM_PROFILEDATA_MEMPROFSUMMARY_H
#define LLVM_ABI
Definition: Compiler.h:213
raw_pwrite_stream & OS
uint64_t getMaxColdTotalSize() const
LLVM_ABI void printSummaryYaml(raw_ostream &OS) const
MemProfSummary(uint64_t NumContexts, uint64_t NumColdContexts, uint64_t NumHotContexts, uint64_t MaxColdTotalSize, uint64_t MaxWarmTotalSize, uint64_t MaxHotTotalSize)
uint64_t getNumHotContexts() const
uint64_t getMaxHotTotalSize() const
uint64_t getNumColdContexts() const
uint64_t getMaxWarmTotalSize() const
LLVM_ABI void write(ProfOStream &OS) const
Write to indexed MemProf profile.
static LLVM_ABI std::unique_ptr< MemProfSummary > deserialize(const unsigned char *&)
Read from indexed MemProf profile.
uint64_t getNumContexts() const
static constexpr unsigned getNumSummaryFields()
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18