LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::CodeGenDataReader Class Referenceabstract

#include "llvm/CGData/CodeGenDataReader.h"

Inheritance diagram for llvm::CodeGenDataReader:
Inheritance graph
[legend]

Public Member Functions

 CodeGenDataReader ()=default
 
virtual ~CodeGenDataReader ()=default
 
virtual Error read ()=0
 Read the header. Required before reading first record.
 
virtual uint32_t getVersion () const =0
 Return the codegen data version.
 
virtual CGDataKind getDataKind () const =0
 Return the codegen data kind.
 
virtual bool hasOutlinedHashTree () const =0
 Return true if the data has an outlined hash tree.
 
virtual bool hasStableFunctionMap () const =0
 Return true if the data has a stable function map.
 
std::unique_ptr< OutlinedHashTreereleaseOutlinedHashTree ()
 Return the outlined hash tree that is released from the reader.
 
std::unique_ptr< StableFunctionMapreleaseStableFunctionMap ()
 

Static Public Member Functions

static Expected< std::unique_ptr< CodeGenDataReader > > create (const Twine &Path, vfs::FileSystem &FS)
 Factory method to create an appropriately typed reader for the given codegen data file path and file system.
 
static Expected< std::unique_ptr< CodeGenDataReader > > create (std::unique_ptr< MemoryBuffer > Buffer)
 Factory method to create an appropriately typed reader for the given memory buffer.
 
static Error mergeFromObjectFile (const object::ObjectFile *Obj, OutlinedHashTreeRecord &GlobalOutlineRecord, StableFunctionMapRecord &GlobalFunctionMapRecord, stable_hash *CombinedHash=nullptr)
 Extract the cgdata embedded in sections from the given object file and merge them into the GlobalOutlineRecord.
 

Protected Member Functions

Error error (cgdata_error Err, const std::string &ErrMsg="")
 Set the current error and return same.
 
Error error (Error &&E)
 
Error success ()
 Clear the current error and return a successful one.
 

Protected Attributes

OutlinedHashTreeRecord HashTreeRecord
 The outlined hash tree that has been read.
 
StableFunctionMapRecord FunctionMapRecord
 The stable function map that has been read. When it's released by.
 

Detailed Description

Definition at line 24 of file CodeGenDataReader.h.

Constructor & Destructor Documentation

◆ CodeGenDataReader()

llvm::CodeGenDataReader::CodeGenDataReader ( )
default

◆ ~CodeGenDataReader()

virtual llvm::CodeGenDataReader::~CodeGenDataReader ( )
virtualdefault

Member Function Documentation

◆ create() [1/2]

Expected< std::unique_ptr< CodeGenDataReader > > llvm::CodeGenDataReader::create ( const Twine Path,
vfs::FileSystem FS 
)
static

Factory method to create an appropriately typed reader for the given codegen data file path and file system.

Definition at line 116 of file CodeGenDataReader.cpp.

References create(), and llvm::setupMemoryBuffer().

Referenced by create(), and llvm::CodeGenData::getInstance().

◆ create() [2/2]

Expected< std::unique_ptr< CodeGenDataReader > > llvm::CodeGenDataReader::create ( std::unique_ptr< MemoryBuffer Buffer)
static

Factory method to create an appropriately typed reader for the given memory buffer.

Definition at line 125 of file CodeGenDataReader.cpp.

References llvm::empty_cgdata, llvm::IndexedCodeGenDataReader::hasFormat(), llvm::TextCodeGenDataReader::hasFormat(), and llvm::malformed.

◆ error() [1/2]

Error llvm::CodeGenDataReader::error ( cgdata_error  Err,
const std::string &  ErrMsg = "" 
)
inlineprotected

Set the current error and return same.

Definition at line 81 of file CodeGenDataReader.h.

References llvm::success, and llvm::Error::success().

◆ error() [2/2]

Error llvm::CodeGenDataReader::error ( Error &&  E)
inlineprotected

◆ getDataKind()

virtual CGDataKind llvm::CodeGenDataReader::getDataKind ( ) const
pure virtual

Return the codegen data kind.

Implemented in llvm::IndexedCodeGenDataReader, and llvm::TextCodeGenDataReader.

◆ getVersion()

virtual uint32_t llvm::CodeGenDataReader::getVersion ( ) const
pure virtual

Return the codegen data version.

Implemented in llvm::IndexedCodeGenDataReader, and llvm::TextCodeGenDataReader.

◆ hasOutlinedHashTree()

virtual bool llvm::CodeGenDataReader::hasOutlinedHashTree ( ) const
pure virtual

Return true if the data has an outlined hash tree.

Implemented in llvm::IndexedCodeGenDataReader, and llvm::TextCodeGenDataReader.

◆ hasStableFunctionMap()

virtual bool llvm::CodeGenDataReader::hasStableFunctionMap ( ) const
pure virtual

Return true if the data has a stable function map.

Implemented in llvm::IndexedCodeGenDataReader, and llvm::TextCodeGenDataReader.

◆ mergeFromObjectFile()

Error llvm::CodeGenDataReader::mergeFromObjectFile ( const object::ObjectFile Obj,
OutlinedHashTreeRecord GlobalOutlineRecord,
StableFunctionMapRecord GlobalFunctionMapRecord,
stable_hash CombinedHash = nullptr 
)
static

Extract the cgdata embedded in sections from the given object file and merge them into the GlobalOutlineRecord.

This is a static helper that is used by llvm-cgdata --merge or ThinLTO's two-codegen rounds. Optionally, CombinedHash can be used to compuate the combined hash of the merged data.

Definition at line 33 of file CodeGenDataReader.cpp.

References llvm::Data, llvm::OutlinedHashTreeRecord::deserialize(), llvm::StableFunctionMapRecord::deserialize(), llvm::getCodeGenDataSectionName(), llvm::object::ObjectFile::makeTriple(), llvm::OutlinedHashTreeRecord::merge(), llvm::StableFunctionMapRecord::merge(), Name, llvm::object::ObjectFile::sections(), llvm::stable_hash_combine(), llvm::Error::success(), llvm::Expected< T >::takeError(), and llvm::xxh3_64bits().

Referenced by llvm::cgdata::mergeCodeGenData().

◆ read()

virtual Error llvm::CodeGenDataReader::read ( )
pure virtual

Read the header. Required before reading first record.

Implemented in llvm::IndexedCodeGenDataReader, and llvm::TextCodeGenDataReader.

◆ releaseOutlinedHashTree()

std::unique_ptr< OutlinedHashTree > llvm::CodeGenDataReader::releaseOutlinedHashTree ( )
inline

Return the outlined hash tree that is released from the reader.

Definition at line 43 of file CodeGenDataReader.h.

References llvm::OutlinedHashTreeRecord::HashTree, and HashTreeRecord.

◆ releaseStableFunctionMap()

std::unique_ptr< StableFunctionMap > llvm::CodeGenDataReader::releaseStableFunctionMap ( )
inline

◆ success()

Error llvm::CodeGenDataReader::success ( )
inlineprotected

Clear the current error and return a successful one.

Definition at line 98 of file CodeGenDataReader.h.

References error, and llvm::success.

Referenced by llvm::IndexedCodeGenDataReader::read().

Member Data Documentation

◆ FunctionMapRecord

StableFunctionMapRecord llvm::CodeGenDataReader::FunctionMapRecord
protected

The stable function map that has been read. When it's released by.

Definition at line 78 of file CodeGenDataReader.h.

Referenced by llvm::IndexedCodeGenDataReader::read(), llvm::TextCodeGenDataReader::read(), and releaseStableFunctionMap().

◆ HashTreeRecord

OutlinedHashTreeRecord llvm::CodeGenDataReader::HashTreeRecord
protected

The outlined hash tree that has been read.

When it's released by releaseOutlinedHashTree(), it's no longer valid.

Definition at line 74 of file CodeGenDataReader.h.

Referenced by llvm::IndexedCodeGenDataReader::read(), llvm::TextCodeGenDataReader::read(), and releaseOutlinedHashTree().


The documentation for this class was generated from the following files: