LLVM 19.0.0git
Public Member Functions | List of all members
llvm::BitcodeWriter Class Reference

#include "llvm/Bitcode/BitcodeWriter.h"

Public Member Functions

 BitcodeWriter (SmallVectorImpl< char > &Buffer, raw_fd_stream *FS=nullptr)
 Create a BitcodeWriter that writes to Buffer.
 
 ~BitcodeWriter ()
 
void writeSymtab ()
 Attempt to write a symbol table to the bitcode file.
 
void writeStrtab ()
 Write the bitcode file's string table.
 
void copyStrtab (StringRef Strtab)
 Copy the string table for another module into this bitcode file.
 
void writeModule (const Module &M, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false, ModuleHash *ModHash=nullptr)
 Write the specified module to the buffer specified at construction time.
 
void writeThinLinkBitcode (const Module &M, const ModuleSummaryIndex &Index, const ModuleHash &ModHash)
 Write the specified thin link bitcode file (i.e., the minimized bitcode file) to the buffer specified at construction time.
 
void writeIndex (const ModuleSummaryIndex *Index, const std::map< std::string, GVSummaryMapTy > *ModuleToSummariesForIndex)
 

Detailed Description

Definition at line 32 of file BitcodeWriter.h.

Constructor & Destructor Documentation

◆ BitcodeWriter()

BitcodeWriter::BitcodeWriter ( SmallVectorImpl< char > &  Buffer,
raw_fd_stream FS = nullptr 
)

Create a BitcodeWriter that writes to Buffer.

Definition at line 4947 of file BitcodeWriter.cpp.

References writeBitcodeHeader().

◆ ~BitcodeWriter()

BitcodeWriter::~BitcodeWriter ( )

Definition at line 4952 of file BitcodeWriter.cpp.

References assert().

Member Function Documentation

◆ copyStrtab()

void BitcodeWriter::copyStrtab ( StringRef  Strtab)

Copy the string table for another module into this bitcode file.

This should be called after copying the module itself into the bitcode file.

Definition at line 5013 of file BitcodeWriter.cpp.

References llvm::bitc::STRTAB_BLOB, and llvm::bitc::STRTAB_BLOCK_ID.

◆ writeIndex()

void BitcodeWriter::writeIndex ( const ModuleSummaryIndex Index,
const std::map< std::string, GVSummaryMapTy > *  ModuleToSummariesForIndex 
)

Definition at line 5037 of file BitcodeWriter.cpp.

Referenced by llvm::writeIndexToFile().

◆ writeModule()

void BitcodeWriter::writeModule ( const Module M,
bool  ShouldPreserveUseListOrder = false,
const ModuleSummaryIndex Index = nullptr,
bool  GenerateHash = false,
ModuleHash ModHash = nullptr 
)

Write the specified module to the buffer specified at construction time.

If ShouldPreserveUseListOrder, encode the use-list order for each Value in M. These will be reconstructed exactly when M is deserialized.

If Index is supplied, the bitcode will contain the summary index (currently for use in ThinLTO optimization).

GenerateHash enables hashing the Module and including the hash in the bitcode (currently for use in ThinLTO incremental build).

If ModHash is non-null, when GenerateHash is true, the resulting hash is written into ModHash. When GenerateHash is false, that value is used as the hash instead of computing from the generated bitcode. Can be used to produce the same module hash for a minimized bitcode used just for the thin link as in the regular full bitcode that will be used in the backend.

Definition at line 5018 of file BitcodeWriter.cpp.

References assert().

Referenced by llvm::orc::cloneToNewContext(), and llvm::WriteBitcodeToFile().

◆ writeStrtab()

void BitcodeWriter::writeStrtab ( )

Write the bitcode file's string table.

This must be called exactly once after all modules and the optional symbol table have been written.

Definition at line 4999 of file BitcodeWriter.cpp.

References assert(), llvm::StringTableBuilder::finalizeInOrder(), llvm::StringTableBuilder::getSize(), llvm::bitc::STRTAB_BLOB, llvm::bitc::STRTAB_BLOCK_ID, and llvm::StringTableBuilder::write().

Referenced by llvm::orc::cloneToNewContext(), llvm::WriteBitcodeToFile(), llvm::writeIndexToFile(), and llvm::writeThinLinkBitcodeToFile().

◆ writeSymtab()

void BitcodeWriter::writeSymtab ( )

Attempt to write a symbol table to the bitcode file.

This must be called at most once after all modules have been written.

A reader does not require a symbol table to interpret a bitcode file; the symbol table is needed only to improve link-time performance. So this function may decide not to write a symbol table. It may so decide if, for example, the target is unregistered or the IR is malformed.

Definition at line 4967 of file BitcodeWriter.cpp.

References assert(), llvm::irsymtab::build(), llvm::consumeError(), llvm::SmallVectorTemplateCommon< T, typename >::data(), llvm::TargetRegistry::lookupTarget(), llvm::SmallVectorBase< Size_T >::size(), llvm::bitc::SYMTAB_BLOB, and llvm::bitc::SYMTAB_BLOCK_ID.

Referenced by llvm::orc::cloneToNewContext(), llvm::WriteBitcodeToFile(), and llvm::writeThinLinkBitcodeToFile().

◆ writeThinLinkBitcode()

void BitcodeWriter::writeThinLinkBitcode ( const Module M,
const ModuleSummaryIndex Index,
const ModuleHash ModHash 
)

Write the specified thin link bitcode file (i.e., the minimized bitcode file) to the buffer specified at construction time.

The thin link bitcode file is used for thin link, and it only contains the necessary information for thin link.

ModHash is for use in ThinLTO incremental build, generated while the IR bitcode file writing.

Definition at line 5231 of file BitcodeWriter.cpp.

References assert().

Referenced by llvm::writeThinLinkBitcodeToFile().


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