LLVM
15.0.0git
|
#include "llvm/IR/MDBuilder.h"
Classes | |
struct | TBAAStructField |
Public Member Functions | |
MDBuilder (LLVMContext &context) | |
MDString * | createString (StringRef Str) |
Return the given string as metadata. More... | |
ConstantAsMetadata * | createConstant (Constant *C) |
Return the given constant as metadata. More... | |
MDNode * | createFPMath (float Accuracy) |
Return metadata with the given settings. More... | |
MDNode * | createBranchWeights (uint32_t TrueWeight, uint32_t FalseWeight) |
Return metadata containing two branch weights. More... | |
MDNode * | createBranchWeights (ArrayRef< uint32_t > Weights) |
Return metadata containing a number of branch weights. More... | |
MDNode * | createUnpredictable () |
Return metadata specifying that a branch or switch is unpredictable. More... | |
MDNode * | createFunctionEntryCount (uint64_t Count, bool Synthetic, const DenseSet< GlobalValue::GUID > *Imports) |
Return metadata containing the entry Count for a function, a boolean \Synthetic indicating whether the counts were synthetized, and the GUIDs stored in Imports that need to be imported for sample PGO, to enable the same inlines as the profiled optimized binary. More... | |
MDNode * | createFunctionSectionPrefix (StringRef Prefix) |
Return metadata containing the section prefix for a function. More... | |
MDNode * | createPseudoProbeDesc (uint64_t GUID, uint64_t Hash, Function *F) |
Return metadata containing the pseudo probe descriptor for a function. More... | |
MDNode * | createRange (const APInt &Lo, const APInt &Hi) |
Return metadata describing the range [Lo, Hi). More... | |
MDNode * | createRange (Constant *Lo, Constant *Hi) |
Return metadata describing the range [Lo, Hi). More... | |
MDNode * | createCallees (ArrayRef< Function * > Callees) |
Return metadata indicating the possible callees of indirect calls. More... | |
MDNode * | createCallbackEncoding (unsigned CalleeArgNo, ArrayRef< int > Arguments, bool VarArgsArePassed) |
Return metadata describing a callback (see llvm::AbstractCallSite). More... | |
MDNode * | mergeCallbackEncodings (MDNode *ExistingCallbacks, MDNode *NewCB) |
Merge the new callback encoding NewCB into ExistingCallbacks . More... | |
MDNode * | createAnonymousTBAARoot () |
Return metadata appropriate for a TBAA root node. More... | |
MDNode * | createAnonymousAliasScopeDomain (StringRef Name=StringRef()) |
Return metadata appropriate for an alias scope domain node. More... | |
MDNode * | createAnonymousAliasScope (MDNode *Domain, StringRef Name=StringRef()) |
Return metadata appropriate for an alias scope root node. More... | |
MDNode * | createTBAARoot (StringRef Name) |
Return metadata appropriate for a TBAA root node with the given name. More... | |
MDNode * | createAliasScopeDomain (StringRef Name) |
Return metadata appropriate for an alias scope domain node with the given name. More... | |
MDNode * | createAliasScope (StringRef Name, MDNode *Domain) |
Return metadata appropriate for an alias scope node with the given name. More... | |
MDNode * | createTBAANode (StringRef Name, MDNode *Parent, bool isConstant=false) |
Return metadata for a non-root TBAA node with the given name, parent in the TBAA tree, and value for 'pointsToConstantMemory'. More... | |
MDNode * | createTBAAStructNode (ArrayRef< TBAAStructField > Fields) |
Return metadata for a tbaa.struct node with the given struct field descriptions. More... | |
MDNode * | createTBAAStructTypeNode (StringRef Name, ArrayRef< std::pair< MDNode *, uint64_t >> Fields) |
Return metadata for a TBAA struct node in the type DAG with the given name, a list of pairs (offset, field type in the type DAG). More... | |
MDNode * | createTBAAScalarTypeNode (StringRef Name, MDNode *Parent, uint64_t Offset=0) |
Return metadata for a TBAA scalar type node with the given name, an offset and a parent in the TBAA type DAG. More... | |
MDNode * | createTBAAStructTagNode (MDNode *BaseType, MDNode *AccessType, uint64_t Offset, bool IsConstant=false) |
Return metadata for a TBAA tag node with the given base type, access type and offset relative to the base type. More... | |
MDNode * | createTBAATypeNode (MDNode *Parent, uint64_t Size, Metadata *Id, ArrayRef< TBAAStructField > Fields=ArrayRef< TBAAStructField >()) |
Return metadata for a TBAA type node in the TBAA type DAG with the given parent type, size in bytes, type identifier and a list of fields. More... | |
MDNode * | createTBAAAccessTag (MDNode *BaseType, MDNode *AccessType, uint64_t Offset, uint64_t Size, bool IsImmutable=false) |
Return metadata for a TBAA access tag with the given base type, final access type, offset of the access relative to the base type, size of the access and flag indicating whether the accessed object can be considered immutable for the purposes of the TBAA analysis. More... | |
MDNode * | createMutableTBAAAccessTag (MDNode *Tag) |
Return mutable version of the given mutable or immutable TBAA access tag. More... | |
MDNode * | createIrrLoopHeaderWeight (uint64_t Weight) |
Return metadata containing an irreducible loop header weight. More... | |
Protected Member Functions | |
MDNode * | createAnonymousAARoot (StringRef Name=StringRef(), MDNode *Extra=nullptr) |
Return metadata appropriate for a AA root node (scope or TBAA). More... | |
Definition at line 35 of file MDBuilder.h.
|
inline |
Definition at line 39 of file MDBuilder.h.
References Context.
Return metadata appropriate for an alias scope node with the given name.
This may be identified (uniqued) with other scopes with the same name and domain.
Definition at line 191 of file MDBuilder.cpp.
References createString(), and llvm::MDNode::get().
Return metadata appropriate for an alias scope domain node with the given name.
This may be identified (uniqued) with other roots with the same name.
Definition at line 187 of file MDBuilder.cpp.
References createString(), and llvm::MDNode::get().
|
protected |
Return metadata appropriate for a AA root node (scope or TBAA).
Each returned node is distinct from all other metadata and will never be identified (uniqued) with anything else.
Definition at line 153 of file MDBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, createString(), llvm::MDNode::getDistinct(), and llvm::MDNode::replaceOperandWith().
Referenced by createAnonymousAliasScope(), createAnonymousAliasScopeDomain(), and createAnonymousTBAARoot().
|
inline |
Return metadata appropriate for an alias scope root node.
Each returned node is distinct from all other metadata and will never be identified (uniqued) with anything else.
Definition at line 140 of file MDBuilder.h.
References createAnonymousAARoot().
Referenced by AddAliasScopeMetadata(), llvm::cloneNoAliasScopes(), llvm::createMemCpyLoopKnownSize(), and llvm::LoopVersioning::prepareNoAliasMetadata().
Return metadata appropriate for an alias scope domain node.
Each returned node is distinct from all other metadata and will never be identified (uniqued) with anything else.
Definition at line 133 of file MDBuilder.h.
References createAnonymousAARoot().
Referenced by AddAliasScopeMetadata(), llvm::createMemCpyLoopKnownSize(), and llvm::LoopVersioning::prepareNoAliasMetadata().
|
inline |
Return metadata appropriate for a TBAA root node.
Each returned node is distinct from all other metadata and will never be identified (uniqued) with anything else.
Definition at line 126 of file MDBuilder.h.
References createAnonymousAARoot().
Return metadata containing a number of branch weights.
Definition at line 42 of file MDBuilder.cpp.
References assert(), createConstant(), createString(), llvm::numbers::e, llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::Type::getInt32Ty(), i, Int32Ty, and llvm::ArrayRef< T >::size().
Return metadata containing two branch weights.
Definition at line 37 of file MDBuilder.cpp.
Referenced by llvm::SwitchInstProfUpdateWrapper::buildProfBranchWeightsMD(), llvm::createCallMatchingInvoke(), fixupBranchWeights(), handlePhiDef(), handleSwitchExpect(), llvm::makeGuardControlFlowExplicit(), llvm::pgo::promoteIndirectCall(), setBranchWeights(), llvm::setLoopEstimatedTripCount(), llvm::setProfMetadata(), updateBranchWeights(), updateLatchBranchWeightsForRemainderLoop(), and updatePredecessorProfileMetadata().
MDNode * MDBuilder::createCallbackEncoding | ( | unsigned | CalleeArgNo, |
ArrayRef< int > | Arguments, | ||
bool | VarArgsArePassed | ||
) |
Return metadata describing a callback (see llvm::AbstractCallSite).
Definition at line 107 of file MDBuilder.cpp.
References Arguments, createConstant(), llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::Type::getInt1Ty(), and llvm::Type::getInt64Ty().
Referenced by llvm::OpenMPIRBuilder::createParallel(), and llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction().
Return metadata indicating the possible callees of indirect calls.
Definition at line 100 of file MDBuilder.cpp.
References createConstant(), F, and llvm::MDNode::get().
Referenced by runCVP().
ConstantAsMetadata * MDBuilder::createConstant | ( | Constant * | C | ) |
Return the given constant as metadata.
Definition at line 24 of file MDBuilder.cpp.
References llvm::ConstantAsMetadata::get().
Referenced by addModuleFlags(), llvm::annotateValueSite(), createBranchWeights(), createCallbackEncoding(), createCallees(), createFPMath(), createFunctionEntryCount(), createIrrLoopHeaderWeight(), createPseudoProbeDesc(), createRange(), createTBAAAccessTag(), createTBAANode(), createTBAAScalarTypeNode(), createTBAAStructNode(), createTBAAStructTagNode(), createTBAAStructTypeNode(), createTBAATypeNode(), and llvm::CallInst::updateProfWeight().
MDNode * MDBuilder::createFPMath | ( | float | Accuracy | ) |
Return metadata with the given settings.
The special value 0.0 for the Accuracy parameter indicates the default (maximal precision) setting.
Definition at line 28 of file MDBuilder.cpp.
References assert(), createConstant(), llvm::ConstantFP::get(), llvm::MDNode::get(), and llvm::Type::getFloatTy().
MDNode * MDBuilder::createFunctionEntryCount | ( | uint64_t | Count, |
bool | Synthetic, | ||
const DenseSet< GlobalValue::GUID > * | Imports | ||
) |
Return metadata containing the entry Count
for a function, a boolean \Synthetic indicating whether the counts were synthetized, and the GUIDs stored in Imports
that need to be imported for sample PGO, to enable the same inlines as the profiled optimized binary.
Definition at line 59 of file MDBuilder.cpp.
References llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::begin(), createConstant(), createString(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::end(), llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), and llvm::sort().
Referenced by llvm::Function::setEntryCount().
Return metadata containing the section prefix for a function.
Definition at line 78 of file MDBuilder.cpp.
References createString(), llvm::MDNode::get(), and llvm::cl::Prefix.
Referenced by llvm::Function::setSectionPrefix().
Return metadata containing an irreducible loop header weight.
Definition at line 301 of file MDBuilder.cpp.
References createConstant(), createString(), llvm::ConstantInt::get(), llvm::MDNode::get(), and llvm::Type::getInt64Ty().
Referenced by llvm::setIrrLoopHeaderMetadata().
Return mutable version of the given mutable or immutable TBAA access tag.
Definition at line 274 of file MDBuilder.cpp.
References createTBAAAccessTag(), createTBAAStructTagNode(), and llvm::MDNode::getOperand().
Return metadata containing the pseudo probe descriptor for a function.
Definition at line 309 of file MDBuilder.cpp.
References createConstant(), createString(), F, llvm::ConstantInt::get(), llvm::MDNode::get(), and llvm::Type::getInt64Ty().
Referenced by llvm::SampleProfileProber::instrumentOneFunc().
Return metadata describing the range [Lo, Hi).
Definition at line 84 of file MDBuilder.cpp.
References assert(), llvm::IntegerType::get(), and llvm::ConstantInt::get().
Referenced by llvm::copyNonnullMetadata(), and llvm::AMDGPUSubtarget::makeLIDRangeMetadata().
Return metadata describing the range [Lo, Hi).
Definition at line 91 of file MDBuilder.cpp.
References createConstant(), and llvm::MDNode::get().
Return the given string as metadata.
Definition at line 20 of file MDBuilder.cpp.
References llvm::MDString::get().
Referenced by llvm::Instruction::addAnnotationMetadata(), annotateFunctionWithHashMismatch(), llvm::annotateValueSite(), createAliasScope(), createAliasScopeDomain(), createAnonymousAARoot(), createBranchWeights(), createFunctionEntryCount(), createFunctionSectionPrefix(), createIrrLoopHeaderWeight(), createPseudoProbeDesc(), createTBAANode(), createTBAARoot(), createTBAAScalarTypeNode(), and createTBAAStructTypeNode().
MDNode * MDBuilder::createTBAAAccessTag | ( | MDNode * | BaseType, |
MDNode * | AccessType, | ||
uint64_t | Offset, | ||
uint64_t | Size, | ||
bool | IsImmutable = false |
||
) |
Return metadata for a TBAA access tag with the given base type, final access type, offset of the access relative to the base type, size of the access and flag indicating whether the accessed object can be considered immutable for the purposes of the TBAA analysis.
Definition at line 260 of file MDBuilder.cpp.
References createConstant(), llvm::ConstantInt::get(), llvm::MDNode::get(), and llvm::Type::getInt64Ty().
Referenced by createMutableTBAAAccessTag().
Return metadata for a non-root TBAA node with the given name, parent in the TBAA tree, and value for 'pointsToConstantMemory'.
Definition at line 177 of file MDBuilder.cpp.
References createConstant(), createString(), llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), and isConstant().
Return metadata appropriate for a TBAA root node with the given name.
This may be identified (uniqued) with other roots with the same name.
Definition at line 171 of file MDBuilder.cpp.
References createString(), and llvm::MDNode::get().
MDNode * MDBuilder::createTBAAScalarTypeNode | ( | StringRef | Name, |
MDNode * | Parent, | ||
uint64_t | Offset = 0 |
||
) |
Return metadata for a TBAA scalar type node with the given name, an offset and a parent in the TBAA type DAG.
Definition at line 224 of file MDBuilder.cpp.
References createConstant(), createString(), llvm::ConstantInt::get(), llvm::MDNode::get(), and llvm::Type::getInt64Ty().
MDNode * MDBuilder::createTBAAStructNode | ( | ArrayRef< TBAAStructField > | Fields | ) |
Return metadata for a tbaa.struct node with the given struct field descriptions.
Definition at line 197 of file MDBuilder.cpp.
References createConstant(), llvm::numbers::e, llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), i, and llvm::ArrayRef< T >::size().
MDNode * MDBuilder::createTBAAStructTagNode | ( | MDNode * | BaseType, |
MDNode * | AccessType, | ||
uint64_t | Offset, | ||
bool | IsConstant = false |
||
) |
Return metadata for a TBAA tag node with the given base type, access type and offset relative to the base type.
Definition at line 233 of file MDBuilder.cpp.
References createConstant(), llvm::ConstantInt::get(), llvm::MDNode::get(), and llvm::Type::getInt64Ty().
Referenced by createMutableTBAAAccessTag().
MDNode * MDBuilder::createTBAAStructTypeNode | ( | StringRef | Name, |
ArrayRef< std::pair< MDNode *, uint64_t >> | Fields | ||
) |
Return metadata for a TBAA struct node in the type DAG with the given name, a list of pairs (offset, field type in the type DAG).
Definition at line 210 of file MDBuilder.cpp.
References createConstant(), createString(), llvm::numbers::e, llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), and i.
MDNode * MDBuilder::createTBAATypeNode | ( | MDNode * | Parent, |
uint64_t | Size, | ||
Metadata * | Id, | ||
ArrayRef< TBAAStructField > | Fields = ArrayRef<TBAAStructField>() |
||
) |
Return metadata for a TBAA type node in the TBAA type DAG with the given parent type, size in bytes, type identifier and a list of fields.
Definition at line 244 of file MDBuilder.cpp.
References createConstant(), E, llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), I, and llvm::ArrayRef< T >::size().
MDNode * MDBuilder::createUnpredictable | ( | ) |
Return metadata specifying that a branch or switch is unpredictable.
Definition at line 55 of file MDBuilder.cpp.
References llvm::MDNode::get(), and llvm::None.
Merge the new callback encoding NewCB
into ExistingCallbacks
.
Definition at line 124 of file MDBuilder.cpp.
References assert(), llvm::MDNode::get(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), and llvm::SmallVectorImpl< T >::resize().