LLVM: llvm::LLVMContext Class Reference (original) (raw)

This is an important class for using LLVM in a threaded context. More...

#include "[llvm/IR/LLVMContext.h](LLVMContext%5F8h%5Fsource.html)"

Public Types
enum : unsigned
enum : unsigned { OB_deopt = 0 , OB_funclet = 1 , OB_gc_transition = 2 , OB_cfguardtarget = 3 , OB_preallocated = 4 , OB_gc_live = 5 , OB_clang_arc_attachedcall = 6 , OB_ptrauth = 7 , OB_kcfi = 8 , OB_convergencectrl = 9 }
Known operand bundle tag IDs, which always have the same value. More...
using YieldCallbackTy = void(*)(LLVMContext *Context, void *OpaqueHandle)
Defines the type of a yield callback.
Public Member Functions
LLVMContext ()
LLVMContext (const LLVMContext &)=delete
LLVMContext & operator= (const LLVMContext &)=delete
~LLVMContext ()
unsigned getMDKindID (StringRef Name) const
getMDKindID - Return a unique non-zero ID for the specified metadata kind.
void getMDKindNames (SmallVectorImpl< StringRef > &Result) const
getMDKindNames - Populate client supplied SmallVector with the name for custom metadata IDs registered in this LLVMContext.
void getOperandBundleTags (SmallVectorImpl< StringRef > &Result) const
getOperandBundleTags - Populate client supplied SmallVector with the bundle tags registered in this LLVMContext.
StringMapEntry< uint32_t > * getOrInsertBundleTag (StringRef TagName) const
getOrInsertBundleTag - Returns the Tag to use for an operand bundle of name TagName.
uint32_t getOperandBundleTagID (StringRef Tag) const
getOperandBundleTagID - Maps a bundle tag to an integer ID.
SyncScope::ID getOrInsertSyncScopeID (StringRef SSN)
getOrInsertSyncScopeID - Maps synchronization scope name to synchronization scope ID.
void getSyncScopeNames (SmallVectorImpl< StringRef > &SSNs) const
getSyncScopeNames - Populates client supplied SmallVector with synchronization scope names registered with LLVMContext.
std::optional< StringRef > getSyncScopeName (SyncScope::ID Id) const
getSyncScopeName - Returns the name of a SyncScope::ID registered with LLVMContext, if any.
void setGC (const Function &Fn, std::string GCName)
Define the GC for a function.
const std::string & getGC (const Function &Fn)
Return the GC for a function.
void deleteGC (const Function &Fn)
Remove the GC for a function.
bool shouldDiscardValueNames () const
Return true if the Context runtime configuration is set to discard all value names.
void setDiscardValueNames (bool Discard)
Set the Context runtime configuration to discard all value name (but GlobalValue).
bool isODRUniquingDebugTypes () const
Whether there is a string map for uniquing debug info identifiers across the context.
void enableDebugTypeODRUniquing ()
void disableDebugTypeODRUniquing ()
unsigned generateMachineFunctionNum (Function &)
generateMachineFunctionNum - Get a unique number for MachineFunction that associated with the given Function.
void setDiagnosticHandlerCallBack (DiagnosticHandler::DiagnosticHandlerTy DiagHandler, void *DiagContext=nullptr, bool RespectFilters=false)
setDiagnosticHandlerCallBack - This method sets a handler call back that is invoked when the backend needs to report anything to the user.
void setDiagnosticHandler (std::unique_ptr< DiagnosticHandler > &&DH, bool RespectFilters=false)
setDiagnosticHandler - This method sets unique_ptr to object of DiagnosticHandler to provide custom diagnostic handling.
DiagnosticHandler::DiagnosticHandlerTy getDiagnosticHandlerCallBack () const
getDiagnosticHandlerCallBack - Return the diagnostic handler call back set by setDiagnosticHandlerCallBack.
void * getDiagnosticContext () const
getDiagnosticContext - Return the diagnostic context set by setDiagnosticContext.
const DiagnosticHandler * getDiagHandlerPtr () const
getDiagHandlerPtr - Returns const raw pointer of DiagnosticHandler set by setDiagnosticHandler.
std::unique_ptr< DiagnosticHandler > getDiagnosticHandler ()
getDiagnosticHandler - transfers ownership of DiagnosticHandler unique_ptr to caller.
bool getDiagnosticsHotnessRequested () const
Return if a code hotness metric should be included in optimization diagnostics.
void setDiagnosticsHotnessRequested (bool Requested)
Set if a code hotness metric should be included in optimization diagnostics.
bool getMisExpectWarningRequested () const
void setMisExpectWarningRequested (bool Requested)
void setDiagnosticsMisExpectTolerance (std::optional< uint32_t > Tolerance)
uint32_t getDiagnosticsMisExpectTolerance () const
uint64_t getDiagnosticsHotnessThreshold () const
Return the minimum hotness value a diagnostic would need in order to be included in optimization diagnostics.
void setDiagnosticsHotnessThreshold (std::optional< uint64_t > Threshold)
Set the minimum hotness value a diagnostic needs in order to be included in optimization diagnostics.
bool isDiagnosticsHotnessThresholdSetFromPSI () const
Return if hotness threshold is requested from PSI.
remarks::RemarkStreamer * getMainRemarkStreamer ()
The "main remark streamer" used by all the specialized remark streamers.
const remarks::RemarkStreamer * getMainRemarkStreamer () const
void setMainRemarkStreamer (std::unique_ptr< remarks::RemarkStreamer > MainRemarkStreamer)
LLVMRemarkStreamer * getLLVMRemarkStreamer ()
The "LLVM remark streamer" used by LLVM to serialize remark diagnostics comming from IR and MIR passes.
const LLVMRemarkStreamer * getLLVMRemarkStreamer () const
void setLLVMRemarkStreamer (std::unique_ptr< LLVMRemarkStreamer > RemarkStreamer)
void diagnose (const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
void setYieldCallback (YieldCallbackTy Callback, void *OpaqueHandle)
Registers a yield callback with the given context.
void yield ()
Calls the yield callback (if applicable).
void emitError (const Instruction *I, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location information.
void emitError (const Twine &ErrorStr)
OptPassGate & getOptPassGate () const
Access the object which can disable optional passes and individual optimizations at compile time.
void setOptPassGate (OptPassGate &)
Set the object which can disable optional passes and individual optimizations at compile time.
StringRef getDefaultTargetCPU ()
Get or set the current "default" target CPU (target-cpu function attribute).
void setDefaultTargetCPU (StringRef CPU)
StringRef getDefaultTargetFeatures ()
Similar to {get,set}DefaultTargetCPU() but for default target-features.
void setDefaultTargetFeatures (StringRef Features)

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.

Definition at line 67 of file LLVMContext.h.

YieldCallbackTy

anonymous enum

anonymous enum

Known operand bundle tag IDs, which always have the same value.

All operand bundle tags that LLVM has special knowledge of are listed here. Additionally, this scheme allows LLVM to efficiently check for specific operand bundle tags without comparing strings. Keep this in sync with LLVMContext::LLVMContext().

Enumerator
OB_deopt
OB_funclet
OB_gc_transition
OB_cfguardtarget
OB_preallocated
OB_gc_live
OB_clang_arc_attachedcall
OB_ptrauth
OB_kcfi
OB_convergencectrl

Definition at line 88 of file LLVMContext.h.

LLVMContext::LLVMContext ( )

LLVMContext() [2/2]

~LLVMContext()

LLVMContext::~LLVMContext ( )

deleteGC()

diagnose()

Report a message to the currently installed diagnostic handler.

This function returns, in particular in the case of error reporting (DI.Severity == 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 DI.getSeverity(), i.e., "error: " for DS_Error, "warning: " for DS_Warning, and "note: " for DS_Note.

Definition at line 245 of file LLVMContext.cpp.

References llvm::LLVMContextImpl::DiagHandler, llvm::DS_Error, llvm::errs(), getDiagnosticMessagePrefix(), getLLVMRemarkStreamer(), llvm::DiagnosticInfo::getSeverity(), isDiagnosticEnabled(), pImpl, llvm::DiagnosticInfo::print(), and llvm::LLVMContextImpl::RespectDiagnosticFilters.

Referenced by llvm::sampleprof::SampleProfileReaderItaniumRemapper::applyRemapping(), llvm::GCNSubtarget::checkSubtargetFeatures(), llvm::createMIRParser(), diagnoseInvalidFormatString(), diagnosePossiblyInvalidConstraint(), llvm::MachineModuleInfoWrapperPass::doInitialization(), llvm::OptimizationRemarkEmitter::emit(), llvm::MachineOptimizationRemarkEmitter::emit(), emitError(), llvm::MachineInstr::emitGenericError(), llvm::MachineInstr::emitInlineAsmError(), EmitInlineAsmStr(), emitNonHSAIntrinsicError(), llvm::RISCVFrameLowering::emitPrologue(), emitRemovedIntrinsicError(), emitUnsupportedError(), llvm::MIRParserImpl::error(), errorUnsupported(), fail(), llvm::RegAllocBase::getErrorAssignment(), InstrumentAllFunctions(), llvm::AMDGPULegalizerInfo::legalizeAddrSpaceCast(), llvm::AMDGPULegalizerInfo::legalizeDebugTrap(), llvm::AMDGPULegalizerInfo::legalizeGlobalValue(), llvm::RISCVTargetLowering::LowerCall(), llvm::AMDGPUTargetLowering::LowerDYNAMIC_STACKALLOC(), llvm::NVPTXTargetLowering::LowerDYNAMIC_STACKALLOC(), llvm::SITargetLowering::LowerFormalArguments(), llvm::AMDGPUTargetLowering::LowerGlobalAddress(), llvm::RISCVTargetLowering::LowerReturn(), llvm::NVPTXTargetLowering::LowerSTACKRESTORE(), llvm::NVPTXTargetLowering::LowerSTACKSAVE(), llvm::AMDGPUTargetLowering::lowerUnhandledCall(), llvm::sampleprof::SampleProfileReaderText::readImpl(), llvm::MIRParserImpl::reportDiagnostic(), llvm::sampleprof::SampleProfileReader::reportError(), llvm::KCFIPass::run(), llvm::MachineModuleAnalysis::run(), llvm::SelectionDAGISel::runOnMachineFunction(), selectExplicitSectionGlobal(), and verifyLoadedModule().

disableDebugTypeODRUniquing()

void LLVMContext::disableDebugTypeODRUniquing ( )

emitError() [1/2]

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 ".".

Definition at line 210 of file LLVMContext.cpp.

References assert(), diagnose(), and I.

Referenced by checkIntrinsicImmArg(), llvm::LTOModule::createFromFile(), llvm::LTOModule::createFromOpenFileSlice(), diagnosePossiblyInvalidConstraint(), emitErrorAndReplaceIntrinsicResults(), emitErrorMsg(), emitIntrinsicErrorMessage(), emitIntrinsicWithChainErrorMessage(), llvm::errorToErrorCodeAndEmitErrors(), getBBAddrMapFeature(), llvm::AMDGPU::getIntegerPairAttribute(), llvm::AMDGPU::getIntegerVecAttribute(), llvm::getTensorSpecFromJSON(), INITIALIZE_PASS(), llvm::InteractiveModelRunner::InteractiveModelRunner(), legalizeIntrinsicImmArg(), lowerVectorBitClearImm(), lowerVectorBitRevImm(), lowerVectorBitSetImm(), lowerVectorSplatImm(), parseBitcodeFileImpl(), llvm::LoongArchTargetLowering::ReplaceNodeResults(), llvm::ReplayInlineAdvisor::ReplayInlineAdvisor(), llvm::RAGreedy::selectOrSplit(), and llvm::TargetLowering::verifyReturnAddressArgumentIsConstant().

emitError() [2/2]

void LLVMContext::emitError ( const Twine & ErrorStr )

enableDebugTypeODRUniquing()

void LLVMContext::enableDebugTypeODRUniquing ( )

generateMachineFunctionNum()

getDefaultTargetCPU()

StringRef LLVMContext::getDefaultTargetCPU ( )

Get or set the current "default" target CPU (target-cpu function attribute).

The intent is that compiler frontends will set this to a value that reflects the attribute that a function would get "by default" without any specific function attributes, and compiler passes will attach the attribute to newly created functions that are not associated with a particular function, such as global initializers. Function::createWithDefaultAttr() will create functions with this attribute. This function should only be called by passes that run at compile time and not by the backend or LTO passes.

Definition at line 365 of file LLVMContext.cpp.

References llvm::LLVMContextImpl::DefaultTargetCPU, and pImpl.

getDefaultTargetFeatures()

StringRef LLVMContext::getDefaultTargetFeatures ( )

getDiagHandlerPtr()

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

Definition at line 357 of file LLVMContext.cpp.

References llvm::LLVMContextImpl::DiagHandler, and pImpl.

Referenced by llvm::OptimizationRemarkEmitter::allowExtraAnalysis(), llvm::MachineOptimizationRemarkEmitter::allowExtraAnalysis(), llvm::MachineOptimizationRemarkEmitter::emit(), llvm::OptimizationRemarkEmitter::enabled(), llvm::MachineOptimizationRemark::isEnabled(), llvm::MachineOptimizationRemarkMissed::isEnabled(), llvm::MachineOptimizationRemarkAnalysis::isEnabled(), llvm::OptimizationRemark::isEnabled(), llvm::OptimizationRemarkMissed::isEnabled(), and llvm::OptimizationRemarkAnalysis::isEnabled().

getDiagnosticContext()

void * LLVMContext::getDiagnosticContext ( ) const

getDiagnosticHandler()

getDiagnosticHandlerCallBack()

getDiagnosticMessagePrefix()

getDiagnosticsHotnessRequested()

bool LLVMContext::getDiagnosticsHotnessRequested ( ) const

getDiagnosticsHotnessThreshold()

uint64_t LLVMContext::getDiagnosticsHotnessThreshold ( ) const

getDiagnosticsMisExpectTolerance()

uint32_t LLVMContext::getDiagnosticsMisExpectTolerance ( ) const

getGC()

getLLVMRemarkStreamer() [1/2]

getLLVMRemarkStreamer() [2/2]

getMainRemarkStreamer() [1/2]

getMainRemarkStreamer() [2/2]

getMDKindID()

getMDKindNames()

getMisExpectWarningRequested()

bool LLVMContext::getMisExpectWarningRequested ( ) const

getOperandBundleTagID()

getOperandBundleTags()

getOptPassGate()

getOrInsertBundleTag()

getOrInsertSyncScopeID()

getSyncScopeName()

getSyncScopeNames()

isDiagnosticsHotnessThresholdSetFromPSI()

bool LLVMContext::isDiagnosticsHotnessThresholdSetFromPSI ( ) const

isODRUniquingDebugTypes()

bool LLVMContext::isODRUniquingDebugTypes ( ) const

operator=()

setDefaultTargetCPU()

void LLVMContext::setDefaultTargetCPU ( StringRef CPU )

setDefaultTargetFeatures()

void LLVMContext::setDefaultTargetFeatures ( StringRef Features )

setDiagnosticHandler()

void LLVMContext::setDiagnosticHandler ( std::unique_ptr< DiagnosticHandler > && DH,
bool RespectFilters = false
)

setDiagnosticHandlerCallBack()

setDiagnosticsHotnessRequested()

void LLVMContext::setDiagnosticsHotnessRequested ( bool Requested )

setDiagnosticsHotnessThreshold()

void LLVMContext::setDiagnosticsHotnessThreshold ( std::optional< uint64_t > Threshold )

setDiagnosticsMisExpectTolerance()

void LLVMContext::setDiagnosticsMisExpectTolerance ( std::optional< uint32_t > Tolerance )

setDiscardValueNames()

void LLVMContext::setDiscardValueNames ( bool Discard )

setGC()

void LLVMContext::setGC ( const Function & Fn,
std::string GCName
)

setLLVMRemarkStreamer()

void LLVMContext::setLLVMRemarkStreamer ( std::unique_ptr< LLVMRemarkStreamer > RemarkStreamer )

setMainRemarkStreamer()

setMisExpectWarningRequested()

void LLVMContext::setMisExpectWarningRequested ( bool Requested )

setOptPassGate()

setYieldCallback()

void LLVMContext::setYieldCallback ( YieldCallbackTy Callback,
void * OpaqueHandle
)

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.

Definition at line 195 of file LLVMContext.cpp.

References pImpl, llvm::LLVMContextImpl::YieldCallback, and llvm::LLVMContextImpl::YieldOpaqueHandle.

shouldDiscardValueNames()

bool LLVMContext::shouldDiscardValueNames ( ) const

yield()

void LLVMContext::yield ( )

Module

pImpl

Definition at line 69 of file LLVMContext.h.

Referenced by llvm::Value::addMetadata(), llvm::DICompositeType::buildODRType(), llvm::Value::clearMetadata(), deleteGC(), diagnose(), disableDebugTypeODRUniquing(), llvm::Module::dropTriviallyDeadConstantArrays(), enableDebugTypeODRUniquing(), llvm::Value::eraseMetadata(), llvm::Value::eraseMetadataIf(), generateMachineFunctionNum(), llvm::ConstantVector::get(), llvm::ConstantArray::get(), llvm::InlineAsm::get(), llvm::DSOLocalEquivalent::get(), llvm::NoCFIValue::get(), llvm::ConstantTokenNone::get(), llvm::DIArgList::get(), llvm::Attribute::get(), llvm::ConstantFP::get(), llvm::ConstantInt::get(), llvm::MetadataAsValue::get(), llvm::ConstantPointerNull::get(), llvm::ConstantTargetNone::get(), llvm::TypedPointerType::get(), llvm::UndefValue::get(), llvm::PoisonValue::get(), llvm::ConstantAggregateZero::get(), llvm::ConstantExpr::get(), llvm::ValueAsMetadata::get(), llvm::Instruction::getAAMetadata(), llvm::Value::getAllMetadata(), llvm::at::getAssignmentInsts(), getDefaultTargetCPU(), getDefaultTargetFeatures(), getDiagHandlerPtr(), getDiagnosticContext(), getDiagnosticHandler(), getDiagnosticHandlerCallBack(), getDiagnosticsHotnessRequested(), getDiagnosticsHotnessThreshold(), getDiagnosticsMisExpectTolerance(), llvm::ConstantExpr::getExtractElement(), llvm::ConstantInt::getFalse(), getFoldedCast(), getGC(), llvm::MetadataAsValue::getIfExists(), llvm::ConstantDataSequential::getImpl(), llvm::ConstantExpr::getInsertElement(), getLLVMRemarkStreamer(), getMainRemarkStreamer(), getMDKindID(), getMDKindNames(), llvm::Value::getMetadata(), llvm::Value::getMetadataImpl(), getMisExpectWarningRequested(), llvm::DICompositeType::getODRTypeIfExists(), getOperandBundleTagID(), getOperandBundleTags(), getOptPassGate(), getOrInsertBundleTag(), getOrInsertSyncScopeID(), llvm::GlobalValue::getPartition(), llvm::GlobalValue::getSanitizerMetadata(), llvm::ConstantExpr::getShuffleVector(), getSyncScopeName(), getSyncScopeNames(), llvm::ConstantInt::getTrue(), llvm::DIArgList::handleChangedOperand(), llvm::ValueAsMetadata::handleRAUW(), isDiagnosticsHotnessThresholdSetFromPSI(), isODRUniquingDebugTypes(), LLVMContext(), llvm::CallBase::populateBundleOperandInfos(), llvm::GlobalValue::removeSanitizerMetadata(), llvm::ReplaceableMetadataImpl::SalvageDebugInfo(), setDefaultTargetCPU(), setDefaultTargetFeatures(), setDiagnosticHandler(), setDiagnosticHandlerCallBack(), setDiagnosticsHotnessRequested(), setDiagnosticsHotnessThreshold(), setDiagnosticsMisExpectTolerance(), setDiscardValueNames(), setGC(), setLLVMRemarkStreamer(), setMainRemarkStreamer(), llvm::Value::setMetadata(), setMisExpectWarningRequested(), setOptPassGate(), llvm::GlobalValue::setPartition(), llvm::GlobalValue::setSanitizerMetadata(), llvm::GlobalObject::setSection(), setYieldCallback(), shouldDiscardValueNames(), llvm::MDNode::storeDistinctInContext(), yield(), ~LLVMContext(), and llvm::MetadataAsValue::~MetadataAsValue().


The documentation for this class was generated from the following files: