LLVM  10.0.0svn
Classes | Public Member Functions | Protected Member Functions | List of all members
llvm::MDBuilder Class Reference

#include "llvm/IR/MDBuilder.h"

Classes

struct  TBAAStructField
 

Public Member Functions

 MDBuilder (LLVMContext &context)
 
MDStringcreateString (StringRef Str)
 Return the given string as metadata. More...
 
ConstantAsMetadatacreateConstant (Constant *C)
 Return the given constant as metadata. More...
 
MDNodecreateFPMath (float Accuracy)
 Return metadata with the given settings. More...
 
MDNodecreateBranchWeights (uint32_t TrueWeight, uint32_t FalseWeight)
 Return metadata containing two branch weights. More...
 
MDNodecreateBranchWeights (ArrayRef< uint32_t > Weights)
 Return metadata containing a number of branch weights. More...
 
MDNodecreateUnpredictable ()
 Return metadata specifying that a branch or switch is unpredictable. More...
 
MDNodecreateFunctionEntryCount (uint64_t Count, bool Synthetic, const DenseSet< GlobalValue::GUID > *Imports)
 Return metadata containing the entry Count for a function, a boolean 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...
 
MDNodecreateFunctionSectionPrefix (StringRef Prefix)
 Return metadata containing the section prefix for a function. More...
 
MDNodecreateMisExpect (uint64_t Index, uint64_t LikelyWeight, uint64_t UnlikelyWeight)
 return metadata containing expected value More...
 
MDNodecreateRange (const APInt &Lo, const APInt &Hi)
 Return metadata describing the range [Lo, Hi). More...
 
MDNodecreateRange (Constant *Lo, Constant *Hi)
 Return metadata describing the range [Lo, Hi). More...
 
MDNodecreateCallees (ArrayRef< Function *> Callees)
 Return metadata indicating the possible callees of indirect calls. More...
 
MDNodecreateCallbackEncoding (unsigned CalleeArgNo, ArrayRef< int > Arguments, bool VarArgsArePassed)
 Return metadata describing a callback (see llvm::AbstractCallSite). More...
 
MDNodemergeCallbackEncodings (MDNode *ExistingCallbacks, MDNode *NewCB)
 Merge the new callback encoding NewCB into ExistingCallbacks. More...
 
MDNodecreateAnonymousTBAARoot ()
 Return metadata appropriate for a TBAA root node. More...
 
MDNodecreateAnonymousAliasScopeDomain (StringRef Name=StringRef())
 Return metadata appropriate for an alias scope domain node. More...
 
MDNodecreateAnonymousAliasScope (MDNode *Domain, StringRef Name=StringRef())
 Return metadata appropriate for an alias scope root node. More...
 
MDNodecreateTBAARoot (StringRef Name)
 Return metadata appropriate for a TBAA root node with the given name. More...
 
MDNodecreateAliasScopeDomain (StringRef Name)
 Return metadata appropriate for an alias scope domain node with the given name. More...
 
MDNodecreateAliasScope (StringRef Name, MDNode *Domain)
 Return metadata appropriate for an alias scope node with the given name. More...
 
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'. More...
 
MDNodecreateTBAAStructNode (ArrayRef< TBAAStructField > Fields)
 Return metadata for a tbaa.struct node with the given struct field descriptions. More...
 
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). More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
MDNodecreateMutableTBAAAccessTag (MDNode *Tag)
 Return mutable version of the given mutable or immutable TBAA access tag. More...
 
MDNodecreateIrrLoopHeaderWeight (uint64_t Weight)
 Return metadata containing an irreducible loop header weight. More...
 

Protected Member Functions

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

Detailed Description

Definition at line 35 of file MDBuilder.h.

Constructor & Destructor Documentation

◆ MDBuilder()

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

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

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

Referenced by createAnonymousAliasScope().

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

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

Referenced by createAnonymousAliasScope().

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

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, createString(), llvm::NVPTXISD::Dummy, llvm::StringRef::empty(), llvm::MDNode::get(), llvm::MDNode::getTemporary(), llvm::None, and llvm::MDNode::replaceOperandWith().

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

◆ 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 141 of file MDBuilder.h.

References createAliasScope(), createAliasScopeDomain(), createAnonymousAARoot(), createTBAANode(), createTBAARoot(), isConstant(), and Name.

Referenced by 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 134 of file MDBuilder.h.

References createAnonymousAARoot(), and Name.

Referenced by 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 127 of file MDBuilder.h.

References createAnonymousAARoot().

◆ createBranchWeights() [1/2]

MDNode * MDBuilder::createBranchWeights ( uint32_t  TrueWeight,
uint32_t  FalseWeight 
)

◆ createBranchWeights() [2/2]

MDNode * MDBuilder::createBranchWeights ( ArrayRef< uint32_t Weights)

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(), Int32Ty, and llvm::ArrayRef< T >::size().

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

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

Referenced by MDBuilder().

◆ 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::ConstantFP::get(), llvm::MDNode::get(), and llvm::Type::getFloatTy().

Referenced by MDBuilder().

◆ 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 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, MapTy, ValueInfoT >::begin(), createConstant(), createString(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), llvm::SmallVectorTemplateBase< T >::push_back(), and llvm::stable_sort().

Referenced by MDBuilder().

◆ createFunctionSectionPrefix()

MDNode * MDBuilder::createFunctionSectionPrefix ( StringRef  Prefix)

Return metadata containing the section prefix for a function.

Definition at line 78 of file MDBuilder.cpp.

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

Referenced by MDBuilder(), and llvm::Function::setSectionPrefix().

◆ createIrrLoopHeaderWeight()

MDNode * MDBuilder::createIrrLoopHeaderWeight ( uint64_t  Weight)

Return metadata containing an irreducible loop header weight.

Definition at line 305 of file MDBuilder.cpp.

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

Referenced by llvm::MDBuilder::TBAAStructField::TBAAStructField().

◆ createMisExpect()

MDNode * MDBuilder::createMisExpect ( uint64_t  Index,
uint64_t  LikelyWeight,
uint64_t  UnlikelyWeight 
)

return metadata containing expected value

Definition at line 313 of file MDBuilder.cpp.

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

Referenced by MDBuilder().

◆ createMutableTBAAAccessTag()

MDNode * MDBuilder::createMutableTBAAAccessTag ( MDNode Tag)

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

Definition at line 278 of file MDBuilder.cpp.

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

Referenced by stripNonValidDataFromBody(), and llvm::MDBuilder::TBAAStructField::TBAAStructField().

◆ createRange() [1/2]

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

Return metadata describing the range [Lo, Hi).

Definition at line 84 of file MDBuilder.cpp.

References assert(), createRange(), llvm::IntegerType::get(), llvm::ConstantInt::get(), and llvm::APInt::getBitWidth().

Referenced by createRange(), and MDBuilder().

◆ createRange() [2/2]

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

Return metadata describing the range [Lo, Hi).

Definition at line 91 of file MDBuilder.cpp.

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

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

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

Referenced by createMutableTBAAAccessTag(), and llvm::MDBuilder::TBAAStructField::TBAAStructField().

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

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

Referenced by createAnonymousAliasScope().

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

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

Referenced by createAnonymousAliasScope().

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

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

Referenced by llvm::MDBuilder::TBAAStructField::TBAAStructField().

◆ createTBAAStructNode()

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

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

Definition at line 201 of file MDBuilder.cpp.

References createConstant(), llvm::numbers::e, llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), Size, and llvm::ArrayRef< T >::size().

Referenced by llvm::MDBuilder::TBAAStructField::TBAAStructField().

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

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

Referenced by createMutableTBAAAccessTag(), and llvm::MDBuilder::TBAAStructField::TBAAStructField().

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

References createConstant(), createString(), llvm::numbers::e, llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), and second.

Referenced by llvm::MDBuilder::TBAAStructField::TBAAStructField().

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

References createConstant(), E, llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::Type::getInt64Ty(), I, and llvm::ArrayRef< T >::size().

Referenced by llvm::MDBuilder::TBAAStructField::TBAAStructField().

◆ createUnpredictable()

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.

Referenced by MDBuilder().

◆ mergeCallbackEncodings()

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

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

Referenced by MDBuilder().


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