LLVM  mainline
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
llvm::MDNode Class Reference

Metadata node. More...

#include <Metadata.h>

Inheritance diagram for llvm::MDNode:
Inheritance graph
[legend]
Collaboration diagram for llvm::MDNode:
Collaboration graph
[legend]

List of all members.

Classes

struct  HasCachedHash

Public Types

typedef const MDOperandop_iterator
typedef iterator_range
< op_iterator
op_range

Public Member Functions

TempMDNode clone () const
 Create a (temporary) clone of this.
LLVMContextgetContext () const
void replaceOperandWith (unsigned I, Metadata *New)
 Replace a specific operand.
bool isResolved () const
 Check if node is fully resolved.
bool isUniqued () const
bool isDistinct () const
bool isTemporary () const
void replaceAllUsesWith (Metadata *MD)
 RAUW a temporary.
void resolveCycles ()
 Resolve cycles.
op_iterator op_begin () const
op_iterator op_end () const
op_range operands () const
const MDOperandgetOperand (unsigned I) const
unsigned getNumOperands () const
 Return number of MDNode operands.
bool isTBAAVtableAccess () const
 Check whether MDNode is a vtable access.

Static Public Member Functions

static MDTupleget (LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDTuplegetIfExists (LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDTuplegetDistinct (LLVMContext &Context, ArrayRef< Metadata * > MDs)
static TempMDTuple getTemporary (LLVMContext &Context, ArrayRef< Metadata * > MDs)
static void deleteTemporary (MDNode *N)
 Deallocate a node created by getTemporary.
template<class T >
static std::enable_if
< std::is_base_of< MDNode, T >
::value, T * >::type 
replaceWithPermanent (std::unique_ptr< T, TempMDNodeDeleter > N)
 Replace a temporary node with a permanent one.
template<class T >
static std::enable_if
< std::is_base_of< MDNode, T >
::value, T * >::type 
replaceWithUniqued (std::unique_ptr< T, TempMDNodeDeleter > N)
 Replace a temporary node with a uniqued one.
template<class T >
static std::enable_if
< std::is_base_of< MDNode, T >
::value, T * >::type 
replaceWithDistinct (std::unique_ptr< T, TempMDNodeDeleter > N)
 Replace a temporary node with a distinct one.
static bool classof (const Metadata *MD)
 Methods for support type inquiry through isa, cast, and dyn_cast:
static MDNodeconcatenate (MDNode *A, MDNode *B)
 Methods for metadata merging.
static MDNodeintersect (MDNode *A, MDNode *B)
static MDNodegetMostGenericTBAA (MDNode *A, MDNode *B)
static MDNodegetMostGenericFPMath (MDNode *A, MDNode *B)
static MDNodegetMostGenericRange (MDNode *A, MDNode *B)
static MDNodegetMostGenericAliasScope (MDNode *A, MDNode *B)

Protected Types

typedef iterator_range
< MDOperand * > 
mutable_op_range

Protected Member Functions

void * operator new (size_t Size, unsigned NumOps)
void operator delete (void *Mem)
void operator delete (void *, unsigned)
 Required by std, but never called.
void operator delete (void *, unsigned, bool)
 Required by std, but never called.
 MDNode (LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2=None)
 ~MDNode ()
void dropAllReferences ()
MDOperandmutable_begin ()
MDOperandmutable_end ()
mutable_op_range mutable_operands ()
void setOperand (unsigned I, Metadata *New)
 Set an operand.
void storeDistinctInContext ()

Static Protected Member Functions

template<class T , class StoreT >
static TstoreImpl (T *N, StorageType Storage, StoreT &Store)

Protected Attributes

ContextAndReplaceableUses Context

Friends

class ReplaceableMetadataImpl
class LLVMContextImpl

Detailed Description

Metadata node.

Metadata nodes can be uniqued, like constants, or distinct. Temporary metadata nodes (with full support for RAUW) can be used to delay uniquing until forward references are known. The basic metadata node is an MDTuple.

There is limited support for RAUW at construction time. At construction time, if any operand is a temporary node (or an unresolved uniqued node, which indicates a transitive temporary operand), the node itself will be unresolved. As soon as all operands become resolved, it will drop RAUW support permanently.

If an unresolved node is part of a cycle, resolveCycles() needs to be called on some member of the cycle once all temporary nodes have been replaced.

Definition at line 728 of file Metadata.h.


Member Typedef Documentation

Definition at line 764 of file Metadata.h.

Definition at line 913 of file Metadata.h.

Definition at line 914 of file Metadata.h.


Constructor & Destructor Documentation

MDNode::MDNode ( LLVMContext Context,
unsigned  ID,
StorageType  Storage,
ArrayRef< Metadata * >  Ops1,
ArrayRef< Metadata * >  Ops2 = None 
) [protected]

Definition at line 400 of file Metadata.cpp.

References isDistinct(), isUniqued(), and setOperand().

llvm::MDNode::~MDNode ( ) [protected]

Member Function Documentation

static bool llvm::MDNode::classof ( const Metadata MD) [inline, static]
TempMDNode MDNode::clone ( ) const
MDNode * MDNode::concatenate ( MDNode A,
MDNode B 
) [static]
void MDNode::deleteTemporary ( MDNode N) [static]

Deallocate a node created by getTemporary.

Calls replaceAllUsesWith(nullptr) before deleting, so any remaining references will be reset.

Definition at line 702 of file Metadata.cpp.

References isTemporary(), and replaceAllUsesWith().

Referenced by llvm::TempMDNodeDeleter::operator()().

void MDNode::dropAllReferences ( ) [protected]

Definition at line 562 of file Metadata.cpp.

References I, isResolved(), and setOperand().

MDTuple * llvm::MDNode::get ( LLVMContext Context,
ArrayRef< Metadata * >  MDs 
) [inline, static]

Reimplemented in llvm::MDTuple.

Definition at line 1018 of file Metadata.h.

Referenced by AddAliasScopeMetadata(), llvm::Module::addModuleFlag(), canonicalizeMetadataForValue(), CloneAliasScopeMetadata(), CloneLoopBlocks(), llvm::DwarfCompileUnit::constructImportedEntityDIE(), llvm::MDBuilder::createAliasScope(), llvm::MDBuilder::createAliasScopeDomain(), llvm::MDBuilder::createAnonymousAARoot(), llvm::DIBuilder::createArrayType(), llvm::DIBuilder::createBasicType(), llvm::DIBuilder::createBitPieceExpression(), llvm::MDBuilder::createBranchWeights(), llvm::DIBuilder::createClassType(), llvm::DIBuilder::createCompileUnit(), llvm::DIBuilder::createEnumerationType(), llvm::DIBuilder::createEnumerator(), llvm::DIBuilder::createExpression(), llvm::DIBuilder::createFile(), llvm::DIBuilder::createForwardDecl(), llvm::MDBuilder::createFPMath(), llvm::DIBuilder::createFriend(), llvm::DIBuilder::createFunction(), llvm::MDBuilder::createFunctionEntryCount(), llvm::DIBuilder::createGlobalVariable(), createImportedModule(), llvm::DIBuilder::createInheritance(), llvm::DIBuilder::createLexicalBlockFile(), llvm::DIBuilder::createLocalVariable(), llvm::DIBuilder::createMemberPointerType(), llvm::DIBuilder::createMemberType(), llvm::DIBuilder::createMethod(), llvm::DIBuilder::createNameSpace(), llvm::DIBuilder::createObjCIVar(), llvm::DIBuilder::createObjCProperty(), llvm::DIBuilder::createPointerType(), llvm::DIBuilder::createQualifiedType(), llvm::MDBuilder::createRange(), llvm::DIBuilder::createReferenceType(), llvm::DIBuilder::createStaticMemberType(), llvm::DIBuilder::createStructType(), llvm::DIBuilder::createSubroutineType(), llvm::MDBuilder::createTBAANode(), llvm::MDBuilder::createTBAARoot(), llvm::MDBuilder::createTBAAScalarTypeNode(), llvm::MDBuilder::createTBAAStructNode(), llvm::MDBuilder::createTBAAStructTagNode(), llvm::MDBuilder::createTBAAStructTypeNode(), llvm::DIBuilder::createTemplateParameterPack(), llvm::DIBuilder::createTemplateTypeParameter(), createTemplateValueParameterHelper(), llvm::DIBuilder::createTypedef(), llvm::DIBuilder::createUnionType(), llvm::DIBuilder::createUnspecifiedType(), llvm::DIBuilder::createVectorType(), llvm::SystemZFrameLowering::emitPrologue(), extractMDNode(), findBasePointer(), llvm::DINode::getCanonicalMDString(), getMostGenericRange(), getMostGenericTBAA(), llvm::DIBuilder::getOrCreateSubrange(), llvm::DIBuilder::getOrCreateTypeArray(), getOrSelfReference(), llvm::DINode::getRef(), llvm::DIScope::getRef(), llvm::DIType::getRef(), LLVMMDNodeInContext(), mapUniquedNode(), llvm::DIBuilder::replaceTemporary(), SetLoopAlreadyUnrolled(), llvm::BranchInst::swapSuccessors(), llvm::UpgradeIntrinsicCall(), llvm::InstCombiner::visitCallInst(), and WriteDISubprogram().

MDTuple * llvm::MDNode::getDistinct ( LLVMContext Context,
ArrayRef< Metadata * >  MDs 
) [inline, static]

Reimplemented in llvm::MDTuple.

Definition at line 1024 of file Metadata.h.

Referenced by llvm::DIBuilder::createLexicalBlock(), fixupLineNumbers(), and updateInlinedAtInfo().

MDTuple * llvm::MDNode::getIfExists ( LLVMContext Context,
ArrayRef< Metadata * >  MDs 
) [inline, static]

Reimplemented in llvm::MDTuple.

Definition at line 1021 of file Metadata.h.

MDNode * MDNode::getMostGenericAliasScope ( MDNode A,
MDNode B 
) [static]
MDNode * MDNode::getMostGenericFPMath ( MDNode A,
MDNode B 
) [static]

Definition at line 809 of file Metadata.cpp.

References llvm::APFloat::cmpLessThan, llvm::APFloat::compare(), and getOperand().

Referenced by llvm::combineMetadata().

MDNode * MDNode::getMostGenericRange ( MDNode A,
MDNode B 
) [static]
MDNode * MDNode::getMostGenericTBAA ( MDNode A,
MDNode B 
) [static]

Definition at line 924 of file Metadata.h.

References I, and op_begin().

Referenced by llvm::Module::addModuleFlag(), cacheAnnotationFromMD(), CloneAliasScopeMetadata(), CloneLoopBlocks(), llvm::computeKnownBitsFromRangeMetadata(), llvm::ConstantFoldTerminator(), llvm::SystemZFrameLowering::emitEpilogue(), llvm::MachineInstr::emitError(), llvm::TargetLoweringObjectFileMachO::emitModuleFlags(), llvm::TargetLoweringObjectFileCOFF::emitModuleFlags(), llvm::HexagonInstrInfo::expandPostRAPseudo(), GetBranchWeights(), llvm::GenericDINode::getDwarfOperand(), llvm::Function::getEntryCount(), llvm::FPMathOperator::getFPAccuracy(), llvm::Loop::getLoopID(), getMDNodeOperandImpl(), getMostGenericFPMath(), getMostGenericRange(), getMostGenericTBAA(), llvm::DINode::getOperandAs(), llvm::DIDerivedTypeBase::getRawBaseType(), llvm::DICompositeTypeBase::getRawElements(), llvm::DIImportedEntity::getRawEntity(), llvm::DICompileUnit::getRawEnumTypes(), llvm::DIScope::getRawFile(), llvm::DIVariable::getRawFile(), llvm::DIObjCProperty::getRawFile(), llvm::DICompileUnit::getRawGlobalVariables(), llvm::DICompileUnit::getRawImportedEntities(), llvm::DILocation::getRawInlinedAt(), llvm::DICompileUnit::getRawRetainedTypes(), llvm::DIType::getRawScope(), llvm::DILocation::getRawScope(), llvm::DILexicalBlockBase::getRawScope(), llvm::DINamespace::getRawScope(), llvm::DIVariable::getRawScope(), llvm::DIImportedEntity::getRawScope(), llvm::DIGlobalVariable::getRawStaticDataMemberDeclaration(), llvm::DICompileUnit::getRawSubprograms(), llvm::DICompositeTypeBase::getRawTemplateParams(), llvm::DITemplateParameter::getRawType(), llvm::DIVariable::getRawType(), llvm::DIObjCProperty::getRawType(), llvm::DIGlobalVariable::getRawVariable(), llvm::DICompositeTypeBase::getRawVTableHolder(), llvm::GetUnrollMetadata(), llvm::DITemplateValueParameter::getValue(), HasBranchWeights(), llvm::Loop::isAnnotatedParallel(), isStructPathTBAA(), isTBAAVtableAccess(), llvm::DITypeRefArray::operator[](), rangeMetadataExcludesValue(), remap(), replaceOperandWith(), SetLoopAlreadyUnrolled(), llvm::Loop::setLoopID(), UnrollCountPragmaValue(), llvm::UpgradeInstWithTBAATag(), and WriteMDTuple().

TempMDTuple llvm::MDNode::getTemporary ( LLVMContext Context,
ArrayRef< Metadata * >  MDs 
) [inline, static]
MDNode * MDNode::intersect ( MDNode A,
MDNode B 
) [static]
bool llvm::MDNode::isDistinct ( ) const [inline]
bool llvm::MDNode::isResolved ( ) const [inline]

Check if node is fully resolved.

If isTemporary(), this always returns false; if isDistinct(), this always returns true.

If isUniqued(), returns true if this has already dropped RAUW support (because all operands are resolved).

As forward declarations are resolved, their containers should get resolved automatically. However, if this (or one of its operands) is involved in a cycle, resolveCycles() needs to be called explicitly.

Definition at line 803 of file Metadata.h.

References Context, and llvm::ContextAndReplaceableUses::hasReplaceableUses().

Referenced by dropAllReferences(), llvm::DIBuilder::finalize(), llvm::LexicalScope::LexicalScope(), mapDistinctNode(), MapMetadataImpl(), remap(), replaceAllUsesWith(), llvm::DIBuilder::replaceArrays(), llvm::DIBuilder::replaceVTableHolder(), resolveCycles(), and storeDistinctInContext().

Check whether MDNode is a vtable access.

Definition at line 547 of file TypeBasedAliasAnalysis.cpp.

References getNumOperands(), getOperand(), and isStructPathTBAA().

bool llvm::MDNode::isTemporary ( ) const [inline]

Definition at line 807 of file Metadata.h.

References llvm::Metadata::Storage, and llvm::Metadata::Temporary.

Referenced by deleteTemporary(), and replaceAllUsesWith().

bool llvm::MDNode::isUniqued ( ) const [inline]
MDOperand* llvm::MDNode::mutable_begin ( ) [inline, protected]

Definition at line 761 of file Metadata.h.

References mutable_end().

Referenced by mutable_operands(), op_begin(), replaceOperandWith(), and setOperand().

MDOperand* llvm::MDNode::mutable_end ( ) [inline, protected]

Definition at line 762 of file Metadata.h.

Referenced by mutable_begin(), mutable_operands(), and op_end().

Definition at line 765 of file Metadata.h.

References mutable_begin(), and mutable_end().

op_iterator llvm::MDNode::op_begin ( ) const [inline]
op_iterator llvm::MDNode::op_end ( ) const [inline]
op_range llvm::MDNode::operands ( ) const [inline]
void MDNode::operator delete ( void *  Mem) [protected]

Definition at line 392 of file Metadata.cpp.

References N.

void llvm::MDNode::operator delete ( void *  ,
unsigned   
) [inline, protected]

Required by std, but never called.

Definition at line 746 of file Metadata.h.

References llvm_unreachable.

void llvm::MDNode::operator delete ( void *  ,
unsigned  ,
bool   
) [inline, protected]

Required by std, but never called.

Definition at line 751 of file Metadata.h.

References llvm_unreachable.

void * MDNode::operator new ( size_t  Size,
unsigned  NumOps 
) [protected]

Definition at line 384 of file Metadata.cpp.

void llvm::MDNode::replaceAllUsesWith ( Metadata MD) [inline]
void MDNode::replaceOperandWith ( unsigned  I,
Metadata New 
)
template<class T >
static std::enable_if<std::is_base_of<MDNode, T>::value, T *>::type llvm::MDNode::replaceWithDistinct ( std::unique_ptr< T, TempMDNodeDeleter N) [inline, static]

Replace a temporary node with a distinct one.

Create a distinct version of N -- in place, if possible -- and return it. Takes ownership of the temporary node.

Definition at line 854 of file Metadata.h.

Referenced by mapDistinctNode().

template<class T >
static std::enable_if<std::is_base_of<MDNode, T>::value, T *>::type llvm::MDNode::replaceWithPermanent ( std::unique_ptr< T, TempMDNodeDeleter N) [inline, static]

Replace a temporary node with a permanent one.

Try to create a uniqued version of N -- in place, if possible -- and return it. If N cannot be uniqued, return a distinct node instead.

Definition at line 832 of file Metadata.h.

template<class T >
static std::enable_if<std::is_base_of<MDNode, T>::value, T *>::type llvm::MDNode::replaceWithUniqued ( std::unique_ptr< T, TempMDNodeDeleter N) [inline, static]

Replace a temporary node with a uniqued one.

Create a uniqued version of N -- in place, if possible -- and return it. Takes ownership of the temporary node.

Precondition:
N does not self-reference.

Definition at line 844 of file Metadata.h.

Referenced by createTypeWithFlags(), mapUniquedNode(), and llvm::DIBuilder::replaceTemporary().

Resolve cycles.

Once all forward declarations have been resolved, force cycles to be resolved.

Precondition:
No operands (or operands' operands, etc.) have isTemporary().

Definition at line 505 of file Metadata.cpp.

References isResolved(), N, and operands().

Referenced by llvm::DIBuilder::finalize().

void MDNode::setOperand ( unsigned  I,
Metadata New 
) [protected]

Set an operand.

Sets the operand directly, without worrying about uniquing.

Definition at line 740 of file Metadata.cpp.

References I, isUniqued(), mutable_begin(), and llvm::MDOperand::reset().

Referenced by dropAllReferences(), MDNode(), and replaceOperandWith().

void MDNode::storeDistinctInContext ( ) [protected]
template<class T , class StoreT >
T * llvm::MDNode::storeImpl ( T N,
StorageType  Storage,
StoreT &  Store 
) [static, protected]

Friends And Related Function Documentation

friend class LLVMContextImpl [friend]
friend class ReplaceableMetadataImpl [friend]

Reimplemented from llvm::Metadata.

Definition at line 729 of file Metadata.h.


Member Data Documentation

Definition at line 740 of file Metadata.h.

Referenced by llvm::MDTuple::get(), getContext(), isResolved(), and replaceAllUsesWith().


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