LLVM 22.0.0git
Metadata.cpp File Reference
#include "llvm/IR/Metadata.h"
#include "LLVMContextImpl.h"
#include "MetadataImpl.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/ConstantRangeList.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DebugProgramInstruction.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/IR/TrackingMDRef.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <utility>
#include <vector>
#include "llvm/IR/Metadata.def"

Go to the source code of this file.

Classes

struct  llvm::MDNode::HasCachedHash< NodeTy >

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.
static DISubprogramgetLocalFunctionMetadata (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.
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

◆ HANDLE_MDNODE_LEAF [1/4]

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

Definition at line 628 of file Metadata.cpp.

◆ HANDLE_MDNODE_LEAF [2/4]

#define HANDLE_MDNODE_LEAF ( CLASS)
Value:
case CLASS##Kind: \
return cast<CLASS>(this)->cloneImpl();
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:565

Definition at line 628 of file Metadata.cpp.

◆ HANDLE_MDNODE_LEAF [3/4]

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

Definition at line 628 of file Metadata.cpp.

◆ HANDLE_MDNODE_LEAF [4/4]

#define HANDLE_MDNODE_LEAF ( CLASS)
Value:
case CLASS##Kind: { \
dispatchResetHash(cast<CLASS>(this)); \
break; \
}

Definition at line 628 of file Metadata.cpp.

◆ HANDLE_MDNODE_LEAF_UNIQUABLE [1/3]

#define HANDLE_MDNODE_LEAF_UNIQUABLE ( CLASS)
Value:
case CLASS##Kind: \
break;

◆ HANDLE_MDNODE_LEAF_UNIQUABLE [2/3]

#define HANDLE_MDNODE_LEAF_UNIQUABLE ( CLASS)
Value:
case CLASS##Kind: { \
CLASS *SubclassThis = cast<CLASS>(this); \
dispatchRecalculateHash(SubclassThis); \
return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \
}
static T * uniquifyImpl(T *N, DenseSet< T *, InfoT > &Store)
Definition Metadata.cpp:980

◆ HANDLE_MDNODE_LEAF_UNIQUABLE [3/3]

#define HANDLE_MDNODE_LEAF_UNIQUABLE ( CLASS)
Value:
case CLASS##Kind: \
getContext().pImpl->CLASS##s.erase(cast<CLASS>(this)); \
break;

◆ HANDLE_METADATA_LEAF

#define HANDLE_METADATA_LEAF ( CLASS)
Value:
case Metadata::CLASS##Kind: \
cast<CLASS>(OwnerMD)->handleChangedOperand(Pair.first, MD); \
continue;

Function Documentation

◆ addRange()

◆ canBeMerged()

bool canBeMerged ( const ConstantRange & A,
const ConstantRange & B )
static

Definition at line 1266 of file Metadata.cpp.

References A(), B(), and isContiguous().

Referenced by tryMergeRange().

◆ canonicalizeMetadataForValue()

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.

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

Definition at line 81 of file Metadata.cpp.

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

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

◆ getLocalFunctionMetadata()

DISubprogram * getLocalFunctionMetadata ( Value * V)
static

Definition at line 485 of file Metadata.cpp.

References A(), assert(), llvm::cast(), llvm::dyn_cast(), and getParent().

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

◆ getNMDOps()

◆ getOrSelfReference()

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 1094 of file Metadata.cpp.

References AbstractManglingParser< Derived, Alloc >::Ops, llvm::dyn_cast_or_null(), E(), llvm::MDNode::get(), I, and N.

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

◆ hasSelfReference()

bool hasSelfReference ( MDNode * N)
static

Definition at line 862 of file Metadata.cpp.

References llvm::is_contained(), and N.

◆ isContiguous()

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

Definition at line 1262 of file Metadata.cpp.

References A(), and B().

Referenced by canBeMerged().

◆ isOperandUnresolved()

bool isOperandUnresolved ( Metadata * Op)
static

Definition at line 753 of file Metadata.cpp.

References llvm::dyn_cast_or_null(), and N.

◆ tryMergeRange()

◆ uniquifyImpl()

template<class T, class InfoT>
T * uniquifyImpl ( T * N,
DenseSet< T *, InfoT > & Store )
static

Definition at line 980 of file Metadata.cpp.

References llvm::getUniqued(), N, and T.