LLVM  14.0.0git
Classes | Public Member Functions | Static Public Member Functions | List of all members
llvm::LTOModule Struct Reference

C++ class which implements the opaque lto_module_t type. More...

#include "llvm/LTO/legacy/LTOModule.h"

Public Member Functions

 ~LTOModule ()
 
bool isThinLTO ()
 Returns 'true' if the Module is produced for ThinLTO. More...
 
const ModulegetModule () const
 
ModulegetModule ()
 
std::unique_ptr< ModuletakeModule ()
 
const std::string & getTargetTriple ()
 Return the Module's target triple. More...
 
void setTargetTriple (StringRef Triple)
 Set the Module's target triple. More...
 
uint32_t getSymbolCount ()
 Get the number of symbols. More...
 
lto_symbol_attributes getSymbolAttributes (uint32_t index)
 Get the attributes for a symbol at the specified index. More...
 
StringRef getSymbolName (uint32_t index)
 Get the name of the symbol at the specified index. More...
 
const GlobalValuegetSymbolGV (uint32_t index)
 
StringRef getLinkerOpts ()
 
const std::vector< StringRef > & getAsmUndefinedRefs ()
 
Expected< uint32_tgetMachOCPUType () const
 
Expected< uint32_tgetMachOCPUSubType () const
 
bool hasCtorDtor () const
 Returns true if the module has either the @llvm.global_ctors or the @llvm.global_dtors symbol. More...
 

Static Public Member Functions

static bool isBitcodeFile (const void *mem, size_t length)
 Returns 'true' if the file or memory contents is LLVM bitcode. More...
 
static bool isBitcodeFile (StringRef path)
 
static bool isBitcodeForTarget (MemoryBuffer *memBuffer, StringRef triplePrefix)
 Returns 'true' if the memory buffer is LLVM bitcode for the specified triple. More...
 
static std::string getProducerString (MemoryBuffer *Buffer)
 Returns a string representing the producer identification stored in the bitcode, or "" if the bitcode does not contains any. More...
 
static std::unique_ptr< MemoryBuffermakeBuffer (const void *mem, size_t length, StringRef name="")
 Create a MemoryBuffer from a memory range with an optional name. More...
 
static ErrorOr< std::unique_ptr< LTOModule > > createFromFile (LLVMContext &Context, StringRef path, const TargetOptions &options)
 Create an LTOModule. More...
 
static ErrorOr< std::unique_ptr< LTOModule > > createFromOpenFile (LLVMContext &Context, int fd, StringRef path, size_t size, const TargetOptions &options)
 
static ErrorOr< std::unique_ptr< LTOModule > > createFromOpenFileSlice (LLVMContext &Context, int fd, StringRef path, size_t map_size, off_t offset, const TargetOptions &options)
 
static ErrorOr< std::unique_ptr< LTOModule > > createFromBuffer (LLVMContext &Context, const void *mem, size_t length, const TargetOptions &options, StringRef path="")
 
static ErrorOr< std::unique_ptr< LTOModule > > createInLocalContext (std::unique_ptr< LLVMContext > Context, const void *mem, size_t length, const TargetOptions &options, StringRef path)
 
static lto::InputFilecreateInputFile (const void *buffer, size_t buffer_size, const char *path, std::string &out_error)
 
static size_t getDependentLibraryCount (lto::InputFile *input)
 
static const char * getDependentLibrary (lto::InputFile *input, size_t index, size_t *size)
 

Detailed Description

C++ class which implements the opaque lto_module_t type.

Definition at line 38 of file LTOModule.h.

Constructor & Destructor Documentation

◆ ~LTOModule()

LTOModule::~LTOModule ( )

Definition at line 53 of file LTOModule.cpp.

Member Function Documentation

◆ createFromBuffer()

ErrorOr< std::unique_ptr< LTOModule > > LTOModule::createFromBuffer ( LLVMContext Context,
const void *  mem,
size_t  length,
const TargetOptions options,
StringRef  path = "" 
)
static

Definition at line 147 of file LTOModule.cpp.

References Context, llvm::Data, and options.

◆ createFromFile()

ErrorOr< std::unique_ptr< LTOModule > > LTOModule::createFromFile ( LLVMContext Context,
StringRef  path,
const TargetOptions options 
)
static

Create an LTOModule.

N.B. These methods take ownership of the buffer. The caller must have initialized the Targets, the TargetMCs, the AsmPrinters, and the AsmParsers by calling:

InitializeAllTargets(); InitializeAllTargetMCs(); InitializeAllAsmPrinters(); InitializeAllAsmParsers();

Definition at line 111 of file LTOModule.cpp.

References Context, llvm::LLVMContext::emitError(), llvm::ErrorOr< T >::get(), llvm::ErrorOr< T >::getError(), llvm::MemoryBuffer::getFile(), move, and options.

◆ createFromOpenFile()

ErrorOr< std::unique_ptr< LTOModule > > LTOModule::createFromOpenFile ( LLVMContext Context,
int  fd,
StringRef  path,
size_t  size,
const TargetOptions options 
)
static

Definition at line 125 of file LTOModule.cpp.

References Context, createFromOpenFileSlice(), options, and llvm::size().

◆ createFromOpenFileSlice()

ErrorOr< std::unique_ptr< LTOModule > > LTOModule::createFromOpenFileSlice ( LLVMContext Context,
int  fd,
StringRef  path,
size_t  map_size,
off_t  offset,
const TargetOptions options 
)
static

◆ createInLocalContext()

ErrorOr< std::unique_ptr< LTOModule > > LTOModule::createInLocalContext ( std::unique_ptr< LLVMContext Context,
const void *  mem,
size_t  length,
const TargetOptions options,
StringRef  path 
)
static

Definition at line 156 of file LTOModule.cpp.

References Context, llvm::Data, move, options, and llvm::MipsISD::Ret.

◆ createInputFile()

lto::InputFile * LTOModule::createInputFile ( const void *  buffer,
size_t  buffer_size,
const char *  path,
std::string &  out_error 
)
static

◆ getAsmUndefinedRefs()

const std::vector<StringRef>& llvm::LTOModule::getAsmUndefinedRefs ( )
inline

Definition at line 157 of file LTOModule.h.

◆ getDependentLibrary()

const char * LTOModule::getDependentLibrary ( lto::InputFile input,
size_t  index,
size_t *  size 
)
static

Definition at line 677 of file LTOModule.cpp.

References index, input, S, and llvm::size().

◆ getDependentLibraryCount()

size_t LTOModule::getDependentLibraryCount ( lto::InputFile input)
static

Definition at line 673 of file LTOModule.cpp.

References input.

◆ getLinkerOpts()

StringRef llvm::LTOModule::getLinkerOpts ( )
inline

Definition at line 155 of file LTOModule.h.

◆ getMachOCPUSubType()

Expected< uint32_t > LTOModule::getMachOCPUSubType ( ) const

Definition at line 688 of file LTOModule.cpp.

References llvm::MachO::getCPUSubType().

◆ getMachOCPUType()

Expected< uint32_t > LTOModule::getMachOCPUType ( ) const

Definition at line 684 of file LTOModule.cpp.

References llvm::MachO::getCPUType().

◆ getModule() [1/2]

Module& llvm::LTOModule::getModule ( )
inline

Definition at line 116 of file LTOModule.h.

References Mod.

◆ getModule() [2/2]

const Module& llvm::LTOModule::getModule ( ) const
inline

Definition at line 115 of file LTOModule.h.

References Mod.

Referenced by getTargetTriple(), and setTargetTriple().

◆ getProducerString()

std::string LTOModule::getProducerString ( MemoryBuffer Buffer)
static

Returns a string representing the producer identification stored in the bitcode, or "" if the bitcode does not contains any.

Definition at line 97 of file LTOModule.cpp.

References Context, llvm::errorToBool(), llvm::expectedToErrorOrAndEmitErrors(), llvm::getBitcodeProducerString(), llvm::MemoryBuffer::getMemBufferRef(), and llvm::Expected< T >::takeError().

◆ getSymbolAttributes()

lto_symbol_attributes llvm::LTOModule::getSymbolAttributes ( uint32_t  index)
inline

Get the attributes for a symbol at the specified index.

Definition at line 136 of file LTOModule.h.

References attributes, and index.

◆ getSymbolCount()

uint32_t llvm::LTOModule::getSymbolCount ( )
inline

Get the number of symbols.

Definition at line 131 of file LTOModule.h.

◆ getSymbolGV()

const GlobalValue* llvm::LTOModule::getSymbolGV ( uint32_t  index)
inline

Definition at line 149 of file LTOModule.h.

References index.

◆ getSymbolName()

StringRef llvm::LTOModule::getSymbolName ( uint32_t  index)
inline

Get the name of the symbol at the specified index.

Definition at line 143 of file LTOModule.h.

References index.

◆ getTargetTriple()

const std::string& llvm::LTOModule::getTargetTriple ( )
inline

Return the Module's target triple.

Definition at line 121 of file LTOModule.h.

References getModule(), and llvm::Module::getTargetTriple().

◆ hasCtorDtor()

bool LTOModule::hasCtorDtor ( ) const

Returns true if the module has either the @llvm.global_ctors or the @llvm.global_dtors symbol.

Otherwise returns false.

Definition at line 692 of file LTOModule.cpp.

References llvm::PointerUnion< PTs >::dyn_cast(), and llvm::ModuleSymbolTable::symbols().

◆ isBitcodeFile() [1/2]

bool LTOModule::isBitcodeFile ( const void *  mem,
size_t  length 
)
static

Returns 'true' if the file or memory contents is LLVM bitcode.

isBitcodeFile - Returns 'true' if the file (or memory contents) is LLVM bitcode.

Definition at line 57 of file LTOModule.cpp.

References llvm::errorToBool(), and llvm::Expected< T >::takeError().

◆ isBitcodeFile() [2/2]

bool LTOModule::isBitcodeFile ( StringRef  path)
static

◆ isBitcodeForTarget()

bool LTOModule::isBitcodeForTarget ( MemoryBuffer memBuffer,
StringRef  triplePrefix 
)
static

Returns 'true' if the memory buffer is LLVM bitcode for the specified triple.

Definition at line 83 of file LTOModule.cpp.

References Context, llvm::errorToBool(), llvm::expectedToErrorOrAndEmitErrors(), llvm::getBitcodeTargetTriple(), llvm::MemoryBuffer::getMemBufferRef(), llvm::StringRef::startswith(), and llvm::Expected< T >::takeError().

◆ isThinLTO()

bool LTOModule::isThinLTO ( )

Returns 'true' if the Module is produced for ThinLTO.

Definition at line 74 of file LTOModule.cpp.

References llvm::errs(), llvm::getBitcodeLTOInfo(), and llvm::logAllUnhandledErrors().

◆ makeBuffer()

std::unique_ptr< MemoryBuffer > LTOModule::makeBuffer ( const void *  mem,
size_t  length,
StringRef  name = "" 
)
static

Create a MemoryBuffer from a memory range with an optional name.

Definition at line 244 of file LTOModule.cpp.

References llvm::MemoryBuffer::getMemBuffer(), and name.

◆ setTargetTriple()

void llvm::LTOModule::setTargetTriple ( StringRef  Triple)
inline

Set the Module's target triple.

Definition at line 126 of file LTOModule.h.

References getModule(), and llvm::Module::setTargetTriple().

◆ takeModule()

std::unique_ptr<Module> llvm::LTOModule::takeModule ( )
inline

Definition at line 118 of file LTOModule.h.

References Mod, and move.


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