class LLVMContext
Declaration
class LLVMContext { /* full declaration omitted */ };
Description
This is an important class for using LLVM in a threaded context. It (opaquely) owns and manages the core "global" data of LLVM's core infrastructure, including the type and constant uniquing tables. LLVMContext itself provides no locking guarantees, so you should be careful to have one context per thread.
Declared at: llvm/include/llvm/IR/LLVMContext.h:68
Member Variables
- public llvm::LLVMContextImpl* const pImpl
Method Overview
- public LLVMContext(llvm::LLVMContext &)
- public LLVMContext()
- private void addModule(llvm::Module *)
- public void deleteGC(const llvm::Function & Fn)
- public void diagnose(const llvm::DiagnosticInfo & DI)
- public void disableDebugTypeODRUniquing()
- public void emitError(const llvm::Twine & ErrorStr)
- public void emitError(uint64_t LocCookie, const llvm::Twine & ErrorStr)
- public void emitError(const llvm::Instruction * I, const llvm::Twine & ErrorStr)
- public void enableDebugTypeODRUniquing()
- public const llvm::DiagnosticHandler * getDiagHandlerPtr() const
- public void * getDiagnosticContext() const
- public std::unique_ptr<DiagnosticHandler> getDiagnosticHandler()
- public DiagnosticHandler::DiagnosticHandlerTy getDiagnosticHandlerCallBack() const
- public static const char * getDiagnosticMessagePrefix(llvm::DiagnosticSeverity Severity)
- public bool getDiagnosticsHotnessRequested() const
- public uint64_t getDiagnosticsHotnessThreshold() const
- public uint64_t getDiagnosticsMisExpectTolerance() const
- public const std::string & getGC(const llvm::Function & Fn)
- public llvm::LLVMRemarkStreamer * getLLVMRemarkStreamer()
- public const llvm::LLVMRemarkStreamer * getLLVMRemarkStreamer() const
- public unsigned int getMDKindID(llvm::StringRef Name) const
- public void getMDKindNames(SmallVectorImpl<llvm::StringRef> & Result) const
- public remarks::RemarkStreamer * getMainRemarkStreamer()
- public const remarks::RemarkStreamer * getMainRemarkStreamer() const
- public bool getMisExpectWarningRequested() const
- public uint32_t getOperandBundleTagID(llvm::StringRef Tag) const
- public void getOperandBundleTags(SmallVectorImpl<llvm::StringRef> & Result) const
- public llvm::OptPassGate & getOptPassGate() const
- public StringMapEntry<uint32_t> * getOrInsertBundleTag(llvm::StringRef TagName) const
- public SyncScope::ID getOrInsertSyncScopeID(llvm::StringRef SSN)
- public void getSyncScopeNames(SmallVectorImpl<llvm::StringRef> & SSNs) const
- public llvm::Any & getTargetData() const
- public bool hasSetOpaquePointersValue() const
- public bool isDiagnosticsHotnessThresholdSetFromPSI() const
- public bool isODRUniquingDebugTypes() const
- private void removeModule(llvm::Module *)
- public void setDiagnosticHandler(std::unique_ptr<DiagnosticHandler> && DH, bool RespectFilters = false)
- public void setDiagnosticHandlerCallBack(DiagnosticHandler::DiagnosticHandlerTy DiagHandler, void * DiagContext = nullptr, bool RespectFilters = false)
- public void setDiagnosticsHotnessRequested(bool Requested)
- public void setDiagnosticsHotnessThreshold(Optional<uint64_t> Threshold)
- public void setDiagnosticsMisExpectTolerance(Optional<uint64_t> Tolerance)
- public void setDiscardValueNames(bool Discard)
- public void setGC(const llvm::Function & Fn, std::string GCName)
- public void setLLVMRemarkStreamer(std::unique_ptr<LLVMRemarkStreamer> RemarkStreamer)
- public void setMainRemarkStreamer(std::unique_ptr<remarks::RemarkStreamer> MainRemarkStreamer)
- public void setMisExpectWarningRequested(bool Requested)
- public void setOpaquePointers(bool Enable) const
- public void setOptPassGate(llvm::OptPassGate &)
- public void setYieldCallback(llvm::LLVMContext::YieldCallbackTy Callback, void * OpaqueHandle)
- public bool shouldDiscardValueNames() const
- public bool supportsTypedPointers() const
- public void yield()
- public ~LLVMContext()
Methods
¶LLVMContext(llvm::LLVMContext&)
LLVMContext(llvm::LLVMContext&)
Declared at: llvm/include/llvm/IR/LLVMContext.h:72
Parameters
¶LLVMContext()
LLVMContext()
Declared at: llvm/include/llvm/IR/LLVMContext.h:71
¶void addModule(llvm::Module*)
void addModule(llvm::Module*)
Description
addModule - Register a module as being instantiated in this context. If the context is deleted, the module will be deleted as well.
Declared at: llvm/include/llvm/IR/LLVMContext.h:336
Parameters
¶void deleteGC(const llvm::Function& Fn)
void deleteGC(const llvm::Function& Fn)
Description
Remove the GC for a function
Declared at: llvm/include/llvm/IR/LLVMContext.h:139
Parameters
- const llvm::Function& Fn
¶void diagnose(const llvm::DiagnosticInfo& DI)
void diagnose(const llvm::DiagnosticInfo& DI)
Description
Report a message to the currently installed diagnostic handler. This function returns, in particular in the case of error reporting (DI.Severity == \a DS_Error), so the caller should leave the compilation process in a self-consistent state, even though the generated code need not be correct. The diagnostic message will be implicitly prefixed with a severity keyword according to \p DI.getSeverity(), i.e., "error: " for \a DS_Error, "warning: " for \a DS_Warning, and "note: " for \a DS_Note.
Declared at: llvm/include/llvm/IR/LLVMContext.h:266
Parameters
- const llvm::DiagnosticInfo& DI
¶void disableDebugTypeODRUniquing()
void disableDebugTypeODRUniquing()
Declared at: llvm/include/llvm/IR/LLVMContext.h:155
¶void emitError(const llvm::Twine& ErrorStr)
void emitError(const llvm::Twine& ErrorStr)
Declared at: llvm/include/llvm/IR/LLVMContext.h:301
Parameters
- const llvm::Twine& ErrorStr
¶void emitError(uint64_t LocCookie,
const llvm::Twine& ErrorStr)
void emitError(uint64_t LocCookie,
const llvm::Twine& ErrorStr)
Description
emitError - Emit an error message to the currently installed error handler with optional location information. This function returns, so code should be prepared to drop the erroneous construct on the floor and "not crash". The generated code need not be correct. The error message will be implicitly prefixed with "error: " and should not end with a ".".
Declared at: llvm/include/llvm/IR/LLVMContext.h:299
Parameters
- uint64_t LocCookie
- const llvm::Twine& ErrorStr
¶void emitError(const llvm::Instruction* I,
const llvm::Twine& ErrorStr)
void emitError(const llvm::Instruction* I,
const llvm::Twine& ErrorStr)
Declared at: llvm/include/llvm/IR/LLVMContext.h:300
Parameters
- const llvm::Instruction* I
- const llvm::Twine& ErrorStr
¶void enableDebugTypeODRUniquing()
void enableDebugTypeODRUniquing()
Declared at: llvm/include/llvm/IR/LLVMContext.h:154
¶const llvm::DiagnosticHandler* getDiagHandlerPtr()
const
const llvm::DiagnosticHandler* getDiagHandlerPtr()
const
Description
getDiagHandlerPtr - Returns const raw pointer of DiagnosticHandler set by setDiagnosticHandler.
Declared at: llvm/include/llvm/IR/LLVMContext.h:193
¶void* getDiagnosticContext() const
void* getDiagnosticContext() const
Description
getDiagnosticContext - Return the diagnostic context set by setDiagnosticContext.
Declared at: llvm/include/llvm/IR/LLVMContext.h:189
¶std::unique_ptr<DiagnosticHandler>
getDiagnosticHandler()
std::unique_ptr<DiagnosticHandler>
getDiagnosticHandler()
Description
getDiagnosticHandler - transfers ownership of DiagnosticHandler unique_ptr to caller.
Declared at: llvm/include/llvm/IR/LLVMContext.h:197
¶DiagnosticHandler::DiagnosticHandlerTy
getDiagnosticHandlerCallBack() const
DiagnosticHandler::DiagnosticHandlerTy
getDiagnosticHandlerCallBack() const
Description
getDiagnosticHandlerCallBack - Return the diagnostic handler call back set by setDiagnosticHandlerCallBack.
Declared at: llvm/include/llvm/IR/LLVMContext.h:185
¶static const char* getDiagnosticMessagePrefix(
llvm::DiagnosticSeverity Severity)
static const char* getDiagnosticMessagePrefix(
llvm::DiagnosticSeverity Severity)
Description
Get the prefix that should be printed in front of a diagnostic of the given \p Severity
Declared at: llvm/include/llvm/IR/LLVMContext.h:254
Parameters
- llvm::DiagnosticSeverity Severity
¶bool getDiagnosticsHotnessRequested() const
bool getDiagnosticsHotnessRequested() const
Description
Return if a code hotness metric should be included in optimization diagnostics.
Declared at: llvm/include/llvm/IR/LLVMContext.h:201
¶uint64_t getDiagnosticsHotnessThreshold() const
uint64_t getDiagnosticsHotnessThreshold() const
Description
Return the minimum hotness value a diagnostic would need in order to be included in optimization diagnostics. Three possible return values: 0 - threshold is disabled. Everything will be printed out. positive int - threshold is set. UINT64_MAX - threshold is not yet set, and needs to be synced from profile summary. Note that in case of missing profile summary, threshold will be kept at "MAX", effectively suppresses all remarks output.
Declared at: llvm/include/llvm/IR/LLVMContext.h:221
¶uint64_t getDiagnosticsMisExpectTolerance() const
uint64_t getDiagnosticsMisExpectTolerance() const
Declared at: llvm/include/llvm/IR/LLVMContext.h:209
¶const std::string& getGC(const llvm::Function& Fn)
const std::string& getGC(const llvm::Function& Fn)
Description
Return the GC for a function
Declared at: llvm/include/llvm/IR/LLVMContext.h:136
Parameters
- const llvm::Function& Fn
¶llvm::LLVMRemarkStreamer* getLLVMRemarkStreamer()
llvm::LLVMRemarkStreamer* getLLVMRemarkStreamer()
Description
The "LLVM remark streamer" used by LLVM to serialize remark diagnostics comming from IR and MIR passes. If it does not exist, diagnostics are not saved in a file but only emitted via the diagnostic handler.
Declared at: llvm/include/llvm/IR/LLVMContext.h:247
¶const llvm::LLVMRemarkStreamer*
getLLVMRemarkStreamer() const
const llvm::LLVMRemarkStreamer*
getLLVMRemarkStreamer() const
Declared at: llvm/include/llvm/IR/LLVMContext.h:248
¶unsigned int getMDKindID(
llvm::StringRef Name) const
unsigned int getMDKindID(
llvm::StringRef Name) const
Description
getMDKindID - Return a unique non-zero ID for the specified metadata kind. This ID is uniqued across modules in the current LLVMContext.
Declared at: llvm/include/llvm/IR/LLVMContext.h:102
Parameters
- llvm::StringRef Name
¶void getMDKindNames(
SmallVectorImpl<llvm::StringRef>& Result)
const
void getMDKindNames(
SmallVectorImpl<llvm::StringRef>& Result)
const
Description
getMDKindNames - Populate client supplied SmallVector with the name for custom metadata IDs registered in this LLVMContext.
Declared at: llvm/include/llvm/IR/LLVMContext.h:106
Parameters
- SmallVectorImpl<llvm::StringRef>& Result
¶remarks::RemarkStreamer* getMainRemarkStreamer()
remarks::RemarkStreamer* getMainRemarkStreamer()
Description
The "main remark streamer" used by all the specialized remark streamers. This streamer keeps generic remark metadata in memory throughout the life of the LLVMContext. This metadata may be emitted in a section in object files depending on the format requirements. All specialized remark streamers should convert remarks to llvm::remarks::Remark and emit them through this streamer.
Declared at: llvm/include/llvm/IR/LLVMContext.h:237
¶const remarks::RemarkStreamer*
getMainRemarkStreamer() const
const remarks::RemarkStreamer*
getMainRemarkStreamer() const
Declared at: llvm/include/llvm/IR/LLVMContext.h:238
¶bool getMisExpectWarningRequested() const
bool getMisExpectWarningRequested() const
Declared at: llvm/include/llvm/IR/LLVMContext.h:206
¶uint32_t getOperandBundleTagID(
llvm::StringRef Tag) const
uint32_t getOperandBundleTagID(
llvm::StringRef Tag) const
Description
getOperandBundleTagID - Maps a bundle tag to an integer ID. Every bundle tag registered with an LLVMContext has an unique ID.
Declared at: llvm/include/llvm/IR/LLVMContext.h:120
Parameters
- llvm::StringRef Tag
¶void getOperandBundleTags(
SmallVectorImpl<llvm::StringRef>& Result)
const
void getOperandBundleTags(
SmallVectorImpl<llvm::StringRef>& Result)
const
Description
getOperandBundleTags - Populate client supplied SmallVector with the bundle tags registered in this LLVMContext. The bundle tags are ordered by increasing bundle IDs.
Declared at: llvm/include/llvm/IR/LLVMContext.h:112
Parameters
- SmallVectorImpl<llvm::StringRef>& Result
¶llvm::OptPassGate& getOptPassGate() const
llvm::OptPassGate& getOptPassGate() const
Description
Access the object which can disable optional passes and individual optimizations at compile time.
Declared at: llvm/include/llvm/IR/LLVMContext.h:305
¶StringMapEntry<uint32_t>* getOrInsertBundleTag(
llvm::StringRef TagName) const
StringMapEntry<uint32_t>* getOrInsertBundleTag(
llvm::StringRef TagName) const
Description
getOrInsertBundleTag - Returns the Tag to use for an operand bundle of name TagName.
Declared at: llvm/include/llvm/IR/LLVMContext.h:116
Parameters
- llvm::StringRef TagName
¶SyncScope::ID getOrInsertSyncScopeID(
llvm::StringRef SSN)
SyncScope::ID getOrInsertSyncScopeID(
llvm::StringRef SSN)
Description
getOrInsertSyncScopeID - Maps synchronization scope name to synchronization scope ID. Every synchronization scope registered with LLVMContext has unique ID except pre-defined ones.
Declared at: llvm/include/llvm/IR/LLVMContext.h:125
Parameters
- llvm::StringRef SSN
¶void getSyncScopeNames(
SmallVectorImpl<llvm::StringRef>& SSNs) const
void getSyncScopeNames(
SmallVectorImpl<llvm::StringRef>& SSNs) const
Description
getSyncScopeNames - Populates client supplied SmallVector with synchronization scope names registered with LLVMContext. Synchronization scope names are ordered by increasing synchronization scope IDs.
Declared at: llvm/include/llvm/IR/LLVMContext.h:130
Parameters
- SmallVectorImpl<llvm::StringRef>& SSNs
¶llvm::Any& getTargetData() const
llvm::Any& getTargetData() const
Description
Optionally target-spcific data can be attached to the context for lifetime management and bypassing layering restrictions.
Declared at: llvm/include/llvm/IR/LLVMContext.h:328
¶bool hasSetOpaquePointersValue() const
bool hasSetOpaquePointersValue() const
Description
Whether we've decided on using opaque pointers or typed pointers yet.
Declared at: llvm/include/llvm/IR/LLVMContext.h:315
¶bool isDiagnosticsHotnessThresholdSetFromPSI()
const
bool isDiagnosticsHotnessThresholdSetFromPSI()
const
Description
Return if hotness threshold is requested from PSI.
Declared at: llvm/include/llvm/IR/LLVMContext.h:228
¶bool isODRUniquingDebugTypes() const
bool isODRUniquingDebugTypes() const
Description
Whether there is a string map for uniquing debug info identifiers across the context. Off by default.
Declared at: llvm/include/llvm/IR/LLVMContext.h:153
¶void removeModule(llvm::Module*)
void removeModule(llvm::Module*)
Description
removeModule - Unregister a module from this context.
Declared at: llvm/include/llvm/IR/LLVMContext.h:339
Parameters
¶void setDiagnosticHandler(
std::unique_ptr<DiagnosticHandler>&& DH,
bool RespectFilters = false)
void setDiagnosticHandler(
std::unique_ptr<DiagnosticHandler>&& DH,
bool RespectFilters = false)
Description
setDiagnosticHandler - This method sets unique_ptr to object of DiagnosticHandler to provide custom diagnostic handling. The first argument is unique_ptr of object of type DiagnosticHandler or a derived of that. The second argument should be set to true if the handler only expects enabled diagnostics. Ownership of this pointer is moved to LLVMContextImpl.
Declared at: llvm/include/llvm/IR/LLVMContext.h:180
Parameters
- std::unique_ptr<DiagnosticHandler>&& DH
- bool RespectFilters = false
¶void setDiagnosticHandlerCallBack(
DiagnosticHandler::DiagnosticHandlerTy
DiagHandler,
void* DiagContext = nullptr,
bool RespectFilters = false)
void setDiagnosticHandlerCallBack(
DiagnosticHandler::DiagnosticHandlerTy
DiagHandler,
void* DiagContext = nullptr,
bool RespectFilters = false)
Description
setDiagnosticHandlerCallBack - This method sets a handler call back that is invoked when the backend needs to report anything to the user. The first argument is a function pointer and the second is a context pointer that gets passed into the DiagHandler. The third argument should be set to true if the handler only expects enabled diagnostics. LLVMContext doesn't take ownership or interpret either of these pointers.
Declared at: llvm/include/llvm/IR/LLVMContext.h:169
Parameters
- DiagnosticHandler::DiagnosticHandlerTy DiagHandler
- void* DiagContext = nullptr
- bool RespectFilters = false
¶void setDiagnosticsHotnessRequested(
bool Requested)
void setDiagnosticsHotnessRequested(
bool Requested)
Description
Set if a code hotness metric should be included in optimization diagnostics.
Declared at: llvm/include/llvm/IR/LLVMContext.h:204
Parameters
- bool Requested
¶void setDiagnosticsHotnessThreshold(
Optional<uint64_t> Threshold)
void setDiagnosticsHotnessThreshold(
Optional<uint64_t> Threshold)
Description
Set the minimum hotness value a diagnostic needs in order to be included in optimization diagnostics.
Declared at: llvm/include/llvm/IR/LLVMContext.h:225
Parameters
- Optional<uint64_t> Threshold
¶void setDiagnosticsMisExpectTolerance(
Optional<uint64_t> Tolerance)
void setDiagnosticsMisExpectTolerance(
Optional<uint64_t> Tolerance)
Declared at: llvm/include/llvm/IR/LLVMContext.h:208
Parameters
- Optional<uint64_t> Tolerance
¶void setDiscardValueNames(bool Discard)
void setDiscardValueNames(bool Discard)
Description
Set the Context runtime configuration to discard all value name (but GlobalValue). Clients can use this flag to save memory and runtime, especially in release mode.
Declared at: llvm/include/llvm/IR/LLVMContext.h:149
Parameters
- bool Discard
¶void setGC(const llvm::Function& Fn,
std::string GCName)
void setGC(const llvm::Function& Fn,
std::string GCName)
Description
Define the GC for a function
Declared at: llvm/include/llvm/IR/LLVMContext.h:133
Parameters
- const llvm::Function& Fn
- std::string GCName
¶void setLLVMRemarkStreamer(
std::unique_ptr<LLVMRemarkStreamer>
RemarkStreamer)
void setLLVMRemarkStreamer(
std::unique_ptr<LLVMRemarkStreamer>
RemarkStreamer)
Declared at: llvm/include/llvm/IR/LLVMContext.h:250
Parameters
- std::unique_ptr<LLVMRemarkStreamer> RemarkStreamer
¶void setMainRemarkStreamer(
std::unique_ptr<remarks::RemarkStreamer>
MainRemarkStreamer)
void setMainRemarkStreamer(
std::unique_ptr<remarks::RemarkStreamer>
MainRemarkStreamer)
Declared at: llvm/include/llvm/IR/LLVMContext.h:239
Parameters
- std::unique_ptr<remarks::RemarkStreamer> MainRemarkStreamer
¶void setMisExpectWarningRequested(bool Requested)
void setMisExpectWarningRequested(bool Requested)
Declared at: llvm/include/llvm/IR/LLVMContext.h:207
Parameters
- bool Requested
¶void setOpaquePointers(bool Enable) const
void setOpaquePointers(bool Enable) const
Description
Set whether opaque pointers are enabled. The method may be called multiple times, but only with the same value. Note that creating a pointer type or otherwise querying the opaque pointer mode performs an implicit set to the default value.
Declared at: llvm/include/llvm/IR/LLVMContext.h:321
Parameters
- bool Enable
¶void setOptPassGate(llvm::OptPassGate&)
void setOptPassGate(llvm::OptPassGate&)
Description
Set the object which can disable optional passes and individual optimizations at compile time. The lifetime of the object must be guaranteed to extend as long as the LLVMContext is used by compilation.
Declared at: llvm/include/llvm/IR/LLVMContext.h:312
Parameters
¶void setYieldCallback(
llvm::LLVMContext::YieldCallbackTy Callback,
void* OpaqueHandle)
void setYieldCallback(
llvm::LLVMContext::YieldCallbackTy Callback,
void* OpaqueHandle)
Description
Registers a yield callback with the given context. The yield callback function may be called by LLVM to transfer control back to the client that invoked the LLVM compilation. This can be used to yield control of the thread, or perform periodic work needed by the client. There is no guaranteed frequency at which callbacks must occur; in fact, the client is not guaranteed to ever receive this callback. It is at the sole discretion of LLVM to do so and only if it can guarantee that suspending the thread won't block any forward progress in other LLVM contexts in the same process. At a suspend point, the state of the current LLVM context is intentionally undefined. No assumptions about it can or should be made. Only LLVM context API calls that explicitly state that they can be used during a yield callback are allowed to be used. Any other API calls into the context are not supported until the yield callback function returns control to LLVM. Other LLVM contexts are unaffected by this restriction.
Declared at: llvm/include/llvm/IR/LLVMContext.h:285
Parameters
- llvm::LLVMContext::YieldCallbackTy Callback
- void* OpaqueHandle
¶bool shouldDiscardValueNames() const
bool shouldDiscardValueNames() const
Description
Return true if the Context runtime configuration is set to discard all value names. When true, only GlobalValue names will be available in the IR.
Declared at: llvm/include/llvm/IR/LLVMContext.h:144
¶bool supportsTypedPointers() const
bool supportsTypedPointers() const
Description
Whether typed pointers are supported. If false, all pointers are opaque.
Declared at: llvm/include/llvm/IR/LLVMContext.h:324
¶void yield()
void yield()
Description
Calls the yield callback (if applicable). This transfers control of the current thread back to the client, which may suspend the current thread. Only call this method when LLVM doesn't hold any global mutex or cannot block the execution in another LLVM context.
Declared at: llvm/include/llvm/IR/LLVMContext.h:292
¶~LLVMContext()
~LLVMContext()
Declared at: llvm/include/llvm/IR/LLVMContext.h:74