LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
llvm::DILocation Class Reference

Debug location. More...

#include "llvm/IR/DebugInfoMetadata.h"

Inheritance diagram for llvm::DILocation:
Inheritance graph
[legend]

Public Member Functions

void replaceOperandWith (unsigned I, Metadata *New)=delete
 
 DEFINE_MDNODE_GET (DILocation,(unsigned Line, unsigned Column, Metadata *Scope, Metadata *InlinedAt=nullptr, bool ImplicitCode=false),(Line, Column, Scope, InlinedAt, ImplicitCode)) DEFINE_MDNODE_GET(DILocation
 
const DILocationcloneWithDiscriminator (unsigned Discriminator) const
 Returns a new DILocation with updated Discriminator.
 
std::optional< const DILocation * > cloneWithBaseDiscriminator (unsigned BD) const
 Returns a new DILocation with updated base discriminator BD.
 
unsigned getDuplicationFactor () const
 Returns the duplication factor stored in the discriminator, or 1 if no duplication factor (or 0) is encoded.
 
unsigned getCopyIdentifier () const
 Returns the copy identifier stored in the discriminator.
 
unsigned getBaseDiscriminator () const
 Returns the base discriminator stored in the discriminator.
 
std::optional< const DILocation * > cloneByMultiplyingDuplicationFactor (unsigned DF) const
 Returns a new DILocation with duplication factor DF * current duplication factor encoded in the discriminator.
 
MetadatagetRawScope () const
 
MetadatagetRawInlinedAt () const
 
- Public Member Functions inherited from llvm::MDNode
 MDNode (const MDNode &)=delete
 
void operator= (const MDNode &)=delete
 
void * operator new (size_t)=delete
 
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
 
bool isReplaceable () const
 
bool isAlwaysReplaceable () const
 
unsigned getNumTemporaryUses () const
 
void replaceAllUsesWith (Metadata *MD)
 RAUW a temporary.
 
void resolveCycles ()
 Resolve cycles.
 
void resolve ()
 Resolve a unique, unresolved node.
 
op_iterator op_begin () const
 
op_iterator op_end () const
 
ArrayRef< MDOperandoperands () const
 
const MDOperandgetOperand (unsigned I) const
 
unsigned getNumOperands () const
 Return number of MDNode operands.
 
bool isTBAAVtableAccess () const
 Check whether MDNode is a vtable access.
 
void printTree (raw_ostream &OS, const Module *M=nullptr) const
 Print in tree shape.
 
void printTree (raw_ostream &OS, ModuleSlotTracker &MST, const Module *M=nullptr) const
 
void dumpTree () const
 User-friendly dump in tree shape.
 
void dumpTree (const Module *M) const
 

Static Public Member Functions

static bool isPseudoProbeDiscriminator (unsigned Discriminator)
 
static DILocationgetMergedLocation (DILocation *LocA, DILocation *LocB)
 When two instructions are combined into a single instruction we also need to combine the original locations into a single location.
 
static DILocationgetMergedLocations (ArrayRef< DILocation * > Locs)
 Try to combine the vector of locations passed as input in a single one.
 
static unsigned getMaskedDiscriminator (unsigned D, unsigned B)
 Return the masked discriminator value for an input discrimnator value D (i.e.
 
static unsigned getBaseDiscriminatorBits ()
 Return the bits used for base discriminators.
 
static unsigned getBaseDiscriminatorFromDiscriminator (unsigned D, bool IsFSDiscriminator=false)
 Returns the base discriminator for a given encoded discriminator D.
 
static std::optional< unsignedencodeDiscriminator (unsigned BD, unsigned DF, unsigned CI)
 Raw encoding of the discriminator.
 
static void decodeDiscriminator (unsigned D, unsigned &BD, unsigned &DF, unsigned &CI)
 Raw decoder for values in an encoded discriminator D.
 
static unsigned getDuplicationFactorFromDiscriminator (unsigned D)
 Returns the duplication factor for a given encoded discriminator D, or 1 if no value or 0 is encoded.
 
static unsigned getCopyIdentifierFromDiscriminator (unsigned D)
 Returns the copy identifier for a given encoded discriminator D.
 
static bool classof (const Metadata *MD)
 
- Static Public Member Functions inherited from llvm::MDNode
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_t< std::is_base_of< MDNode, T >::value, T * > replaceWithPermanent (std::unique_ptr< T, TempMDNodeDeleter > N)
 Replace a temporary node with a permanent one.
 
template<class T >
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithUniqued (std::unique_ptr< T, TempMDNodeDeleter > N)
 Replace a temporary node with a uniqued one.
 
template<class T >
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > 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 MDNodegetMostGenericNoaliasAddrspace (MDNode *A, MDNode *B)
 
static MDNodegetMostGenericAliasScope (MDNode *A, MDNode *B)
 
static MDNodegetMostGenericAlignmentOrDereferenceable (MDNode *A, MDNode *B)
 
static MDNodegetMergedProfMetadata (MDNode *A, MDNode *B, const Instruction *AInstr, const Instruction *BInstr)
 Merge !prof metadata from two instructions.
 

Public Attributes

unsigned Line
 
unsigned unsigned Column
 
unsigned unsigned DILocalScopeScope
 
unsigned unsigned DILocalScope DILocationInlinedAt = nullptr
 
unsigned unsigned DILocalScope DILocation bool ImplicitCode
 

Friends

class LLVMContextImpl
 
class MDNode
 

Additional Inherited Members

- Public Types inherited from llvm::MDNode
using op_iterator = const MDOperand *
 
using op_range = iterator_range< op_iterator >
 
- Protected Types inherited from llvm::MDNode
using mutable_op_range = iterator_range< MDOperand * >
 
 Active type of storage. More...
- Protected Member Functions inherited from llvm::MDNode
 MDNode (LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2={})
 
 ~MDNode ()=default
 
void * operator new (size_t Size, size_t NumOps, StorageType Storage)
 
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.
 
void dropAllReferences ()
 
MDOperandmutable_begin ()
 
MDOperandmutable_end ()
 
mutable_op_range mutable_operands ()
 
void setOperand (unsigned I, Metadata *New)
 Set an operand.
 
unsigned getNumUnresolved () const
 
void setNumUnresolved (unsigned N)
 
void storeDistinctInContext ()
 
void resize (size_t NumOps)
 Resize the node to hold NumOps operands.
 
- Static Protected Member Functions inherited from llvm::MDNode
template<class T , class StoreT >
static TstoreImpl (T *N, StorageType Storage, StoreT &Store)
 
template<class T >
static TstoreImpl (T *N, StorageType Storage)
 

Detailed Description

Debug location.

A debug location in source code, used for debug info and otherwise.

Uses the SubclassData1, SubclassData16 and SubclassData32 Metadata slots.

Definition at line 1988 of file DebugInfoMetadata.h.

Member Function Documentation

◆ classof()

static bool llvm::DILocation::classof ( const Metadata MD)
inlinestatic

Definition at line 2253 of file DebugInfoMetadata.h.

References llvm::Metadata::getMetadataID().

◆ cloneByMultiplyingDuplicationFactor()

std::optional< const DILocation * > llvm::DILocation::cloneByMultiplyingDuplicationFactor ( unsigned  DF) const
inline

Returns a new DILocation with duplication factor DF * current duplication factor encoded in the discriminator.

The current duplication factor is as defined by getDuplicationFactor(). Returns std::nullopt if encoding failed.

Definition at line 2439 of file DebugInfoMetadata.h.

References assert(), cloneWithDiscriminator(), D, DF, llvm::EnableFSDiscriminator, encodeDiscriminator(), getBaseDiscriminator(), getCopyIdentifier(), getDuplicationFactor(), and isPseudoProbeDiscriminator().

Referenced by llvm::VPTransformState::setDebugLocFrom().

◆ cloneWithBaseDiscriminator()

std::optional< const DILocation * > llvm::DILocation::cloneWithBaseDiscriminator ( unsigned  BD) const
inline

Returns a new DILocation with updated base discriminator BD.

Only the base discriminator is set in the new DILocation, the other encoded values are elided. If the discriminator cannot be encoded, the function returns std::nullopt.

Definition at line 2420 of file DebugInfoMetadata.h.

References cloneWithDiscriminator(), D, decodeDiscriminator(), DF, llvm::EnableFSDiscriminator, encodeDiscriminator(), and getBaseDiscriminator().

Referenced by addDiscriminators().

◆ cloneWithDiscriminator()

const DILocation * llvm::DILocation::cloneWithDiscriminator ( unsigned  Discriminator) const
inline

◆ decodeDiscriminator()

void DILocation::decodeDiscriminator ( unsigned  D,
unsigned BD,
unsigned DF,
unsigned CI 
)
static

Raw decoder for values in an encoded discriminator D.

Definition at line 281 of file DebugInfoMetadata.cpp.

References D, DF, getNextComponentInDiscriminator(), and getUnsignedFromPrefixEncoding().

Referenced by cloneWithBaseDiscriminator(), and encodeDiscriminator().

◆ DEFINE_MDNODE_GET()

llvm::DILocation::DEFINE_MDNODE_GET ( DILocation  ,
(unsigned Line, unsigned Column, Metadata *Scope, Metadata *InlinedAt=nullptr, bool ImplicitCode=false)  ,
(Line, Column, Scope, InlinedAt, ImplicitCode  
)

◆ encodeDiscriminator()

std::optional< unsigned > DILocation::encodeDiscriminator ( unsigned  BD,
unsigned  DF,
unsigned  CI 
)
static

Raw encoding of the discriminator.

APIs such as cloneWithDuplicationFactor have certain special case behavior (e.g. treating empty duplication factor as the value '1'). This API, in conjunction with cloneWithDiscriminator, may be used to encode the raw values provided.

BD: base discriminator DF: duplication factor CI: copy index

The return is std::nullopt if the values cannot be encoded in 32 bits - for example, values for BD or DF larger than 12 bits. Otherwise, the return is the encoded value.

Definition at line 248 of file DebugInfoMetadata.cpp.

References llvm::CallingConv::C, decodeDiscriminator(), DF, encodeComponent(), encodingBits(), and I.

Referenced by cloneByMultiplyingDuplicationFactor(), and cloneWithBaseDiscriminator().

◆ getBaseDiscriminator()

unsigned llvm::DILocation::getBaseDiscriminator ( ) const
inline

◆ getBaseDiscriminatorBits()

static unsigned llvm::DILocation::getBaseDiscriminatorBits ( )
inlinestatic

Return the bits used for base discriminators.

Definition at line 2182 of file DebugInfoMetadata.h.

References llvm::getBaseFSBitEnd().

Referenced by getBaseDiscriminatorFromDiscriminator().

◆ getBaseDiscriminatorFromDiscriminator()

static unsigned llvm::DILocation::getBaseDiscriminatorFromDiscriminator ( unsigned  D,
bool  IsFSDiscriminator = false 
)
inlinestatic

◆ getCopyIdentifier()

unsigned llvm::DILocation::getCopyIdentifier ( ) const
inline

Returns the copy identifier stored in the discriminator.

Definition at line 2415 of file DebugInfoMetadata.h.

References getCopyIdentifierFromDiscriminator().

Referenced by cloneByMultiplyingDuplicationFactor().

◆ getCopyIdentifierFromDiscriminator()

static unsigned llvm::DILocation::getCopyIdentifierFromDiscriminator ( unsigned  D)
inlinestatic

Returns the copy identifier for a given encoded discriminator D.

Definition at line 2241 of file DebugInfoMetadata.h.

References D, getNextComponentInDiscriminator(), and getUnsignedFromPrefixEncoding().

Referenced by getCopyIdentifier().

◆ getDuplicationFactor()

unsigned llvm::DILocation::getDuplicationFactor ( ) const
inline

Returns the duplication factor stored in the discriminator, or 1 if no duplication factor (or 0) is encoded.

Definition at line 2411 of file DebugInfoMetadata.h.

References getDuplicationFactorFromDiscriminator().

Referenced by cloneByMultiplyingDuplicationFactor().

◆ getDuplicationFactorFromDiscriminator()

static unsigned llvm::DILocation::getDuplicationFactorFromDiscriminator ( unsigned  D)
inlinestatic

Returns the duplication factor for a given encoded discriminator D, or 1 if no value or 0 is encoded.

Definition at line 2230 of file DebugInfoMetadata.h.

References D, llvm::EnableFSDiscriminator, getNextComponentInDiscriminator(), and getUnsignedFromPrefixEncoding().

Referenced by getDuplicationFactor().

◆ getMaskedDiscriminator()

static unsigned llvm::DILocation::getMaskedDiscriminator ( unsigned  D,
unsigned  B 
)
inlinestatic

Return the masked discriminator value for an input discrimnator value D (i.e.

zero out the (B+1)-th and above bits for D (B is 0-base).

Definition at line 2177 of file DebugInfoMetadata.h.

References B, D, and llvm::getN1Bits().

Referenced by getBaseDiscriminatorFromDiscriminator().

◆ getMergedLocation()

DILocation * DILocation::getMergedLocation ( DILocation LocA,
DILocation LocB 
)
static

When two instructions are combined into a single instruction we also need to combine the original locations into a single location.

When the locations are the same we can use either location. When they differ, we need a third location which is distinct from either. If they share a common scope, use this scope and compare the line/column pair of the locations with the common scope:

  • if both match, keep the line and column;
  • if only the line number matches, keep the line and set the column as 0;
  • otherwise set line and column as 0. If they do not share a common scope the location is ambiguous and can't be represented in a line entry. In this case, set line and column as 0 and use the scope of any location.

LocA LocB: The locations to be merged.

Definition at line 121 of file DebugInfoMetadata.cpp.

References assert(), llvm::CallingConv::C, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MDNode::get(), llvm::MDNode::getContext(), getSubprogram(), I, InlinedAt, IT, Line, S1, Scope, and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace().

Referenced by llvm::Instruction::applyMergedLocation(), combineFPFusedMultiply(), llvm::MachineBasicBlock::findBranchDebugLoc(), getMergedLocations(), mergeDILocations(), llvm::InstCombinerImpl::mergeStoreIntoSuccessor(), performBlockTailMerging(), performSink(), and llvm::LegalizationArtifactCombiner::tryCombineAnyExt().

◆ getMergedLocations()

DILocation * DILocation::getMergedLocations ( ArrayRef< DILocation * >  Locs)
static

Try to combine the vector of locations passed as input in a single one.

This function applies getMergedLocation() repeatedly left-to-right.

Locs: The locations to be merged.

Definition at line 107 of file DebugInfoMetadata.cpp.

References llvm::drop_begin(), llvm::ArrayRef< T >::empty(), getMergedLocation(), and llvm::ArrayRef< T >::size().

Referenced by llvm::promoteLoopAccessesToScalars().

◆ getRawInlinedAt()

Metadata * llvm::DILocation::getRawInlinedAt ( ) const
inline

◆ getRawScope()

Metadata * llvm::DILocation::getRawScope ( ) const
inline

Definition at line 2246 of file DebugInfoMetadata.h.

References llvm::MDNode::getOperand().

◆ isPseudoProbeDiscriminator()

static bool llvm::DILocation::isPseudoProbeDiscriminator ( unsigned  Discriminator)
inlinestatic

◆ replaceOperandWith()

void llvm::DILocation::replaceOperandWith ( unsigned  I,
Metadata New 
)
delete

Friends And Related Function Documentation

◆ LLVMContextImpl

friend class LLVMContextImpl
friend

Definition at line 1989 of file DebugInfoMetadata.h.

◆ MDNode

friend class MDNode
friend

Definition at line 1990 of file DebugInfoMetadata.h.

Member Data Documentation

◆ Column

unsigned unsigned llvm::DILocation::Column

Definition at line 2025 of file DebugInfoMetadata.h.

◆ ImplicitCode

unsigned unsigned DILocalScope DILocation bool llvm::DILocation::ImplicitCode

Definition at line 2027 of file DebugInfoMetadata.h.

◆ InlinedAt

unsigned unsigned DILocalScope DILocation* llvm::DILocation::InlinedAt = nullptr

Definition at line 2026 of file DebugInfoMetadata.h.

Referenced by getMergedLocation().

◆ Line

unsigned llvm::DILocation::Line

Definition at line 2025 of file DebugInfoMetadata.h.

Referenced by getMergedLocation().

◆ Scope

unsigned unsigned DILocalScope* llvm::DILocation::Scope

Definition at line 2025 of file DebugInfoMetadata.h.

Referenced by cloneWithDiscriminator(), and getMergedLocation().


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