|
LLVM
3.7.0
|
This is an important class for using LLVM in a threaded context. More...
#include <LLVMContext.h>
Public Types | |
| enum | { MD_dbg = 0, MD_tbaa = 1, MD_prof = 2, MD_fpmath = 3, MD_range = 4, MD_tbaa_struct = 5, MD_invariant_load = 6, MD_alias_scope = 7, MD_noalias = 8, MD_nontemporal = 9, MD_mem_parallel_loop_access = 10, MD_nonnull = 11, MD_dereferenceable = 12, MD_dereferenceable_or_null = 13 } |
| typedef void(* | InlineAsmDiagHandlerTy )(const SMDiagnostic &, void *Context, unsigned LocCookie) |
| typedef void(* | DiagnosticHandlerTy )(const DiagnosticInfo &DI, void *Context) |
| Defines the type of a diagnostic handler. More... | |
| typedef void(* | YieldCallbackTy )(LLVMContext *Context, void *OpaqueHandle) |
| Defines the type of a yield callback. More... | |
Public Member Functions | |
| LLVMContext () | |
| ~LLVMContext () | |
| unsigned | getMDKindID (StringRef Name) const |
| getMDKindID - Return a unique non-zero ID for the specified metadata kind. More... | |
| void | getMDKindNames (SmallVectorImpl< StringRef > &Result) const |
| getMDKindNames - Populate client supplied SmallVector with the name for custom metadata IDs registered in this LLVMContext. More... | |
| void | setInlineAsmDiagnosticHandler (InlineAsmDiagHandlerTy DiagHandler, void *DiagContext=nullptr) |
| setInlineAsmDiagnosticHandler - This method sets a handler that is invoked when problems with inline asm are detected by the backend. More... | |
| InlineAsmDiagHandlerTy | getInlineAsmDiagnosticHandler () const |
| getInlineAsmDiagnosticHandler - Return the diagnostic handler set by setInlineAsmDiagnosticHandler. More... | |
| void * | getInlineAsmDiagnosticContext () const |
| getInlineAsmDiagnosticContext - Return the diagnostic context set by setInlineAsmDiagnosticHandler. More... | |
| void | setDiagnosticHandler (DiagnosticHandlerTy DiagHandler, void *DiagContext=nullptr, bool RespectFilters=false) |
| setDiagnosticHandler - This method sets a handler that is invoked when the backend needs to report anything to the user. More... | |
| DiagnosticHandlerTy | getDiagnosticHandler () const |
| getDiagnosticHandler - Return the diagnostic handler set by setDiagnosticHandler. More... | |
| void * | getDiagnosticContext () const |
| getDiagnosticContext - Return the diagnostic context set by setDiagnosticContext. More... | |
| void | diagnose (const DiagnosticInfo &DI) |
| Report a message to the currently installed diagnostic handler. More... | |
| void | setYieldCallback (YieldCallbackTy Callback, void *OpaqueHandle) |
| Registers a yield callback with the given context. More... | |
| void | yield () |
| Calls the yield callback (if applicable). More... | |
| void | emitError (unsigned LocCookie, const Twine &ErrorStr) |
| emitError - Emit an error message to the currently installed error handler with optional location information. More... | |
| void | emitError (const Instruction *I, const Twine &ErrorStr) |
| void | emitError (const Twine &ErrorStr) |
| template<typename ValT , typename Base , ValTBase::* Mem> | |
| ValT | getOption () const |
| Query for a debug option's value. More... | |
Public Attributes | |
| LLVMContextImpl *const | pImpl |
Friends | |
| class | Module |
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 41 of file LLVMContext.h.
| typedef void(* llvm::LLVMContext::DiagnosticHandlerTy)(const DiagnosticInfo &DI, void *Context) |
Defines the type of a diagnostic handler.
Definition at line 81 of file LLVMContext.h.
| typedef void(* llvm::LLVMContext::InlineAsmDiagHandlerTy)(const SMDiagnostic &, void *Context, unsigned LocCookie) |
Definition at line 75 of file LLVMContext.h.
| typedef void(* llvm::LLVMContext::YieldCallbackTy)(LLVMContext *Context, void *OpaqueHandle) |
Defines the type of a yield callback.
Definition at line 85 of file LLVMContext.h.
| anonymous enum |
Definition at line 49 of file LLVMContext.h.
| LLVMContext::LLVMContext | ( | ) |
Definition at line 34 of file LLVMContext.cpp.
References getMDKindID(), MD_alias_scope, MD_dbg, MD_dereferenceable, MD_dereferenceable_or_null, MD_fpmath, MD_invariant_load, MD_mem_parallel_loop_access, MD_noalias, MD_nonnull, MD_nontemporal, MD_prof, MD_range, MD_tbaa, and MD_tbaa_struct.
| LLVMContext::~LLVMContext | ( | ) |
Definition at line 108 of file LLVMContext.cpp.
References pImpl.
| void LLVMContext::diagnose | ( | const DiagnosticInfo & | DI | ) |
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 216 of file LLVMContext.cpp.
References llvm::LLVMContextImpl::DiagnosticContext, llvm::LLVMContextImpl::DiagnosticHandler, llvm::DS_Error, llvm::errs(), getDiagnosticMessagePrefix(), llvm::DiagnosticInfo::getSeverity(), isDiagnosticEnabled(), pImpl, llvm::DiagnosticInfo::print(), and llvm::LLVMContextImpl::RespectDiagnosticFilters.
Referenced by emitError(), llvm::emitLoopInterleaveWarning(), llvm::emitLoopVectorizeWarning(), llvm::emitOptimizationRemark(), llvm::emitOptimizationRemarkAnalysis(), llvm::emitOptimizationRemarkMissed(), llvm::MIRParserImpl::error(), getDiagHandler(), llvm::Linker::Linker(), llvm::AMDGPUTargetLowering::LowerCall(), llvm::AMDGPUTargetLowering::LowerGlobalAddress(), llvm::MIRParserImpl::reportDiagnostic(), llvm::sampleprof::SampleProfileReader::reportParseError(), and llvm::UpgradeDebugInfo().
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 236 of file LLVMContext.cpp.
References diagnose().
Referenced by diagnosePossiblyInvalidConstraint(), llvm::SIRegisterInfo::eliminateFrameIndex(), EmitGCCInlineAsmStr(), EmitMSInlineAsmStr(), llvm::SIInstrInfo::loadRegFromStackSlot(), llvm::AMDGPUMCInstLower::lower(), llvm::SIInstrInfo::storeRegToStackSlot(), and llvm::TargetLowering::verifyReturnAddressArgumentIsConstant().
| void LLVMContext::emitError | ( | const Instruction * | I, |
| const Twine & | ErrorStr | ||
| ) |
Definition at line 173 of file LLVMContext.cpp.
References diagnose().
Definition at line 169 of file LLVMContext.cpp.
References diagnose().
| void * LLVMContext::getDiagnosticContext | ( | ) | const |
getDiagnosticContext - Return the diagnostic context set by setDiagnosticContext.
Definition at line 154 of file LLVMContext.cpp.
References llvm::LLVMContextImpl::DiagnosticContext, and pImpl.
| LLVMContext::DiagnosticHandlerTy LLVMContext::getDiagnosticHandler | ( | ) | const |
getDiagnosticHandler - Return the diagnostic handler set by setDiagnosticHandler.
Definition at line 150 of file LLVMContext.cpp.
References llvm::LLVMContextImpl::DiagnosticHandler, and pImpl.
| void * LLVMContext::getInlineAsmDiagnosticContext | ( | ) | const |
getInlineAsmDiagnosticContext - Return the diagnostic context set by setInlineAsmDiagnosticHandler.
Definition at line 138 of file LLVMContext.cpp.
References llvm::LLVMContextImpl::InlineAsmDiagContext, and pImpl.
| LLVMContext::InlineAsmDiagHandlerTy LLVMContext::getInlineAsmDiagnosticHandler | ( | ) | const |
getInlineAsmDiagnosticHandler - Return the diagnostic handler set by setInlineAsmDiagnosticHandler.
Definition at line 132 of file LLVMContext.cpp.
References llvm::LLVMContextImpl::InlineAsmDiagHandler, and pImpl.
getMDKindID - Return a unique non-zero ID for the specified metadata kind.
Return a unique non-zero ID for the specified metadata kind.
This ID is uniqued across modules in the current LLVMContext.
Definition at line 245 of file LLVMContext.cpp.
References llvm::LLVMContextImpl::CustomMDKindNames, llvm::StringMap< ValueTy, AllocatorTy >::insert(), pImpl, and llvm::StringMapImpl::size().
Referenced by llvm::objcarc::ARCMDKindCache::get(), llvm::Module::getMDKindID(), and LLVMContext().
| void LLVMContext::getMDKindNames | ( | SmallVectorImpl< StringRef > & | Names | ) | const |
getMDKindNames - Populate client supplied SmallVector with the name for custom metadata IDs registered in this LLVMContext.
getHandlerNames - Populate client supplied smallvector using custome metadata name and ID.
Definition at line 255 of file LLVMContext.cpp.
References llvm::StringMap< ValueTy, AllocatorTy >::begin(), llvm::LLVMContextImpl::CustomMDKindNames, llvm::StringMap< ValueTy, AllocatorTy >::end(), I, pImpl, llvm::SmallVectorImpl< T >::resize(), and llvm::StringMapImpl::size().
Referenced by llvm::Module::getMDKindNames().
|
inline |
Query for a debug option's value.
This function returns typed data populated from command line parsing.
Definition at line 176 of file LLVMContext.h.
References llvm::OptionRegistry::instance().
| void LLVMContext::setDiagnosticHandler | ( | DiagnosticHandlerTy | DiagHandler, |
| void * | DiagContext = nullptr, |
||
| bool | RespectFilters = false |
||
| ) |
setDiagnosticHandler - This method sets a handler 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.
Definition at line 142 of file LLVMContext.cpp.
References llvm::LLVMContextImpl::DiagnosticContext, llvm::LLVMContextImpl::DiagnosticHandler, pImpl, and llvm::LLVMContextImpl::RespectDiagnosticFilters.
| void LLVMContext::setInlineAsmDiagnosticHandler | ( | InlineAsmDiagHandlerTy | DiagHandler, |
| void * | DiagContext = nullptr |
||
| ) |
setInlineAsmDiagnosticHandler - This method sets a handler that is invoked when problems with inline asm are detected by the backend.
The first argument is a function pointer and the second is a context pointer that gets passed into the DiagHandler.
LLVMContext doesn't take ownership or interpret either of these pointers.
Definition at line 123 of file LLVMContext.cpp.
References llvm::LLVMContextImpl::InlineAsmDiagContext, llvm::LLVMContextImpl::InlineAsmDiagHandler, and pImpl.
| 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 158 of file LLVMContext.cpp.
References pImpl, llvm::LLVMContextImpl::YieldCallback, and llvm::LLVMContextImpl::YieldOpaqueHandle.
| void LLVMContext::yield | ( | ) |
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.
Definition at line 164 of file LLVMContext.cpp.
References pImpl, llvm::LLVMContextImpl::YieldCallback, and llvm::LLVMContextImpl::YieldOpaqueHandle.
Referenced by llvm::legacy::FunctionPassManagerImpl::run(), llvm::legacy::PassManagerImpl::run(), and llvm::LPPassManager::runOnFunction().
|
friend |
Definition at line 192 of file LLVMContext.h.
| LLVMContextImpl* const llvm::LLVMContext::pImpl |
Definition at line 43 of file LLVMContext.h.
Referenced by llvm::DILocation::computeNewDiscriminator(), llvm::StructType::create(), diagnose(), llvm::Module::dropTriviallyDeadConstantArrays(), llvm::Instruction::dropUnknownMetadata(), llvm::Function::dropUnknownMetadata(), llvm::IntegerType::get(), llvm::InlineAsm::get(), llvm::ConstantInt::get(), llvm::FunctionType::get(), llvm::Attribute::get(), llvm::AttributeSetNode::get(), llvm::MetadataAsValue::get(), llvm::StructType::get(), llvm::ConstantFP::get(), llvm::ValueAsMetadata::get(), llvm::ConstantAggregateZero::get(), llvm::ArrayType::get(), llvm::ConstantArray::get(), llvm::VectorType::get(), llvm::ConstantStruct::get(), llvm::PointerType::get(), llvm::ConstantVector::get(), llvm::MDString::get(), llvm::ConstantPointerNull::get(), llvm::BlockAddress::get(), llvm::ConstantExpr::get(), llvm::UndefValue::get(), llvm::Function::getAllMetadata(), getDiagnosticContext(), getDiagnosticHandler(), llvm::Type::getDoubleTy(), llvm::ConstantExpr::getExtractElement(), llvm::ConstantExpr::getExtractValue(), llvm::ConstantInt::getFalse(), llvm::ConstantExpr::getFCmp(), llvm::Type::getFloatTy(), getFoldedCast(), llvm::Type::getFP128Ty(), llvm::ConstantExpr::getGetElementPtr(), llvm::Type::getHalfTy(), llvm::ConstantExpr::getICmp(), llvm::MetadataAsValue::getIfExists(), llvm::ValueAsMetadata::getIfExists(), llvm::ConstantDataSequential::getImpl(), getInlineAsmDiagnosticContext(), getInlineAsmDiagnosticHandler(), llvm::ConstantExpr::getInsertElement(), llvm::ConstantExpr::getInsertValue(), llvm::Type::getInt128Ty(), llvm::Type::getInt16Ty(), llvm::Type::getInt1Ty(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), llvm::Type::getInt8Ty(), llvm::Type::getLabelTy(), getMDKindID(), getMDKindNames(), llvm::Function::getMetadata(), llvm::Type::getMetadataTy(), llvm::Type::getPPC_FP128Ty(), llvm::Function::getPrefixData(), llvm::Function::getPrologueData(), llvm::ConstantExpr::getSelect(), llvm::ConstantExpr::getShuffleVector(), llvm::ConstantInt::getTrue(), llvm::Module::getTypeByName(), llvm::Value::getValueName(), llvm::Type::getVoidTy(), llvm::Type::getX86_FP80Ty(), llvm::Type::getX86_MMXTy(), llvm::ValueAsMetadata::handleDeletion(), llvm::BlockAddress::lookup(), llvm::StructType::setBody(), setDiagnosticHandler(), setInlineAsmDiagnosticHandler(), llvm::Instruction::setMetadata(), llvm::Function::setMetadata(), llvm::StructType::setName(), llvm::Function::setPrefixData(), llvm::Function::setPrologueData(), llvm::Value::setValueName(), setYieldCallback(), llvm::MDNode::storeDistinctInContext(), llvm::ValueHandleBase::ValueIsDeleted(), llvm::ValueHandleBase::ValueIsRAUWd(), yield(), and ~LLVMContext().
1.8.6