LLVM 20.0.0git
|
#include "llvm/IR/MDBuilder.h"
Classes | |
struct | TBAAStructField |
Public Types | |
using | PCSection = std::pair< StringRef, SmallVector< Constant * > > |
A pair of PC section name with auxilliary constant data. | |
Public Member Functions | |
MDBuilder (LLVMContext &context) | |
MDString * | createString (StringRef Str) |
Return the given string as metadata. | |
ConstantAsMetadata * | createConstant (Constant *C) |
Return the given constant as metadata. | |
MDNode * | createFPMath (float Accuracy) |
Return metadata with the given settings. | |
MDNode * | createBranchWeights (uint32_t TrueWeight, uint32_t FalseWeight, bool IsExpected=false) |
Return metadata containing two branch weights. | |
MDNode * | createLikelyBranchWeights () |
Return metadata containing two branch weights, with significant bias towards true destination. | |
MDNode * | createUnlikelyBranchWeights () |
Return metadata containing two branch weights, with significant bias towards false destination. | |
MDNode * | createBranchWeights (ArrayRef< uint32_t > Weights, bool IsExpected=false) |
Return metadata containing a number of branch weights. | |
MDNode * | createUnpredictable () |
Return metadata specifying that a branch or switch is unpredictable. | |
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. | |
MDNode * | createFunctionSectionPrefix (StringRef Prefix) |
Return metadata containing the section prefix for a function. | |
MDNode * | createPseudoProbeDesc (uint64_t GUID, uint64_t Hash, StringRef FName) |
Return metadata containing the pseudo probe descriptor for a function. | |
MDNode * | createLLVMStats (ArrayRef< std::pair< StringRef, uint64_t > > LLVMStatsVec) |
Return metadata containing llvm statistics. | |
MDNode * | createRange (const APInt &Lo, const APInt &Hi) |
Return metadata describing the range [Lo, Hi). | |
MDNode * | createRange (Constant *Lo, Constant *Hi) |
Return metadata describing the range [Lo, Hi). | |
MDNode * | createCallees (ArrayRef< Function * > Callees) |
Return metadata indicating the possible callees of indirect calls. | |
MDNode * | createCallbackEncoding (unsigned CalleeArgNo, ArrayRef< int > Arguments, bool VarArgsArePassed) |
Return metadata describing a callback (see llvm::AbstractCallSite). | |
MDNode * | mergeCallbackEncodings (MDNode *ExistingCallbacks, MDNode *NewCB) |
Merge the new callback encoding NewCB into ExistingCallbacks . | |
MDNode * | createRTTIPointerPrologue (Constant *PrologueSig, Constant *RTTI) |
Return metadata feeding to the CodeGen about how to generate a function prologue for the "function" santizier. | |
MDNode * | createPCSections (ArrayRef< PCSection > Sections) |
Return metadata for PC sections. | |
MDNode * | createAnonymousTBAARoot () |
Return metadata appropriate for a TBAA root node. | |
MDNode * | createAnonymousAliasScopeDomain (StringRef Name=StringRef()) |
Return metadata appropriate for an alias scope domain node. | |
MDNode * | createAnonymousAliasScope (MDNode *Domain, StringRef Name=StringRef()) |
Return metadata appropriate for an alias scope root node. | |
MDNode * | createTBAARoot (StringRef Name) |
Return metadata appropriate for a TBAA root node with the given name. | |
MDNode * | createAliasScopeDomain (StringRef Name) |
Return metadata appropriate for an alias scope domain node with the given name. | |
MDNode * | createAliasScope (StringRef Name, MDNode *Domain) |
Return metadata appropriate for an alias scope node with the given name. | |
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'. | |
MDNode * | createTBAAStructNode (ArrayRef< TBAAStructField > Fields) |
Return metadata for a tbaa.struct node with the given struct field descriptions. | |
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). | |
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. | |
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. | |
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. | |
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. | |
MDNode * | createMutableTBAAAccessTag (MDNode *Tag) |
Return mutable version of the given mutable or immutable TBAA access tag. | |
MDNode * | createIrrLoopHeaderWeight (uint64_t Weight) |
Return metadata containing an irreducible loop header weight. | |
Protected Member Functions | |
MDNode * | createAnonymousAARoot (StringRef Name=StringRef(), MDNode *Extra=nullptr) |
Return metadata appropriate for a AA root node (scope or TBAA). | |
Definition at line 36 of file MDBuilder.h.
using llvm::MDBuilder::PCSection = std::pair<StringRef, SmallVector<Constant *> > |
A pair of PC section name with auxilliary constant data.
Definition at line 140 of file MDBuilder.h.
|
inline |
Definition at line 40 of file MDBuilder.h.
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 234 of file MDBuilder.cpp.
References createString(), llvm::MDNode::get(), and Name.
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 230 of file MDBuilder.cpp.
References createString(), llvm::MDNode::get(), and Name.
|
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 196 of file MDBuilder.cpp.
References createString(), llvm::MDNode::getDistinct(), Name, 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 174 of file MDBuilder.h.
References createAnonymousAARoot(), and Name.
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 167 of file MDBuilder.h.
References createAnonymousAARoot(), and Name.
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 160 of file MDBuilder.h.
References createAnonymousAARoot().
Return metadata containing a number of branch weights.
Weights | the weights of all the branches |
Do | these weights come from __builtin_expect* |
Definition at line 52 of file MDBuilder.cpp.
References assert(), createConstant(), createString(), llvm::MDNode::get(), llvm::Type::getInt32Ty(), llvm::Offset, and llvm::ArrayRef< T >::size().
MDNode * MDBuilder::createBranchWeights | ( | uint32_t | TrueWeight, |
uint32_t | FalseWeight, | ||
bool | IsExpected = false |
||
) |
Return metadata containing two branch weights.
TrueWeight | the weight of the true branch |
FalseWeight | the weight of the false branch |
Do | these weights come from __builtin_expect* |
Definition at line 37 of file MDBuilder.cpp.
References createBranchWeights().
Referenced by llvm::SwitchInstProfUpdateWrapper::buildProfBranchWeightsMD(), CloneLoopBlocks(), ConnectEpilog(), ConnectProlog(), llvm::ConstantFoldTerminator(), createBranchWeights(), createBranchWeights(), llvm::createCallMatchingInvoke(), createLikelyBranchWeights(), createUnlikelyBranchWeights(), handleBrSelExpect(), handlePhiDef(), InsertStackProtectors(), llvm::makeGuardControlFlowExplicit(), llvm::setBranchWeights(), setBranchWeights(), llvm::setLoopEstimatedTripCount(), and llvm::UnrollRuntimeLoopRemainder().
MDNode * MDBuilder::createCallbackEncoding | ( | unsigned | CalleeArgNo, |
ArrayRef< int > | Arguments, | ||
bool | VarArgsArePassed | ||
) |
Return metadata describing a callback (see llvm::AbstractCallSite).
Definition at line 120 of file MDBuilder.cpp.
References Arguments, createConstant(), llvm::MDNode::get(), llvm::Type::getInt1Ty(), llvm::Type::getInt64Ty(), Int1, Int64, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), and hostParallelCallback().
Return metadata indicating the possible callees of indirect calls.
Definition at line 113 of file MDBuilder.cpp.
References createConstant(), F, llvm::MDNode::get(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by runCVP().
ConstantAsMetadata * MDBuilder::createConstant | ( | Constant * | C | ) |
Return the given constant as metadata.
Definition at line 24 of file MDBuilder.cpp.
References llvm::CallingConv::C, and llvm::ConstantAsMetadata::get().
Referenced by addModuleFlags(), llvm::annotateValueSite(), createBranchWeights(), createCallbackEncoding(), createCallees(), createFPMath(), createFunctionEntryCount(), createIrrLoopHeaderWeight(), createLLVMStats(), createPCSections(), createPseudoProbeDesc(), createRange(), createRTTIPointerPrologue(), createTBAAAccessTag(), createTBAANode(), createTBAAScalarTypeNode(), createTBAAStructNode(), createTBAAStructTagNode(), createTBAAStructTypeNode(), createTBAATypeNode(), lowerKernelArguments(), llvm::scaleProfData(), and llvm::setKCFIType().
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::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 73 of file MDBuilder.cpp.
References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::begin(), createConstant(), createString(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::sort().
Referenced by llvm::Function::setEntryCount().
Return metadata containing the section prefix for a function.
Definition at line 92 of file MDBuilder.cpp.
References createString(), and llvm::MDNode::get().
Referenced by llvm::Function::setSectionPrefix().
Return metadata containing an irreducible loop header weight.
Definition at line 344 of file MDBuilder.cpp.
References createConstant(), createString(), llvm::MDNode::get(), and llvm::Type::getInt64Ty().
Referenced by llvm::setIrrLoopHeaderMetadata().
MDNode * MDBuilder::createLikelyBranchWeights | ( | ) |
Return metadata containing two branch weights, with significant bias towards true
destination.
Definition at line 42 of file MDBuilder.cpp.
References createBranchWeights().
Return metadata containing llvm statistics.
Definition at line 363 of file MDBuilder.cpp.
References createConstant(), createString(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), and I.
Return mutable version of the given mutable or immutable TBAA access tag.
Definition at line 317 of file MDBuilder.cpp.
References createTBAAAccessTag(), createTBAAStructTagNode(), llvm::MDNode::getOperand(), llvm::Offset, and Size.
Referenced by stripNonValidDataFromBody().
Return metadata for PC sections.
Definition at line 175 of file MDBuilder.cpp.
References llvm::CallingConv::C, createConstant(), createString(), llvm::SmallVectorBase< Size_T >::empty(), llvm::MDNode::get(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::reserve(), and llvm::SmallVectorBase< Size_T >::size().
Return metadata containing the pseudo probe descriptor for a function.
Definition at line 352 of file MDBuilder.cpp.
References createConstant(), createString(), llvm::MDNode::get(), and llvm::Type::getInt64Ty().
Referenced by llvm::SampleProfileProber::instrumentOneFunc().
Return metadata describing the range [Lo, Hi).
Definition at line 97 of file MDBuilder.cpp.
References assert(), createRange(), llvm::IntegerType::get(), llvm::Hi, and llvm::Lo.
Referenced by llvm::copyNonnullMetadata(), createRange(), and llvm::AMDGPUSubtarget::makeLIDRangeMetadata().
Return metadata describing the range [Lo, Hi).
Definition at line 104 of file MDBuilder.cpp.
References createConstant(), llvm::MDNode::get(), llvm::Hi, and llvm::Lo.
Return metadata feeding to the CodeGen about how to generate a function prologue for the "function" santizier.
Definition at line 167 of file MDBuilder.cpp.
References createConstant(), llvm::MDNode::get(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
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(), createLLVMStats(), createPCSections(), 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 303 of file MDBuilder.cpp.
References createConstant(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), Int64, llvm::Offset, and Size.
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 220 of file MDBuilder.cpp.
References createConstant(), createString(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), isConstant(), and Name.
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 214 of file MDBuilder.cpp.
References createString(), llvm::MDNode::get(), and Name.
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 267 of file MDBuilder.cpp.
References createConstant(), createString(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), Name, and llvm::Offset.
MDNode * MDBuilder::createTBAAStructNode | ( | ArrayRef< TBAAStructField > | Fields | ) |
Return metadata for a tbaa.struct node with the given struct field descriptions.
Definition at line 240 of file MDBuilder.cpp.
References createConstant(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), Int64, llvm::Offset, llvm::ArrayRef< T >::size(), and 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 276 of file MDBuilder.cpp.
References createConstant(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), Int64, and llvm::Offset.
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 253 of file MDBuilder.cpp.
References createConstant(), createString(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), Int64, and Name.
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 287 of file MDBuilder.cpp.
References createConstant(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), I, Int64, llvm::Offset, llvm::ArrayRef< T >::size(), and Size.
MDNode * MDBuilder::createUnlikelyBranchWeights | ( | ) |
Return metadata containing two branch weights, with significant bias towards false
destination.
Definition at line 47 of file MDBuilder.cpp.
References createBranchWeights().
Referenced by llvm::AMDGPU::genAMDGPUReportBlock(), and llvm::KCFIPass::run().
MDNode * MDBuilder::createUnpredictable | ( | ) |
Return metadata specifying that a branch or switch is unpredictable.
Definition at line 69 of file MDBuilder.cpp.
References llvm::MDNode::get().
Merge the new callback encoding NewCB
into ExistingCallbacks
.
Definition at line 137 of file MDBuilder.cpp.
References assert(), llvm::MDNode::get(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), and llvm::SmallVectorImpl< T >::resize().