LLVM  8.0.1
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. More...
 
 ~BitcodeWriter ()
 
void writeSymtab ()
 Attempt to write a symbol table to the bitcode file. More...
 
void writeStrtab ()
 Write the bitcode file's string table. More...
 
void copyStrtab (StringRef Strtab)
 Copy the string table for another module into this bitcode file. More...
 
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. More...
 
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. More...
 
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)

Create a BitcodeWriter that writes to Buffer.

Definition at line 4183 of file BitcodeWriter.cpp.

References writeBitcodeHeader().

◆ ~BitcodeWriter()

BitcodeWriter::~BitcodeWriter ( )

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 4249 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 4273 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 4254 of file BitcodeWriter.cpp.

References assert(), and llvm::Module::isMaterialized().

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 4235 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 4203 of file BitcodeWriter.cpp.

References assert(), and llvm::Module::getModuleInlineAsm().

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 4466 of file BitcodeWriter.cpp.

References assert(), and llvm::Module::isMaterialized().

Referenced by llvm::WriteThinLinkBitcodeToFile().


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