LLVM 20.0.0git
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
llvm::MDBuilder Class Reference

#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)
 
MDStringcreateString (StringRef Str)
 Return the given string as metadata.
 
ConstantAsMetadatacreateConstant (Constant *C)
 Return the given constant as metadata.
 
MDNodecreateFPMath (float Accuracy)
 Return metadata with the given settings.
 
MDNodecreateBranchWeights (uint32_t TrueWeight, uint32_t FalseWeight, bool IsExpected=false)
 Return metadata containing two branch weights.
 
MDNodecreateLikelyBranchWeights ()
 Return metadata containing two branch weights, with significant bias towards true destination.
 
MDNodecreateUnlikelyBranchWeights ()
 Return metadata containing two branch weights, with significant bias towards false destination.
 
MDNodecreateBranchWeights (ArrayRef< uint32_t > Weights, bool IsExpected=false)
 Return metadata containing a number of branch weights.
 
MDNodecreateUnpredictable ()
 Return metadata specifying that a branch or switch is unpredictable.
 
MDNodecreateFunctionEntryCount (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.
 
MDNodecreateFunctionSectionPrefix (StringRef Prefix)
 Return metadata containing the section prefix for a function.
 
MDNodecreatePseudoProbeDesc (uint64_t GUID, uint64_t Hash, StringRef FName)
 Return metadata containing the pseudo probe descriptor for a function.
 
MDNodecreateLLVMStats (ArrayRef< std::pair< StringRef, uint64_t > > LLVMStatsVec)
 Return metadata containing llvm statistics.
 
MDNodecreateRange (const APInt &Lo, const APInt &Hi)
 Return metadata describing the range [Lo, Hi).
 
MDNodecreateRange (Constant *Lo, Constant *Hi)
 Return metadata describing the range [Lo, Hi).
 
MDNodecreateCallees (ArrayRef< Function * > Callees)
 Return metadata indicating the possible callees of indirect calls.
 
MDNodecreateCallbackEncoding (unsigned CalleeArgNo, ArrayRef< int > Arguments, bool VarArgsArePassed)
 Return metadata describing a callback (see llvm::AbstractCallSite).
 
MDNodemergeCallbackEncodings (MDNode *ExistingCallbacks, MDNode *NewCB)
 Merge the new callback encoding NewCB into ExistingCallbacks.
 
MDNodecreateRTTIPointerPrologue (Constant *PrologueSig, Constant *RTTI)
 Return metadata feeding to the CodeGen about how to generate a function prologue for the "function" santizier.
 
MDNodecreatePCSections (ArrayRef< PCSection > Sections)
 Return metadata for PC sections.
 
MDNodecreateAnonymousTBAARoot ()
 Return metadata appropriate for a TBAA root node.
 
MDNodecreateAnonymousAliasScopeDomain (StringRef Name=StringRef())
 Return metadata appropriate for an alias scope domain node.
 
MDNodecreateAnonymousAliasScope (MDNode *Domain, StringRef Name=StringRef())
 Return metadata appropriate for an alias scope root node.
 
MDNodecreateTBAARoot (StringRef Name)
 Return metadata appropriate for a TBAA root node with the given name.
 
MDNodecreateAliasScopeDomain (StringRef Name)
 Return metadata appropriate for an alias scope domain node with the given name.
 
MDNodecreateAliasScope (StringRef Name, MDNode *Domain)
 Return metadata appropriate for an alias scope node with the given name.
 
MDNodecreateTBAANode (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'.
 
MDNodecreateTBAAStructNode (ArrayRef< TBAAStructField > Fields)
 Return metadata for a tbaa.struct node with the given struct field descriptions.
 
MDNodecreateTBAAStructTypeNode (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).
 
MDNodecreateTBAAScalarTypeNode (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.
 
MDNodecreateTBAAStructTagNode (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.
 
MDNodecreateTBAATypeNode (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.
 
MDNodecreateTBAAAccessTag (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.
 
MDNodecreateMutableTBAAAccessTag (MDNode *Tag)
 Return mutable version of the given mutable or immutable TBAA access tag.
 
MDNodecreateIrrLoopHeaderWeight (uint64_t Weight)
 Return metadata containing an irreducible loop header weight.
 

Protected Member Functions

MDNodecreateAnonymousAARoot (StringRef Name=StringRef(), MDNode *Extra=nullptr)
 Return metadata appropriate for a AA root node (scope or TBAA).
 

Detailed Description

Definition at line 36 of file MDBuilder.h.

Member Typedef Documentation

◆ PCSection

A pair of PC section name with auxilliary constant data.

Definition at line 140 of file MDBuilder.h.

Constructor & Destructor Documentation

◆ MDBuilder()

llvm::MDBuilder::MDBuilder ( LLVMContext context)
inline

Definition at line 40 of file MDBuilder.h.

Member Function Documentation

◆ createAliasScope()

MDNode * MDBuilder::createAliasScope ( StringRef  Name,
MDNode Domain 
)

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 232 of file MDBuilder.cpp.

References createString(), llvm::MDNode::get(), and Name.

◆ createAliasScopeDomain()

MDNode * MDBuilder::createAliasScopeDomain ( StringRef  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 228 of file MDBuilder.cpp.

References createString(), llvm::MDNode::get(), and Name.

◆ createAnonymousAARoot()

MDNode * MDBuilder::createAnonymousAARoot ( StringRef  Name = StringRef(),
MDNode Extra = nullptr 
)
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 194 of file MDBuilder.cpp.

References createString(), llvm::MDNode::getDistinct(), Name, and llvm::MDNode::replaceOperandWith().

Referenced by createAnonymousAliasScope(), createAnonymousAliasScopeDomain(), and createAnonymousTBAARoot().

◆ createAnonymousAliasScope()

MDNode * llvm::MDBuilder::createAnonymousAliasScope ( MDNode Domain,
StringRef  Name = StringRef() 
)
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().

◆ createAnonymousAliasScopeDomain()

MDNode * llvm::MDBuilder::createAnonymousAliasScopeDomain ( StringRef  Name = StringRef())
inline

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().

◆ createAnonymousTBAARoot()

MDNode * llvm::MDBuilder::createAnonymousTBAARoot ( )
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().

◆ createBranchWeights() [1/2]

MDNode * MDBuilder::createBranchWeights ( ArrayRef< uint32_t Weights,
bool  IsExpected = false 
)

Return metadata containing a number of branch weights.

Parameters
Weightsthe weights of all the branches
Dothese 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().

◆ createBranchWeights() [2/2]

MDNode * MDBuilder::createBranchWeights ( uint32_t  TrueWeight,
uint32_t  FalseWeight,
bool  IsExpected = false 
)

◆ createCallbackEncoding()

MDNode * MDBuilder::createCallbackEncoding ( unsigned  CalleeArgNo,
ArrayRef< int >  Arguments,
bool  VarArgsArePassed 
)

◆ createCallees()

MDNode * MDBuilder::createCallees ( ArrayRef< Function * >  Callees)

Return metadata indicating the possible callees of indirect calls.

Definition at line 111 of file MDBuilder.cpp.

References createConstant(), F, llvm::MDNode::get(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by runCVP().

◆ createConstant()

ConstantAsMetadata * MDBuilder::createConstant ( Constant C)

◆ createFPMath()

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().

◆ createFunctionEntryCount()

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 71 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().

◆ createFunctionSectionPrefix()

MDNode * MDBuilder::createFunctionSectionPrefix ( StringRef  Prefix)

Return metadata containing the section prefix for a function.

Definition at line 90 of file MDBuilder.cpp.

References createString(), and llvm::MDNode::get().

◆ createIrrLoopHeaderWeight()

MDNode * MDBuilder::createIrrLoopHeaderWeight ( uint64_t  Weight)

Return metadata containing an irreducible loop header weight.

Definition at line 342 of file MDBuilder.cpp.

References createConstant(), createString(), llvm::MDNode::get(), and llvm::Type::getInt64Ty().

Referenced by llvm::setIrrLoopHeaderMetadata().

◆ createLikelyBranchWeights()

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().

◆ createLLVMStats()

MDNode * MDBuilder::createLLVMStats ( ArrayRef< std::pair< StringRef, uint64_t > >  LLVMStatsVec)

Return metadata containing llvm statistics.

Definition at line 361 of file MDBuilder.cpp.

References createConstant(), createString(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), and I.

◆ createMutableTBAAAccessTag()

MDNode * MDBuilder::createMutableTBAAAccessTag ( MDNode Tag)

Return mutable version of the given mutable or immutable TBAA access tag.

Definition at line 315 of file MDBuilder.cpp.

References createTBAAAccessTag(), createTBAAStructTagNode(), llvm::MDNode::getOperand(), llvm::Offset, Size, and llvm::Tag.

Referenced by stripNonValidDataFromBody().

◆ createPCSections()

MDNode * MDBuilder::createPCSections ( ArrayRef< PCSection Sections)

◆ createPseudoProbeDesc()

MDNode * MDBuilder::createPseudoProbeDesc ( uint64_t  GUID,
uint64_t  Hash,
StringRef  FName 
)

Return metadata containing the pseudo probe descriptor for a function.

Definition at line 350 of file MDBuilder.cpp.

References createConstant(), createString(), llvm::MDNode::get(), and llvm::Type::getInt64Ty().

Referenced by llvm::SampleProfileProber::instrumentOneFunc().

◆ createRange() [1/2]

MDNode * MDBuilder::createRange ( const APInt Lo,
const APInt Hi 
)

◆ createRange() [2/2]

MDNode * MDBuilder::createRange ( Constant Lo,
Constant Hi 
)

Return metadata describing the range [Lo, Hi).

Definition at line 102 of file MDBuilder.cpp.

References createConstant(), llvm::MDNode::get(), llvm::Hi, and llvm::Lo.

◆ createRTTIPointerPrologue()

MDNode * MDBuilder::createRTTIPointerPrologue ( Constant PrologueSig,
Constant RTTI 
)

Return metadata feeding to the CodeGen about how to generate a function prologue for the "function" santizier.

Definition at line 165 of file MDBuilder.cpp.

References createConstant(), llvm::MDNode::get(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

◆ createString()

MDString * MDBuilder::createString ( StringRef  Str)

◆ createTBAAAccessTag()

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 301 of file MDBuilder.cpp.

References createConstant(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), Int64, llvm::Offset, and Size.

Referenced by createMutableTBAAAccessTag().

◆ createTBAANode()

MDNode * MDBuilder::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'.

Definition at line 218 of file MDBuilder.cpp.

References createConstant(), createString(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), isConstant(), and Name.

◆ createTBAARoot()

MDNode * MDBuilder::createTBAARoot ( StringRef  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 212 of file MDBuilder.cpp.

References createString(), llvm::MDNode::get(), and Name.

◆ createTBAAScalarTypeNode()

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 265 of file MDBuilder.cpp.

References createConstant(), createString(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), Name, and llvm::Offset.

◆ createTBAAStructNode()

MDNode * MDBuilder::createTBAAStructNode ( ArrayRef< TBAAStructField Fields)

Return metadata for a tbaa.struct node with the given struct field descriptions.

Definition at line 238 of file MDBuilder.cpp.

References createConstant(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), Int64, llvm::Offset, llvm::ArrayRef< T >::size(), and Size.

◆ createTBAAStructTagNode()

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 274 of file MDBuilder.cpp.

References createConstant(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), Int64, and llvm::Offset.

Referenced by createMutableTBAAAccessTag().

◆ createTBAAStructTypeNode()

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 251 of file MDBuilder.cpp.

References createConstant(), createString(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), Int64, and Name.

◆ createTBAATypeNode()

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 285 of file MDBuilder.cpp.

References createConstant(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), I, Int64, llvm::Offset, llvm::ArrayRef< T >::size(), and Size.

◆ createUnlikelyBranchWeights()

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().

◆ createUnpredictable()

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().

◆ mergeCallbackEncodings()

MDNode * MDBuilder::mergeCallbackEncodings ( MDNode ExistingCallbacks,
MDNode NewCB 
)

Merge the new callback encoding NewCB into ExistingCallbacks.

Definition at line 135 of file MDBuilder.cpp.

References assert(), llvm::MDNode::get(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), and llvm::SmallVectorImpl< T >::resize().


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