LLVM  14.0.0git
InstrProfReader.h
Go to the documentation of this file.
1 //===- InstrProfReader.h - Instrumented profiling readers -------*- 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 support for reading profiling data for instrumentation
10 // based PGO and coverage.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_PROFILEDATA_INSTRPROFREADER_H
15 #define LLVM_PROFILEDATA_INSTRPROFREADER_H
16 
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/IR/ProfileSummary.h"
22 #include "llvm/Support/Endian.h"
23 #include "llvm/Support/Error.h"
28 #include <algorithm>
29 #include <cassert>
30 #include <cstddef>
31 #include <cstdint>
32 #include <iterator>
33 #include <memory>
34 #include <utility>
35 #include <vector>
36 
37 namespace llvm {
38 
39 class InstrProfReader;
40 
41 /// A file format agnostic iterator over profiling data.
43 public:
44  using iterator_category = std::input_iterator_tag;
46  using difference_type = std::ptrdiff_t;
47  using pointer = value_type *;
48  using reference = value_type &;
49 
50 private:
51  InstrProfReader *Reader = nullptr;
53 
54  void Increment();
55 
56 public:
57  InstrProfIterator() = default;
58  InstrProfIterator(InstrProfReader *Reader) : Reader(Reader) { Increment(); }
59 
60  InstrProfIterator &operator++() { Increment(); return *this; }
61  bool operator==(const InstrProfIterator &RHS) const {
62  return Reader == RHS.Reader;
63  }
64  bool operator!=(const InstrProfIterator &RHS) const {
65  return Reader != RHS.Reader;
66  }
67  value_type &operator*() { return Record; }
68  value_type *operator->() { return &Record; }
69 };
70 
71 /// Base class and interface for reading profiling data of any known instrprof
72 /// format. Provides an iterator over NamedInstrProfRecords.
75  std::string LastErrorMsg;
76 
77 public:
78  InstrProfReader() = default;
79  virtual ~InstrProfReader() = default;
80 
81  /// Read the header. Required before reading first record.
82  virtual Error readHeader() = 0;
83 
84  /// Read a single record.
86 
87  /// Print binary ids on stream OS.
88  virtual Error printBinaryIds(raw_ostream &OS) { return success(); };
89 
90  /// Iterator over profile data.
93 
94  virtual bool isIRLevelProfile() const = 0;
95 
96  virtual bool hasCSIRLevelProfile() const = 0;
97 
98  virtual bool instrEntryBBEnabled() const = 0;
99 
100  /// Return true if we must provide debug info to create PGO profiles.
101  virtual bool useDebugInfoCorrelate() const { return false; }
102 
103  /// Return the PGO symtab. There are three different readers:
104  /// Raw, Text, and Indexed profile readers. The first two types
105  /// of readers are used only by llvm-profdata tool, while the indexed
106  /// profile reader is also used by llvm-cov tool and the compiler (
107  /// backend or frontend). Since creating PGO symtab can create
108  /// significant runtime and memory overhead (as it touches data
109  /// for the whole program), InstrProfSymtab for the indexed profile
110  /// reader should be created on demand and it is recommended to be
111  /// only used for dumping purpose with llvm-proftool, not with the
112  /// compiler.
113  virtual InstrProfSymtab &getSymtab() = 0;
114 
115  /// Compute the sum of counts and return in Sum.
116  void accumulateCounts(CountSumOrPercent &Sum, bool IsCS);
117 
118 protected:
119  std::unique_ptr<InstrProfSymtab> Symtab;
120 
121  /// Set the current error and return same.
122  Error error(instrprof_error Err, const std::string &ErrMsg = "") {
123  LastError = Err;
124  LastErrorMsg = ErrMsg;
125  if (Err == instrprof_error::success)
126  return Error::success();
127  return make_error<InstrProfError>(Err, ErrMsg);
128  }
129 
131  handleAllErrors(std::move(E), [&](const InstrProfError &IPE) {
132  LastError = IPE.get();
133  LastErrorMsg = IPE.getMessage();
134  });
135  return make_error<InstrProfError>(LastError, LastErrorMsg);
136  }
137 
138  /// Clear the current error and return a successful one.
140 
141 public:
142  /// Return true if the reader has finished reading the profile data.
143  bool isEOF() { return LastError == instrprof_error::eof; }
144 
145  /// Return true if the reader encountered an error reading profiling data.
146  bool hasError() { return LastError != instrprof_error::success && !isEOF(); }
147 
148  /// Get the current error.
150  if (hasError())
151  return make_error<InstrProfError>(LastError, LastErrorMsg);
152  return Error::success();
153  }
154 
155  /// Factory method to create an appropriately typed reader for the given
156  /// instrprof file.
158  create(const Twine &Path, const InstrProfCorrelator *Correlator = nullptr);
159 
161  create(std::unique_ptr<MemoryBuffer> Buffer,
162  const InstrProfCorrelator *Correlator = nullptr);
163 };
164 
165 /// Reader for the simple text based instrprof format.
166 ///
167 /// This format is a simple text format that's suitable for test data. Records
168 /// are separated by one or more blank lines, and record fields are separated by
169 /// new lines.
170 ///
171 /// Each record consists of a function name, a function hash, a number of
172 /// counters, and then each counter value, in that order.
174 private:
175  /// The profile data file contents.
176  std::unique_ptr<MemoryBuffer> DataBuffer;
177  /// Iterator over the profile data.
178  line_iterator Line;
179  bool IsIRLevelProfile = false;
180  bool HasCSIRLevelProfile = false;
181  bool InstrEntryBBEnabled = false;
182 
183  Error readValueProfileData(InstrProfRecord &Record);
184 
185 public:
186  TextInstrProfReader(std::unique_ptr<MemoryBuffer> DataBuffer_)
187  : DataBuffer(std::move(DataBuffer_)), Line(*DataBuffer, true, '#') {}
188  TextInstrProfReader(const TextInstrProfReader &) = delete;
190 
191  /// Return true if the given buffer is in text instrprof format.
192  static bool hasFormat(const MemoryBuffer &Buffer);
193 
194  bool isIRLevelProfile() const override { return IsIRLevelProfile; }
195 
196  bool hasCSIRLevelProfile() const override { return HasCSIRLevelProfile; }
197 
198  bool instrEntryBBEnabled() const override { return InstrEntryBBEnabled; }
199 
200  /// Read the header.
201  Error readHeader() override;
202 
203  /// Read a single record.
205 
207  assert(Symtab.get());
208  return *Symtab.get();
209  }
210 };
211 
212 /// Reader for the raw instrprof binary format from runtime.
213 ///
214 /// This format is a raw memory dump of the instrumentation-based profiling data
215 /// from the runtime. It has no index.
216 ///
217 /// Templated on the unsigned type whose size matches pointers on the platform
218 /// that wrote the profile.
219 template <class IntPtrT>
221 private:
222  /// The profile data file contents.
223  std::unique_ptr<MemoryBuffer> DataBuffer;
224  /// If available, this hold the ProfileData array used to correlate raw
225  /// instrumentation data to their functions.
226  const InstrProfCorrelatorImpl<IntPtrT> *Correlator;
227  bool ShouldSwapBytes;
228  // The value of the version field of the raw profile data header. The lower 56
229  // bits specifies the format version and the most significant 8 bits specify
230  // the variant types of the profile.
231  uint64_t Version;
232  uint64_t CountersDelta;
233  uint64_t NamesDelta;
235  const RawInstrProf::ProfileData<IntPtrT> *DataEnd;
236  const char *CountersStart;
237  const char *CountersEnd;
238  const char *NamesStart;
239  const char *NamesEnd;
240  // After value profile is all read, this pointer points to
241  // the header of next profile data (if exists)
242  const uint8_t *ValueDataStart;
243  uint32_t ValueKindLast;
244  uint32_t CurValueDataSize;
245 
246  uint64_t BinaryIdsSize;
247  const uint8_t *BinaryIdsStart;
248 
249 public:
250  RawInstrProfReader(std::unique_ptr<MemoryBuffer> DataBuffer,
251  const InstrProfCorrelator *Correlator)
252  : DataBuffer(std::move(DataBuffer)),
253  Correlator(dyn_cast_or_null<const InstrProfCorrelatorImpl<IntPtrT>>(
254  Correlator)) {}
255  RawInstrProfReader(const RawInstrProfReader &) = delete;
257 
258  static bool hasFormat(const MemoryBuffer &DataBuffer);
259  Error readHeader() override;
261  Error printBinaryIds(raw_ostream &OS) override;
262 
263  bool isIRLevelProfile() const override {
264  return (Version & VARIANT_MASK_IR_PROF) != 0;
265  }
266 
267  bool hasCSIRLevelProfile() const override {
268  return (Version & VARIANT_MASK_CSIR_PROF) != 0;
269  }
270 
271  bool instrEntryBBEnabled() const override {
272  return (Version & VARIANT_MASK_INSTR_ENTRY) != 0;
273  }
274 
275  bool useDebugInfoCorrelate() const override {
276  return (Version & VARIANT_MASK_DBG_CORRELATE) != 0;
277  }
278 
280  assert(Symtab.get());
281  return *Symtab.get();
282  }
283 
284 private:
285  Error createSymtab(InstrProfSymtab &Symtab);
286  Error readNextHeader(const char *CurrentPos);
287  Error readHeader(const RawInstrProf::Header &Header);
288 
289  template <class IntT> IntT swap(IntT Int) const {
290  return ShouldSwapBytes ? sys::getSwappedBytes(Int) : Int;
291  }
292 
293  support::endianness getDataEndianness() const {
294  support::endianness HostEndian = getHostEndianness();
295  if (!ShouldSwapBytes)
296  return HostEndian;
297  if (HostEndian == support::little)
298  return support::big;
299  else
300  return support::little;
301  }
302 
303  inline uint8_t getNumPaddingBytes(uint64_t SizeInBytes) {
304  return 7 & (sizeof(uint64_t) - SizeInBytes % sizeof(uint64_t));
305  }
306 
307  Error readName(NamedInstrProfRecord &Record);
308  Error readFuncHash(NamedInstrProfRecord &Record);
309  Error readRawCounts(InstrProfRecord &Record);
310  Error readValueProfilingData(InstrProfRecord &Record);
311  bool atEnd() const { return Data == DataEnd; }
312 
313  void advanceData() {
314  // `CountersDelta` is a constant zero when using debug info correlation.
315  if (!Correlator) {
316  // The initial CountersDelta is the in-memory address difference between
317  // the data and counts sections:
318  // start(__llvm_prf_cnts) - start(__llvm_prf_data)
319  // As we advance to the next record, we maintain the correct CountersDelta
320  // with respect to the next record.
321  CountersDelta -= sizeof(*Data);
322  }
323  Data++;
324  ValueDataStart += CurValueDataSize;
325  }
326 
327  const char *getNextHeaderPos() const {
328  assert(atEnd());
329  return (const char *)ValueDataStart;
330  }
331 
332  StringRef getName(uint64_t NameRef) const {
333  return Symtab->getFuncName(swap(NameRef));
334  }
335 
336  int getCounterTypeSize() const { return sizeof(uint64_t); }
337 };
338 
341 
342 namespace IndexedInstrProf {
343 
344 enum class HashT : uint32_t;
345 
346 } // end namespace IndexedInstrProf
347 
348 /// Trait for lookups into the on-disk hash table for the binary instrprof
349 /// format.
351  std::vector<NamedInstrProfRecord> DataBuffer;
353  unsigned FormatVersion;
354  // Endianness of the input value profile data.
355  // It should be LE by default, but can be changed
356  // for testing purpose.
357  support::endianness ValueProfDataEndianness = support::little;
358 
359 public:
361  : HashType(HashType), FormatVersion(FormatVersion) {}
362 
364 
369 
370  static bool EqualKey(StringRef A, StringRef B) { return A == B; }
371  static StringRef GetInternalKey(StringRef K) { return K; }
372  static StringRef GetExternalKey(StringRef K) { return K; }
373 
374  hash_value_type ComputeHash(StringRef K);
375 
376  static std::pair<offset_type, offset_type>
377  ReadKeyDataLength(const unsigned char *&D) {
378  using namespace support;
379 
380  offset_type KeyLen = endian::readNext<offset_type, little, unaligned>(D);
381  offset_type DataLen = endian::readNext<offset_type, little, unaligned>(D);
382  return std::make_pair(KeyLen, DataLen);
383  }
384 
385  StringRef ReadKey(const unsigned char *D, offset_type N) {
386  return StringRef((const char *)D, N);
387  }
388 
389  bool readValueProfilingData(const unsigned char *&D,
390  const unsigned char *const End);
391  data_type ReadData(StringRef K, const unsigned char *D, offset_type N);
392 
393  // Used for testing purpose only.
395  ValueProfDataEndianness = Endianness;
396  }
397 };
398 
400  virtual ~InstrProfReaderIndexBase() = default;
401 
402  // Read all the profile records with the same key pointed to the current
403  // iterator.
404  virtual Error getRecords(ArrayRef<NamedInstrProfRecord> &Data) = 0;
405 
406  // Read all the profile records with the key equal to FuncName
407  virtual Error getRecords(StringRef FuncName,
409  virtual void advanceToNextKey() = 0;
410  virtual bool atEnd() const = 0;
411  virtual void setValueProfDataEndianness(support::endianness Endianness) = 0;
412  virtual uint64_t getVersion() const = 0;
413  virtual bool isIRLevelProfile() const = 0;
414  virtual bool hasCSIRLevelProfile() const = 0;
415  virtual bool instrEntryBBEnabled() const = 0;
416  virtual Error populateSymtab(InstrProfSymtab &) = 0;
417 };
418 
419 using OnDiskHashTableImplV3 =
421 
422 template <typename HashTableImpl>
424 
425 template <typename HashTableImpl>
427 private:
428  std::unique_ptr<HashTableImpl> HashTable;
429  typename HashTableImpl::data_iterator RecordIterator;
430  uint64_t FormatVersion;
431 
432  friend class InstrProfReaderItaniumRemapper<HashTableImpl>;
433 
434 public:
435  InstrProfReaderIndex(const unsigned char *Buckets,
436  const unsigned char *const Payload,
437  const unsigned char *const Base,
439  ~InstrProfReaderIndex() override = default;
440 
441  Error getRecords(ArrayRef<NamedInstrProfRecord> &Data) override;
442  Error getRecords(StringRef FuncName,
444  void advanceToNextKey() override { RecordIterator++; }
445 
446  bool atEnd() const override {
447  return RecordIterator == HashTable->data_end();
448  }
449 
451  HashTable->getInfoObj().setValueProfDataEndianness(Endianness);
452  }
453 
454  uint64_t getVersion() const override { return GET_VERSION(FormatVersion); }
455 
456  bool isIRLevelProfile() const override {
457  return (FormatVersion & VARIANT_MASK_IR_PROF) != 0;
458  }
459 
460  bool hasCSIRLevelProfile() const override {
461  return (FormatVersion & VARIANT_MASK_CSIR_PROF) != 0;
462  }
463 
464  bool instrEntryBBEnabled() const override {
465  return (FormatVersion & VARIANT_MASK_INSTR_ENTRY) != 0;
466  }
467 
469  return Symtab.create(HashTable->keys());
470  }
471 };
472 
473 /// Name matcher supporting fuzzy matching of symbol names to names in profiles.
475 public:
477  virtual Error populateRemappings() { return Error::success(); }
478  virtual Error getRecords(StringRef FuncName,
480 };
481 
482 /// Reader for the indexed binary instrprof format.
484 private:
485  /// The profile data file contents.
486  std::unique_ptr<MemoryBuffer> DataBuffer;
487  /// The profile remapping file contents.
488  std::unique_ptr<MemoryBuffer> RemappingBuffer;
489  /// The index into the profile data.
490  std::unique_ptr<InstrProfReaderIndexBase> Index;
491  /// The profile remapping file contents.
492  std::unique_ptr<InstrProfReaderRemapper> Remapper;
493  /// Profile summary data.
494  std::unique_ptr<ProfileSummary> Summary;
495  /// Context sensitive profile summary data.
496  std::unique_ptr<ProfileSummary> CS_Summary;
497  // Index to the current record in the record array.
498  unsigned RecordIndex;
499 
500  // Read the profile summary. Return a pointer pointing to one byte past the
501  // end of the summary data if it exists or the input \c Cur.
502  // \c UseCS indicates whether to use the context-sensitive profile summary.
503  const unsigned char *readSummary(IndexedInstrProf::ProfVersion Version,
504  const unsigned char *Cur, bool UseCS);
505 
506 public:
508  std::unique_ptr<MemoryBuffer> DataBuffer,
509  std::unique_ptr<MemoryBuffer> RemappingBuffer = nullptr)
510  : DataBuffer(std::move(DataBuffer)),
511  RemappingBuffer(std::move(RemappingBuffer)), RecordIndex(0) {}
513  IndexedInstrProfReader &operator=(const IndexedInstrProfReader &) = delete;
514 
515  /// Return the profile version.
516  uint64_t getVersion() const { return Index->getVersion(); }
517  bool isIRLevelProfile() const override { return Index->isIRLevelProfile(); }
518  bool hasCSIRLevelProfile() const override {
519  return Index->hasCSIRLevelProfile();
520  }
521 
522  bool instrEntryBBEnabled() const override {
523  return Index->instrEntryBBEnabled();
524  }
525 
526  /// Return true if the given buffer is in an indexed instrprof format.
527  static bool hasFormat(const MemoryBuffer &DataBuffer);
528 
529  /// Read the file header.
530  Error readHeader() override;
531  /// Read a single record.
532  Error readNextRecord(NamedInstrProfRecord &Record) override;
533 
534  /// Return the NamedInstrProfRecord associated with FuncName and FuncHash
535  Expected<InstrProfRecord> getInstrProfRecord(StringRef FuncName,
536  uint64_t FuncHash);
537 
538  /// Fill Counts with the profile data for the given function name.
539  Error getFunctionCounts(StringRef FuncName, uint64_t FuncHash,
540  std::vector<uint64_t> &Counts);
541 
542  /// Return the maximum of all known function counts.
543  /// \c UseCS indicates whether to use the context-sensitive count.
545  if (UseCS) {
546  assert(CS_Summary && "No context sensitive profile summary");
547  return CS_Summary->getMaxFunctionCount();
548  } else {
549  assert(Summary && "No profile summary");
550  return Summary->getMaxFunctionCount();
551  }
552  }
553 
554  /// Factory method to create an indexed reader.
556  create(const Twine &Path, const Twine &RemappingPath = "");
557 
559  create(std::unique_ptr<MemoryBuffer> Buffer,
560  std::unique_ptr<MemoryBuffer> RemappingBuffer = nullptr);
561 
562  // Used for testing purpose only.
564  Index->setValueProfDataEndianness(Endianness);
565  }
566 
567  // See description in the base class. This interface is designed
568  // to be used by llvm-profdata (for dumping). Avoid using this when
569  // the client is the compiler.
570  InstrProfSymtab &getSymtab() override;
571 
572  /// Return the profile summary.
573  /// \c UseCS indicates whether to use the context-sensitive summary.
574  ProfileSummary &getSummary(bool UseCS) {
575  if (UseCS) {
576  assert(CS_Summary && "No context sensitive summary");
577  return *(CS_Summary.get());
578  } else {
579  assert(Summary && "No profile summary");
580  return *(Summary.get());
581  }
582  }
583 };
584 
585 } // end namespace llvm
586 
587 #endif // LLVM_PROFILEDATA_INSTRPROFREADER_H
MemoryBuffer.h
llvm::RawInstrProfReader
Reader for the raw instrprof binary format from runtime.
Definition: InstrProfReader.h:220
llvm::IndexedInstrProfReader::getSummary
ProfileSummary & getSummary(bool UseCS)
Return the profile summary.
Definition: InstrProfReader.h:574
llvm::InstrProfReader::success
Error success()
Clear the current error and return a successful one.
Definition: InstrProfReader.h:139
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:22
llvm::InstrProfReaderIndex::atEnd
bool atEnd() const override
Definition: InstrProfReader.h:446
llvm::TextInstrProfReader::instrEntryBBEnabled
bool instrEntryBBEnabled() const override
Definition: InstrProfReader.h:198
llvm::msgpack::Endianness
constexpr support::endianness Endianness
The endianness of all multi-byte encoded values in MessagePack.
Definition: MsgPack.h:24
llvm::IndexedInstrProf::ProfVersion
ProfVersion
Definition: InstrProf.h:972
offset_type
InstrProfLookupTrait::offset_type offset_type
Definition: InstrProfReader.cpp:616
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
llvm::InstrProfReader::InstrProfReader
InstrProfReader()=default
llvm::line_iterator
A forward iterator which reads text lines from a buffer.
Definition: LineIterator.h:33
llvm::RawInstrProfReader::instrEntryBBEnabled
bool instrEntryBBEnabled() const override
Definition: InstrProfReader.h:271
ProfileSummary.h
StringRef.h
llvm::InstrProfReaderIndex::advanceToNextKey
void advanceToNextKey() override
Definition: InstrProfReader.h:444
llvm::InstrProfReader::readNextRecord
virtual Error readNextRecord(NamedInstrProfRecord &Record)=0
Read a single record.
llvm::IndexedInstrProf::ComputeHash
uint64_t ComputeHash(StringRef K)
Definition: InstrProf.h:1003
llvm::InstrProfSymtab::create
Error create(object::SectionRef &Section)
Create InstrProfSymtab from an object file section which contains function PGO names.
llvm::InstrProfError::get
instrprof_error get() const
Definition: InstrProf.h:328
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
llvm::InstrProfReader::isEOF
bool isEOF()
Return true if the reader has finished reading the profile data.
Definition: InstrProfReader.h:143
Error.h
SwapByteOrder.h
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1886
llvm::InstrProfIterator::InstrProfIterator
InstrProfIterator(InstrProfReader *Reader)
Definition: InstrProfReader.h:58
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
RHS
Value * RHS
Definition: X86PartialReduction.cpp:74
llvm::InstrProfLookupTrait::GetInternalKey
static StringRef GetInternalKey(StringRef K)
Definition: InstrProfReader.h:371
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::MemoryBuffer
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:50
llvm::InstrProfRecord
Profiling information for a single function.
Definition: InstrProf.h:699
llvm::IndexedInstrProfReader::isIRLevelProfile
bool isIRLevelProfile() const override
Definition: InstrProfReader.h:517
llvm::IndexedInstrProfReader::setValueProfDataEndianness
void setValueProfDataEndianness(support::endianness Endianness)
Definition: InstrProfReader.h:563
llvm::TextInstrProfReader::operator=
TextInstrProfReader & operator=(const TextInstrProfReader &)=delete
llvm::InstrProfCorrelatorImpl
InstrProfCorrelatorImpl - A child of InstrProfCorrelator with a template pointer type so that the Pro...
Definition: InstrProfCorrelator.h:72
llvm::TextInstrProfReader::readHeader
Error readHeader() override
Read the header.
Definition: InstrProfReader.cpp:155
llvm::InstrProfReader::hasError
bool hasError()
Return true if the reader encountered an error reading profiling data.
Definition: InstrProfReader.h:146
llvm::InstrProfLookupTrait
Trait for lookups into the on-disk hash table for the binary instrprof format.
Definition: InstrProfReader.h:350
llvm::TextInstrProfReader::getSymtab
InstrProfSymtab & getSymtab() override
Return the PGO symtab.
Definition: InstrProfReader.h:206
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::support::little
@ little
Definition: Endian.h:27
llvm::InstrProfLookupTrait::setValueProfDataEndianness
void setValueProfDataEndianness(support::endianness Endianness)
Definition: InstrProfReader.h:394
llvm::InstrProfLookupTrait::EqualKey
static bool EqualKey(StringRef A, StringRef B)
Definition: InstrProfReader.h:370
llvm::InstrProfIterator::operator!=
bool operator!=(const InstrProfIterator &RHS) const
Definition: InstrProfReader.h:64
OnDiskHashTable.h
llvm::InstrProfError::getMessage
const std::string & getMessage() const
Definition: InstrProf.h:329
llvm::RawInstrProfReader::RawInstrProfReader
RawInstrProfReader(std::unique_ptr< MemoryBuffer > DataBuffer, const InstrProfCorrelator *Correlator)
Definition: InstrProfReader.h:250
llvm::InstrProfReader::hasCSIRLevelProfile
virtual bool hasCSIRLevelProfile() const =0
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
InstrProf.h
LineIterator.h
llvm::InstrProfReaderIndex::setValueProfDataEndianness
void setValueProfDataEndianness(support::endianness Endianness) override
Definition: InstrProfReader.h:450
llvm::InstrProfIterator::operator*
value_type & operator*()
Definition: InstrProfReader.h:67
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::TextInstrProfReader::hasCSIRLevelProfile
bool hasCSIRLevelProfile() const override
Definition: InstrProfReader.h:196
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:999
llvm::TextInstrProfReader::readNextRecord
Error readNextRecord(NamedInstrProfRecord &Record) override
Read a single record.
Definition: InstrProfReader.cpp:256
llvm::InstrProfLookupTrait::GetExternalKey
static StringRef GetExternalKey(StringRef K)
Definition: InstrProfReader.h:372
llvm::InstrProfReader::Symtab
std::unique_ptr< InstrProfSymtab > Symtab
Definition: InstrProfReader.h:119
llvm::InstrProfReaderRemapper::populateRemappings
virtual Error populateRemappings()
Definition: InstrProfReader.h:477
llvm::sys::getSwappedBytes
unsigned char getSwappedBytes(unsigned char C)
Definition: SwapByteOrder.h:103
llvm::getHostEndianness
support::endianness getHostEndianness()
Definition: InstrProf.h:936
llvm::InstrProfIterator::iterator_category
std::input_iterator_tag iterator_category
Definition: InstrProfReader.h:44
llvm::InstrProfIterator::operator++
InstrProfIterator & operator++()
Definition: InstrProfReader.h:60
llvm::InstrProfReaderIndex::isIRLevelProfile
bool isIRLevelProfile() const override
Definition: InstrProfReader.h:456
llvm::InstrProfReader::~InstrProfReader
virtual ~InstrProfReader()=default
Index
uint32_t Index
Definition: ELFObjHandler.cpp:83
uint64_t
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::IndexedInstrProfReader::getVersion
uint64_t getVersion() const
Return the profile version.
Definition: InstrProfReader.h:516
llvm::IndexedInstrProfReader
Reader for the indexed binary instrprof format.
Definition: InstrProfReader.h:483
llvm::InstrProfError
Definition: InstrProf.h:313
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::InstrProfIterator::difference_type
std::ptrdiff_t difference_type
Definition: InstrProfReader.h:46
llvm::InstrProfReader::error
Error error(Error &&E)
Definition: InstrProfReader.h:130
llvm::InstrProfReaderRemapper::~InstrProfReaderRemapper
virtual ~InstrProfReaderRemapper()
Definition: InstrProfReader.h:476
llvm::TextInstrProfReader
Reader for the simple text based instrprof format.
Definition: InstrProfReader.h:173
llvm::CountSumOrPercent
Definition: InstrProf.h:605
llvm::instrprof_error
instrprof_error
Definition: InstrProf.h:282
llvm::instrprof_error::success
@ success
ArrayRef.h
llvm::ProfileSummary
Definition: ProfileSummary.h:45
llvm::InstrProfReader::isIRLevelProfile
virtual bool isIRLevelProfile() const =0
llvm::InstrProfReaderIndex::hasCSIRLevelProfile
bool hasCSIRLevelProfile() const override
Definition: InstrProfReader.h:460
llvm::InstrProfLookupTrait::InstrProfLookupTrait
InstrProfLookupTrait(IndexedInstrProf::HashT HashType, unsigned FormatVersion)
Definition: InstrProfReader.h:360
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::IndexedInstrProfReader::IndexedInstrProfReader
IndexedInstrProfReader(std::unique_ptr< MemoryBuffer > DataBuffer, std::unique_ptr< MemoryBuffer > RemappingBuffer=nullptr)
Definition: InstrProfReader.h:507
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1650
llvm::RawInstrProfReader::isIRLevelProfile
bool isIRLevelProfile() const override
Definition: InstrProfReader.h:263
llvm::RawInstrProfReader::hasCSIRLevelProfile
bool hasCSIRLevelProfile() const override
Definition: InstrProfReader.h:267
llvm::Record
Definition: Record.h:1485
llvm::InstrProfReader::printBinaryIds
virtual Error printBinaryIds(raw_ostream &OS)
Print binary ids on stream OS.
Definition: InstrProfReader.h:88
llvm::OnDiskIterableChainedHashTable
Provides lookup and iteration over an on disk hash table.
Definition: OnDiskHashTable.h:431
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::InstrProfReader::useDebugInfoCorrelate
virtual bool useDebugInfoCorrelate() const
Return true if we must provide debug info to create PGO profiles.
Definition: InstrProfReader.h:101
llvm::InstrProfReaderIndex
Definition: InstrProfReader.h:426
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::IndexedInstrProf::HashT
HashT
Definition: InstrProf.h:957
llvm::RawInstrProfReader::operator=
RawInstrProfReader & operator=(const RawInstrProfReader &)=delete
llvm::InstrProfReader::instrEntryBBEnabled
virtual bool instrEntryBBEnabled() const =0
llvm::InstrProfIterator::operator->
value_type * operator->()
Definition: InstrProfReader.h:68
uint32_t
llvm::instrprof_error::eof
@ eof
llvm::IndexedInstrProfReader::hasCSIRLevelProfile
bool hasCSIRLevelProfile() const override
Definition: InstrProfReader.h:518
llvm::RawInstrProfReader::readHeader
Error readHeader() override
Read the header. Required before reading first record.
Definition: InstrProfReader.cpp:317
llvm::RawInstrProfReader::hasFormat
static bool hasFormat(const MemoryBuffer &DataBuffer)
Definition: InstrProfReader.cpp:307
llvm::InstrProfReaderItaniumRemapper
A remapper that applies remappings based on a symbol remapping file.
Definition: InstrProfReader.h:423
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
std
Definition: BitVector.h:850
llvm::InstrProfSymtab
A symbol table used for function PGO name look-up with keys (such as pointers, md5hash values) to the...
Definition: InstrProf.h:421
llvm::InstrProfReader::accumulateCounts
void accumulateCounts(CountSumOrPercent &Sum, bool IsCS)
Compute the sum of counts and return in Sum.
Definition: InstrProfReader.cpp:1016
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::RawInstrProfReader::getSymtab
InstrProfSymtab & getSymtab() override
Return the PGO symtab.
Definition: InstrProfReader.h:279
llvm::InstrProfReaderIndex::populateSymtab
Error populateSymtab(InstrProfSymtab &Symtab) override
Definition: InstrProfReader.h:468
llvm::InstrProfReaderRemapper
Name matcher supporting fuzzy matching of symbol names to names in profiles.
Definition: InstrProfReader.h:474
llvm::InstrProfReader::create
static Expected< std::unique_ptr< InstrProfReader > > create(const Twine &Path, const InstrProfCorrelator *Correlator=nullptr)
Factory method to create an appropriately typed reader for the given instrprof file.
Definition: InstrProfReader.cpp:55
llvm::InstrProfReader::readHeader
virtual Error readHeader()=0
Read the header. Required before reading first record.
llvm::RawInstrProfReader::readNextRecord
Error readNextRecord(NamedInstrProfRecord &Record) override
Read a single record.
Definition: InstrProfReader.cpp:526
llvm::IndexedInstrProf::HashType
const HashT HashType
Definition: InstrProf.h:1001
llvm::InstrProfReaderIndexBase
Definition: InstrProfReader.h:399
llvm::InstrProfReaderIndex::instrEntryBBEnabled
bool instrEntryBBEnabled() const override
Definition: InstrProfReader.h:464
llvm::IndexedInstrProfReader::instrEntryBBEnabled
bool instrEntryBBEnabled() const override
Definition: InstrProfReader.h:522
llvm::InstrProfReader::getError
Error getError()
Get the current error.
Definition: InstrProfReader.h:149
llvm::RawInstrProf::ProfileData
Definition: InstrProf.h:1133
llvm::TextInstrProfReader::TextInstrProfReader
TextInstrProfReader(std::unique_ptr< MemoryBuffer > DataBuffer_)
Definition: InstrProfReader.h:186
llvm::RawInstrProfReader::printBinaryIds
Error printBinaryIds(raw_ostream &OS) override
Print binary ids on stream OS.
Definition: InstrProfReader.cpp:558
llvm::TextInstrProfReader::hasFormat
static bool hasFormat(const MemoryBuffer &Buffer)
Return true if the given buffer is in text instrprof format.
Definition: InstrProfReader.cpp:142
N
#define N
llvm::TextInstrProfReader::isIRLevelProfile
bool isIRLevelProfile() const override
Definition: InstrProfReader.h:194
llvm::InstrProfReader::end
InstrProfIterator end()
Definition: InstrProfReader.h:92
data_type
InstrProfLookupTrait::data_type data_type
Definition: InstrProfReader.cpp:615
support
Reimplement select in terms of SEL *We would really like to support but we need to prove that the add doesn t need to overflow between the two bit chunks *Implement pre post increment support(e.g. PR935) *Implement smarter const ant generation for binops with large immediates. A few ARMv6T2 ops should be pattern matched
Definition: README.txt:10
llvm::InstrProfLookupTrait::ReadKey
StringRef ReadKey(const unsigned char *D, offset_type N)
Definition: InstrProfReader.h:385
llvm::support::endianness
endianness
Definition: Endian.h:27
llvm::InstrProfCorrelator
InstrProfCorrelator - A base class used to create raw instrumentation data to their functions.
Definition: InstrProfCorrelator.h:29
llvm::dyn_cast_or_null
LLVM_NODISCARD std::enable_if_t< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast_or_null(const Y &Val)
Definition: Casting.h:354
llvm::NamedInstrProfRecord
Definition: InstrProf.h:856
llvm::InstrProfReaderIndex::getVersion
uint64_t getVersion() const override
Definition: InstrProfReader.h:454
InstrProfCorrelator.h
llvm::InstrProfLookupTrait::ReadKeyDataLength
static std::pair< offset_type, offset_type > ReadKeyDataLength(const unsigned char *&D)
Definition: InstrProfReader.h:377
llvm::InstrProfIterator
A file format agnostic iterator over profiling data.
Definition: InstrProfReader.h:42
llvm::InstrProfReader::getSymtab
virtual InstrProfSymtab & getSymtab()=0
Return the PGO symtab.
llvm::IndexedInstrProfReader::getMaximumFunctionCount
uint64_t getMaximumFunctionCount(bool UseCS)
Return the maximum of all known function counts.
Definition: InstrProfReader.h:544
llvm::RawInstrProf::Header
Definition: InstrProf.h:1142
Endian.h
llvm::InstrProfReader::begin
InstrProfIterator begin()
Iterator over profile data.
Definition: InstrProfReader.h:91
llvm::handleAllErrors
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
Definition: Error.h:966
llvm::support::big
@ big
Definition: Endian.h:27
llvm::InstrProfIterator::operator==
bool operator==(const InstrProfIterator &RHS) const
Definition: InstrProfReader.h:61
llvm::InstrProfReader
Base class and interface for reading profiling data of any known instrprof format.
Definition: InstrProfReader.h:73
llvm::sampleprof::Base
@ Base
Definition: Discriminator.h:58
llvm::InstrProfIterator::InstrProfIterator
InstrProfIterator()=default
llvm::InstrProfReader::error
Error error(instrprof_error Err, const std::string &ErrMsg="")
Set the current error and return same.
Definition: InstrProfReader.h:122
llvm::RawInstrProfReader::useDebugInfoCorrelate
bool useDebugInfoCorrelate() const override
Return true if we must provide debug info to create PGO profiles.
Definition: InstrProfReader.h:275