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

Methods

LLVMContext(llvm::LLVMContext&)

Declared at: llvm/include/llvm/IR/LLVMContext.h:72

Parameters

llvm::LLVMContext&

LLVMContext()

Declared at: llvm/include/llvm/IR/LLVMContext.h:71

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

llvm::Module*

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)

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()

Declared at: llvm/include/llvm/IR/LLVMContext.h:155

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)

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)

Declared at: llvm/include/llvm/IR/LLVMContext.h:300

Parameters

const llvm::Instruction* I
const llvm::Twine& ErrorStr

void enableDebugTypeODRUniquing()

Declared at: llvm/include/llvm/IR/LLVMContext.h:154

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

Description

getDiagnosticContext - Return the diagnostic context set by setDiagnosticContext.

Declared at: llvm/include/llvm/IR/LLVMContext.h:189

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

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)

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

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

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

Declared at: llvm/include/llvm/IR/LLVMContext.h:209

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()

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

Declared at: llvm/include/llvm/IR/LLVMContext.h:248

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

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()

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

Declared at: llvm/include/llvm/IR/LLVMContext.h:238

bool getMisExpectWarningRequested() const

Declared at: llvm/include/llvm/IR/LLVMContext.h:206

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

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

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

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)

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

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

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

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

Description

Return if hotness threshold is requested from PSI.

Declared at: llvm/include/llvm/IR/LLVMContext.h:228

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*)

Description

removeModule - Unregister a module from this context.

Declared at: llvm/include/llvm/IR/LLVMContext.h:339

Parameters

llvm::Module*

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)

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)

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)

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)

Declared at: llvm/include/llvm/IR/LLVMContext.h:208

Parameters

Optional<uint64_t> Tolerance

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)

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)

Declared at: llvm/include/llvm/IR/LLVMContext.h:250

Parameters

std::unique_ptr<LLVMRemarkStreamer> RemarkStreamer

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)

Declared at: llvm/include/llvm/IR/LLVMContext.h:207

Parameters

bool Requested

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&)

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

llvm::OptPassGate&

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

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

Description

Whether typed pointers are supported. If false, all pointers are opaque.

Declared at: llvm/include/llvm/IR/LLVMContext.h:324

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()

Declared at: llvm/include/llvm/IR/LLVMContext.h:74