LLVM 20.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)
 Create a BitcodeWriter that writes to Buffer.
 
 BitcodeWriter (raw_ostream &FS)
 
 ~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, const GVSummaryPtrSet *DecSummaries)
 

Detailed Description

Definition at line 32 of file BitcodeWriter.h.

Constructor & Destructor Documentation

◆ BitcodeWriter() [1/2]

BitcodeWriter::BitcodeWriter ( SmallVectorImpl< char > &  Buffer)

Create a BitcodeWriter that writes to Buffer.

Definition at line 5008 of file BitcodeWriter.cpp.

References writeBitcodeHeader().

◆ BitcodeWriter() [2/2]

BitcodeWriter::BitcodeWriter ( raw_ostream FS)

Definition at line 5013 of file BitcodeWriter.cpp.

References writeBitcodeHeader().

◆ ~BitcodeWriter()

BitcodeWriter::~BitcodeWriter ( )

Definition at line 5018 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 5079 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,
const GVSummaryPtrSet DecSummaries 
)

Definition at line 5103 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 5084 of file BitcodeWriter.cpp.

References assert().

Referenced by llvm::orc::cloneToNewContext().

◆ 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 5065 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::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 5033 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(), 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 5301 of file BitcodeWriter.cpp.

References assert().

Referenced by llvm::writeThinLinkBitcodeToFile().


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