LLVM  4.0.0
Classes | Macros | Functions
Metadata.cpp File Reference
#include "llvm/IR/Metadata.h"
#include "LLVMContextImpl.h"
#include "MetadataImpl.h"
#include "SymbolTableListTraitsImpl.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/IR/Metadata.def"
Include dependency graph for Metadata.cpp:

Go to the source code of this file.

Classes

struct  llvm::MDNode::HasCachedHash< NodeTy >
 
struct  llvm::MDNode::HasCachedHash< NodeTy >::SFINAE< U, Val >
 

Macros

#define HANDLE_METADATA_LEAF(CLASS)
 
#define HANDLE_MDNODE_LEAF(CLASS)
 
#define HANDLE_MDNODE_LEAF(CLASS)
 
#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS)
 
#define HANDLE_MDNODE_LEAF(CLASS)
 
#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS)
 
#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS)
 
#define HANDLE_MDNODE_LEAF(CLASS)
 

Functions

static MetadatacanonicalizeMetadataForValue (LLVMContext &Context, Metadata *MD)
 Canonicalize metadata arguments to intrinsics. More...
 
static FunctiongetLocalFunction (Value *V)
 
static bool isOperandUnresolved (Metadata *Op)
 
static bool hasSelfReference (MDNode *N)
 
template<class T , class InfoT >
static TuniquifyImpl (T *N, DenseSet< T *, InfoT > &Store)
 
static MDNodegetOrSelfReference (LLVMContext &Context, ArrayRef< Metadata * > Ops)
 Get a node or a self-reference that looks like it. More...
 
static bool isContiguous (const ConstantRange &A, const ConstantRange &B)
 
static bool canBeMerged (const ConstantRange &A, const ConstantRange &B)
 
static bool tryMergeRange (SmallVectorImpl< ConstantInt * > &EndPoints, ConstantInt *Low, ConstantInt *High)
 
static void addRange (SmallVectorImpl< ConstantInt * > &EndPoints, ConstantInt *Low, ConstantInt *High)
 
static SmallVector
< TrackingMDRef, 4 > & 
getNMDOps (void *Operands)
 

Macro Definition Documentation

#define HANDLE_MDNODE_LEAF (   CLASS)
Value:
static_assert( \
alignof(uint64_t) >= alignof(CLASS), \
"Alignment is insufficient after objects prepended to " #CLASS);

Definition at line 435 of file Metadata.cpp.

#define HANDLE_MDNODE_LEAF (   CLASS)
Value:
case CLASS##Kind: \
return cast<CLASS>(this)->cloneImpl();
const unsigned Kind

Definition at line 435 of file Metadata.cpp.

#define HANDLE_MDNODE_LEAF (   CLASS)
Value:
case CLASS##Kind: \
delete cast<CLASS>(this); \
break;
const unsigned Kind

Definition at line 435 of file Metadata.cpp.

#define HANDLE_MDNODE_LEAF (   CLASS)
Value:
case CLASS##Kind: { \
std::integral_constant<bool, HasCachedHash<CLASS>::value> ShouldResetHash; \
dispatchResetHash(cast<CLASS>(this), ShouldResetHash); \
break; \
}
const unsigned Kind

Definition at line 435 of file Metadata.cpp.

#define HANDLE_MDNODE_LEAF_UNIQUABLE (   CLASS)
Value:
case CLASS##Kind: \
break;
const unsigned Kind
#define HANDLE_MDNODE_LEAF_UNIQUABLE (   CLASS)
Value:
case CLASS##Kind: { \
CLASS *SubclassThis = cast<CLASS>(this); \
std::integral_constant<bool, HasCachedHash<CLASS>::value> \
ShouldRecalculateHash; \
dispatchRecalculateHash(SubclassThis, ShouldRecalculateHash); \
return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \
}
static T * uniquifyImpl(T *N, DenseSet< T *, InfoT > &Store)
Definition: Metadata.cpp:722
const unsigned Kind
#define HANDLE_MDNODE_LEAF_UNIQUABLE (   CLASS)
Value:
case CLASS##Kind: \
getContext().pImpl->CLASS##s.erase(cast<CLASS>(this)); \
break;
const unsigned Kind
#define HANDLE_METADATA_LEAF (   CLASS)
Value:
case Metadata::CLASS##Kind: \
cast<CLASS>(OwnerMD)->handleChangedOperand(Pair.first, MD); \
continue;
const unsigned Kind

Function Documentation

static void addRange ( SmallVectorImpl< ConstantInt * > &  EndPoints,
ConstantInt Low,
ConstantInt High 
)
static
static bool canBeMerged ( const ConstantRange A,
const ConstantRange B 
)
static
static Metadata* canonicalizeMetadataForValue ( LLVMContext Context,
Metadata MD 
)
static

Canonicalize metadata arguments to intrinsics.

To support bitcode upgrades (and assembly semantic sugar) for MetadataAsValue, we need to canonicalize certain metadata.

  • nullptr is replaced by an empty MDNode.
  • An MDNode with a single null operand is replaced by an empty MDNode.
  • An MDNode whose only operand is a ConstantAsMetadata gets skipped.

This maintains readability of bitcode from when metadata was a type of value, and these bridges were unnecessary.

Definition at line 52 of file Metadata.cpp.

References C, llvm::dyn_cast(), llvm::MDNode::get(), N, and llvm::None.

Referenced by llvm::MetadataAsValue::get(), and llvm::MetadataAsValue::getIfExists().

static Function* getLocalFunction ( Value V)
static

Definition at line 300 of file Metadata.cpp.

References A, assert(), and getParent().

Referenced by llvm::ValueAsMetadata::handleRAUW().

static SmallVector<TrackingMDRef, 4>& getNMDOps ( void *  Operands)
static
static MDNode* getOrSelfReference ( LLVMContext Context,
ArrayRef< Metadata * >  Ops 
)
static

Get a node or a self-reference that looks like it.

Special handling for finding self-references, for use by MDNode::concatenate() and MDNode::intersect() to maintain behaviour from when self-referencing nodes were still uniqued. If the first operand has the same operands as Ops, return the first operand instead.

Definition at line 842 of file Metadata.cpp.

References E, llvm::ArrayRef< T >::empty(), llvm::MDNode::get(), I, N, and llvm::ArrayRef< T >::size().

Referenced by llvm::MDNode::concatenate(), and llvm::MDNode::intersect().

static bool hasSelfReference ( MDNode N)
static

Definition at line 601 of file Metadata.cpp.

References llvm::MDNode::operands().

static bool isContiguous ( const ConstantRange A,
const ConstantRange B 
)
static

Definition at line 901 of file Metadata.cpp.

References llvm::ConstantRange::getLower(), and llvm::ConstantRange::getUpper().

Referenced by canBeMerged().

static bool isOperandUnresolved ( Metadata Op)
static

Definition at line 493 of file Metadata.cpp.

References N.

static bool tryMergeRange ( SmallVectorImpl< ConstantInt * > &  EndPoints,
ConstantInt Low,
ConstantInt High 
)
static
template<class T , class InfoT >
static T* uniquifyImpl ( T N,
DenseSet< T *, InfoT > &  Store 
)
static