Go to the documentation of this file.
13 #ifndef LLVM_BITCODE_BITCODEREADER_H
14 #define LLVM_BITCODE_BITCODEREADER_H
26 #include <system_error>
33 class ModuleSummaryIndex;
51 struct BitcodeFileContents;
77 : Buffer(Buffer), ModuleIdentifier(ModuleIdentifier),
78 IdentificationBit(IdentificationBit), ModuleBit(ModuleBit) {}
86 bool ShouldLazyLoadMetadata,
bool IsImporting,
91 return StringRef((
const char *)Buffer.begin(), Buffer.size());
103 bool ShouldLazyLoadMetadata,
116 Expected<std::unique_ptr<ModuleSummaryIndex>>
getSummary();
120 Error
readSummary(ModuleSummaryIndex &CombinedIndex, StringRef ModulePath,
125 std::vector<BitcodeModule>
Mods;
146 bool ShouldLazyLoadMetadata =
false,
147 bool IsImporting =
false);
155 bool ShouldLazyLoadMetadata =
false,
bool IsImporting =
false);
182 Expected<std::unique_ptr<ModuleSummaryIndex>>
187 ModuleSummaryIndex &CombinedIndex,
194 Expected<std::unique_ptr<ModuleSummaryIndex>>
196 bool IgnoreEmptyThinLTOIndexFile =
false);
201 const unsigned char *BufEnd) {
204 return BufPtr != BufEnd &&
214 const unsigned char *BufEnd) {
217 return BufPtr != BufEnd &&
227 const unsigned char *BufEnd) {
249 const unsigned char *&BufEnd,
250 bool VerifyBufferSize) {
260 if (VerifyBufferSize && BitcodeOffsetEnd >
uint64_t(BufEnd-BufPtr))
263 BufEnd = BufPtr+Size;
267 APInt
readWideAPInt(ArrayRef<uint64_t> Vals,
unsigned TypeBits);
283 #endif // LLVM_BITCODE_BITCODEREADER_H
Expected< std::unique_ptr< Module > > getOwningLazyBitcodeModule(std::unique_ptr< MemoryBuffer > &&Buffer, LLVMContext &Context, bool ShouldLazyLoadMetadata=false, bool IsImporting=false)
Like getLazyBitcodeModule, except that the module takes ownership of the memory buffer if successful.
ErrorOr< T > expectedToErrorOrAndEmitErrors(LLVMContext &Ctx, Expected< T > Val)
Expected< std::unique_ptr< Module > > parseModule(LLVMContext &Context, DataLayoutCallbackTy DataLayoutCallback=[](StringRef) { return None;})
Read the entire bitcode module and return it.
This is an optimization pass for GlobalISel generic memory operations.
StringRef getBuffer() const
Error readSummary(ModuleSummaryIndex &CombinedIndex, StringRef ModulePath, uint64_t ModuleId)
Parse the specified bitcode buffer and merge its module summary index into CombinedIndex.
Expected< std::string > getBitcodeProducerString(MemoryBufferRef Buffer)
Read the header of the specified bitcode buffer and extract just the producer string information.
bool SkipBitcodeWrapperHeader(const unsigned char *&BufPtr, const unsigned char *&BufEnd, bool VerifyBufferSize)
SkipBitcodeWrapperHeader - Some systems wrap bc files with a special header for padding or other reas...
APInt readWideAPInt(ArrayRef< uint64_t > Vals, unsigned TypeBits)
Tagged union holding either a T or a Error.
Expected< std::unique_ptr< ModuleSummaryIndex > > getModuleSummaryIndex(MemoryBufferRef Buffer)
Parse the specified bitcode buffer, returning the module summary index.
StringRef getModuleIdentifier() const
Basic information extracted from a bitcode module to be used for LTO.
Error readModuleSummaryIndex(MemoryBufferRef Buffer, ModuleSummaryIndex &CombinedIndex, uint64_t ModuleId)
Parse the specified bitcode buffer and merge the index into CombinedIndex.
Expected< BitcodeFileContents > getBitcodeFileContents(MemoryBufferRef Buffer)
Returns the contents of a bitcode file.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Expected< BitcodeLTOInfo > getLTOInfo()
Returns information about the module to be used for LTO: whether to compile with ThinLTO,...
bool isRawBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd)
isRawBitcode - Return true if the given bytes are the magic bytes for raw LLVM IR bitcode (without a ...
bool isBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd)
isBitcode - Return true if the given bytes are the magic bytes for LLVM IR bitcode,...
std::error_code errorToErrorCodeAndEmitErrors(LLVMContext &Ctx, Error Err)
An efficient, type-erasing, non-owning reference to a callable.
friend Expected< BitcodeFileContents > getBitcodeFileContents(MemoryBufferRef Buffer)
Returns the contents of a bitcode file.
Expected< std::unique_ptr< Module > > parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context, DataLayoutCallbackTy DataLayoutCallback=[](StringRef) { return None;})
Read the specified bitcode file, returning the module.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
This is an important class for using LLVM in a threaded context.
const std::error_category & BitcodeErrorCategory()
Expected< std::unique_ptr< ModuleSummaryIndex > > getModuleSummaryIndexForFile(StringRef Path, bool IgnoreEmptyThinLTOIndexFile=false)
Parse the module summary index out of an IR file and return the module summary index object if found,...
std::vector< BitcodeModule > Mods
Expected< std::unique_ptr< ModuleSummaryIndex > > getSummary()
Parse the specified bitcode buffer, returning the module summary index.
StringRef - Represent a constant reference to a string, i.e.
Expected< std::string > getBitcodeTargetTriple(MemoryBufferRef Buffer)
Read the header of the specified bitcode buffer and extract just the triple information.
Machine Check Debug Module
std::error_code make_error_code(BitcodeError E)
Expected< std::unique_ptr< Module > > getLazyModule(LLVMContext &Context, bool ShouldLazyLoadMetadata, bool IsImporting)
Read the bitcode module and prepare for lazy deserialization of function bodies.
bool isBitcodeWrapper(const unsigned char *BufPtr, const unsigned char *BufEnd)
isBitcodeWrapper - Return true if the given bytes are the magic bytes for an LLVM IR bitcode wrapper.
StringRef getStrtab() const
StringRef StrtabForSymtab
Error takeError()
Take ownership of the stored error.
uint32_t read32le(const void *P)
Represents either an error or a value T.
Expected< BitcodeLTOInfo > getBitcodeLTOInfo(MemoryBufferRef Buffer)
Returns LTO information for the specified bitcode file.
Expected< std::vector< BitcodeModule > > getBitcodeModuleList(MemoryBufferRef Buffer)
Returns a list of modules in the specified bitcode buffer.
Represents a module in a bitcode file.
Expected< std::unique_ptr< Module > > getLazyBitcodeModule(MemoryBufferRef Buffer, LLVMContext &Context, bool ShouldLazyLoadMetadata=false, bool IsImporting=false)
Read the header of the specified bitcode buffer and prepare for lazy deserialization of function bodi...
static ManagedStatic< _object_error_category > error_category
Expected< bool > isBitcodeContainingObjCCategory(MemoryBufferRef Buffer)
Return true if Buffer contains a bitcode file with ObjC code (category or class) in it.
llvm::function_ref< Optional< std::string >StringRef)> DataLayoutCallbackTy