Go to the documentation of this file.
19 #include <system_error>
32 std::unique_ptr<Module>
35 if (
isBitcode((
const unsigned char *)Buffer->getBufferStart(),
36 (
const unsigned char *)Buffer->getBufferEnd())) {
55 bool ShouldLazyLoadMetadata) {
58 if (std::error_code EC = FileOrErr.
getError()) {
60 "Could not open input file: " + EC.message());
65 ShouldLazyLoadMetadata);
91 std::unique_ptr<Module>
96 if (std::error_code EC = FileOrErr.
getError()) {
98 "Could not open input file: " + EC.message());
115 std::unique_ptr<MemoryBuffer> MB(
unwrap(MemBuf));
124 Diag.
print(
nullptr, os,
false);
127 *OutMessage = strdup(buf.c_str());
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.
std::unique_ptr< Module > parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err, LLVMContext &Context, DataLayoutCallbackTy DataLayoutCallback=[](StringRef) { return None;})
If the given MemoryBuffer holds a bitcode image, return a Module for it.
const char * getBufferStart() const
This is an optimization pass for GlobalISel generic memory operations.
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
const char TimeIRParsingGroupDescription[]
A raw_ostream that writes to an std::string.
bool TimePassesIsEnabled
If the user specifies the -time-passes argument on an LLVM tool command line then the value of this b...
const char TimeIRParsingGroupName[]
std::unique_ptr< Module > parseAssembly(MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context, SlotMapping *Slots=nullptr, DataLayoutCallbackTy DataLayoutCallback=[](StringRef) { return None;})
parseAssemblyFile and parseAssemblyString are wrappers around this function.
Tagged union holding either a T or a Error.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
std::error_code getError() const
std::unique_ptr< Module > getLazyIRFileModule(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, bool ShouldLazyLoadMetadata=false)
If the given file holds a bitcode image, return a Module for it which does lazy deserialization of fu...
const char TimeIRParsingDescription[]
Attribute unwrap(LLVMAttributeRef Attr)
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,...
Base class for error info classes.
virtual std::string message() const
Return the error message as a string.
An efficient, type-erasing, non-owning reference to a callable.
void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true) const
const char * getBufferEnd() const
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.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
LLVMAttributeRef wrap(Attribute Attr)
StringRef - Represent a constant reference to a string, i.e.
reference get()
Returns a reference to the stored T value.
LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef, LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM, char **OutMessage)
Read LLVM IR from a memory buffer and convert it into an in-memory Module object.
std::unique_ptr< Module > parseIRFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, DataLayoutCallbackTy DataLayoutCallback=[](StringRef) { return None;})
If the given file holds a bitcode image, return a Module for it.
Lightweight error class with error context and mandatory checking.
This class is basically a combination of TimeRegion and Timer.
Error takeError()
Take ownership of the stored error.
Represents either an error or a value T.
StringRef getBufferIdentifier() const
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
std::unique_ptr< Module > getLazyIRModule(std::unique_ptr< MemoryBuffer > Buffer, SMDiagnostic &Err, LLVMContext &Context, bool ShouldLazyLoadMetadata=false)
If the given MemoryBuffer holds a bitcode image, return a Module for it which does lazy deserializati...
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
const char TimeIRParsingName[]
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.