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.

Synopsis

Declared in <llvm/IR/LLVMContext.h>

class LLVMContext;

Type Aliases

Name

Description

YieldCallbackTy

Defines the type of a yield callback.

Enums

Name

Description

Unnamed enum

Fixed metadata kind IDs that are always available in every context.

Unnamed enum

Known operand bundle tag IDs with fixed numeric values.

Member Functions

Name

Description

LLVMContext [constructor]

Constructors

~LLVMContext [destructor]

Destroy this context and release all associated global state.

operator= [deleted]

Copy assignment is deleted; LLVMContext is non‐copyable.

deleteGC

Remove the GC for a function.

diagnose

Report a message to the currently installed diagnostic handler.

disableDebugTypeODRUniquing

Disable ODR‐based uniquing of debug type identifiers in this context.

emitError

emitError overloads

enableDebugTypeODRUniquing

Enable ODR‐based uniquing of debug type identifiers in this context.

generateMachineFunctionNum

Get a unique number for a MachineFunction associated with F.

getDefaultTargetCPU

Get the current default target CPU (target‐cpu function attribute).

getDefaultTargetFeatures

Similar to {get,set}DefaultTargetCPU() but for default target‐features.

getDiagHandlerPtr

getDiagHandlerPtr ‐ Returns const raw pointer of DiagnosticHandler set by setDiagnosticHandler.

getDiagnosticContext

getDiagnosticContext ‐ Return the diagnostic context set by setDiagnosticContext.

getDiagnosticHandler

getDiagnosticHandler ‐ transfers ownership of DiagnosticHandler unique_ptr to caller.

getDiagnosticHandlerCallBack

getDiagnosticHandlerCallBack ‐ Return the diagnostic handler call back set by setDiagnosticHandlerCallBack.

getDiagnosticsHotnessRequested

Return if a code hotness metric should be included in optimization diagnostics.

getDiagnosticsHotnessThreshold

Return the minimum hotness value a diagnostic would need in order to be included in optimization diagnostics.

getDiagnosticsMisExpectTolerance

Return the tolerance used when diagnosing misexpect warnings.

getGC

Return the GC for a function.

getLLVMRemarkStreamer

getLLVMRemarkStreamer overloads

getMDKindID

Return a unique non‐zero ID for the specified metadata kind.

getMDKindNames

Populate Result with the names of custom metadata IDs in this context.

getMainRemarkStreamer

getMainRemarkStreamer overloads

getMisExpectWarningRequested

Return whether misexpect (branch‐weight mismatch) warnings are enabled.

getOperandBundleTagID

Map a bundle tag name to its integer ID.

getOperandBundleTags

Populate Result with the operand bundle tags registered in this context.

getOptPassGate

Access the object which can disable optional passes and individual optimizations at compile time.

getOrInsertBundleTag

Return the tag entry to use for an operand bundle named TagName.

getOrInsertSyncScopeID

Map a synchronization scope name to its synchronization scope ID.

getSyncScopeName

Return the name of a SyncScope::ID registered with LLVMContext, if any.

getSyncScopeNames

Populate SSNs with synchronization scope names registered in this context.

incNextDILocationAtomGroup

Key Instructions: get the next free atom group number and increment the global tracker.

isDiagnosticsHotnessThresholdSetFromPSI

Return if hotness threshold is requested from PSI.

isODRUniquingDebugTypes

Whether there is a string map for uniquing debug info identifiers across the context. Off by default.

setDefaultTargetCPU

Set the current default target CPU (target‐cpu function attribute).

setDefaultTargetFeatures

Set the default target‐features string for newly created functions.

setDiagnosticHandler

Install a DiagnosticHandler object for custom diagnostic handling.

setDiagnosticHandlerCallBack

Set a diagnostic handler callback invoked when the backend reports to the user.

setDiagnosticsHotnessRequested

Set if a code hotness metric should be included in optimization diagnostics.

setDiagnosticsHotnessThreshold

Set the minimum hotness value a diagnostic needs in order to be included in optimization diagnostics.

setDiagnosticsMisExpectTolerance

Set the tolerance used when diagnosing misexpect warnings.

setDiscardValueNames

Configure whether non‐GlobalValue value names are discarded.

setGC

Define the GC for a function.

setLLVMRemarkStreamer

Set the LLVM remark streamer used to serialize IR/MIR remark diagnostics.

setMainRemarkStreamer

Set the main remark streamer used by specialized remark streamers.

setMisExpectWarningRequested

Enable or disable misexpect (branch‐weight mismatch) warnings.

setOptPassGate

Set the object which can disable optional passes and individual optimizations at compile time.

setYieldCallback

Registers a yield callback with the given context.

shouldDiscardValueNames

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.

updateDILocationAtomGroupWaterline

Key Instructions: update the highest number atom group emitted for any function.

yield

Calls the yield callback (if applicable).

Static Member Functions

Name

Description

getDiagnosticMessagePrefix

Get the prefix that should be printed in front of a diagnostic of the given Severity

Data Members

Name

Description

pImpl

Pointer to the private implementation of this context.

Friends

Name

Description

llvm::Module

Top‐level container for LLVM IR objects in a translation unit.

Non-Member Functions

Name

Description

createDevelopmentModeAdvisorProvider

Create a development‐mode ML eviction advisor provider.

createDevelopmentModePriorityAdvisorProvider

Create a development‐mode ML priority advisor provider.

createReleaseModeAdvisorProvider

Create a release‐mode ML eviction advisor provider.

createReleaseModeModelRunner

Construct the appropriate MLModelRunner for release mode.

errorToErrorCodeAndEmitErrors

Convert Err to an error_code and emit diagnostics into Ctx.

expectedToErrorOrAndEmitErrors

Convert Val to ErrorOr, emitting diagnostics into Ctx on failure.

finalizeLLVMOptimizationRemarks

Finalize optimization remarks and deregister the RemarkStreamer from the Context.

getTensorSpecFromJSON

Construct a TensorSpec from a JSON dictionary describing the tensor.

makePostTransformationMetadata

Create a new LoopID after the loop has been transformed.

setupLLVMOptimizationRemarks

Set up optimization remarks that output directly to a raw_ostream.

setupLLVMOptimizationRemarks

Set up optimization remarks that output to a file.

unwrap

Opaque C API conversions for LLVMContext (see CBindingWrapping.h).

unwrap

Unwrap an array of opaque LLVMContextRef values.

wrap

Wrap an array of LLVMContext pointers for the C API.

wrap

Wrap a LLVMContext pointer as an opaque C API reference.

Intrinsic::getAttributes

Return the attributes for an intrinsic.

Intrinsic::getFnAttributes

Return the function attributes for an intrinsic.

Intrinsic::getType

Return the function type for an intrinsic.

lto::setupLLVMOptimizationRemarks

Setup optimization remarks.

Derived Classes

Name

Description

LTOLLVMContext

LLVMContext initialized from an LTO Config.

Created with MrDocs