LLVM 22.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::DebugLoc Class Reference

A debug info location. More...

#include "llvm/IR/DebugLoc.h"

Public Types

enum  { ReplaceLastInlinedAt = true }
 

Public Member Functions

 DebugLoc ()=default
 
LLVM_ABI DebugLoc (const DILocation *L)
 Construct from an DILocation.
 
LLVM_ABI DebugLoc (const MDNode *N)
 Construct from an MDNode.
 
DebugLoc orElse (DebugLoc Other) const
 If this DebugLoc is non-empty, returns this DebugLoc; otherwise, selects Other.
 
DebugLoc getCopied () const
 
 operator bool () const
 Check for null.
 
bool hasTrivialDestructor () const
 Check whether this has a trivial destructor.
 
bool isSameSourceLocation (const DebugLoc &Other) const
 Return true if the source locations match, ignoring isImplicitCode and source atom info.
 
LLVM_ABI unsigned getLine () const
 
LLVM_ABI unsigned getCol () const
 
LLVM_ABI MDNodegetScope () const
 
LLVM_ABI DILocationgetInlinedAt () const
 
LLVM_ABI MDNodegetInlinedAtScope () const
 Get the fully inlined-at scope for a DebugLoc.
 
LLVM_ABI DebugLoc getFnDebugLoc () const
 Find the debug info location for the start of the function.
 
MDNodegetAsMDNode () const
 Return this as a bar MDNode.
 
LLVM_ABI bool isImplicitCode () const
 Check if the DebugLoc corresponds to an implicit code.
 
LLVM_ABI void setImplicitCode (bool ImplicitCode)
 
bool operator== (const DebugLoc &DL) const
 
bool operator!= (const DebugLoc &DL) const
 
LLVM_ABI void dump () const
 
LLVM_ABI void print (raw_ostream &OS) const
 prints source location /path/to/file.exe:line:col @[inlined at]
 
LLVM_ABI DILocationget () const
 Get the underlying DILocation.
 
 operator DILocation * () const
 
DILocationoperator-> () const
 
DILocationoperator* () const
 

Static Public Member Functions

static DebugLoc getTemporary ()
 
static DebugLoc getUnknown ()
 
static DebugLoc getCompilerGenerated ()
 
static DebugLoc getDropped ()
 
static LLVM_ABI DebugLoc getMergedLocation (DebugLoc LocA, DebugLoc LocB)
 When two instructions are combined into a single instruction we also need to combine the original locations into a single location.
 
static LLVM_ABI DebugLoc getMergedLocations (ArrayRef< DebugLoc > Locs)
 Try to combine the vector of locations passed as input in a single one.
 
static LLVM_ABI DebugLoc appendInlinedAt (const DebugLoc &DL, DILocation *InlinedAt, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
 Rebuild the entire inlined-at chain for this instruction so that the top of the chain now is inlined-at the new call site.
 
static LLVM_ABI DebugLoc replaceInlinedAtSubprogram (const DebugLoc &DL, DISubprogram &NewSP, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
 Rebuild the entire inline-at chain by replacing the subprogram at the end of the chain with NewSP.
 

Detailed Description

A debug info location.

This class is a wrapper around a tracking reference to an DILocation pointer.

To avoid extra includes, DebugLoc doubles the DILocation API with a one based on relatively opaque MDNode pointers.

Definition at line 124 of file DebugLoc.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
ReplaceLastInlinedAt 

Definition at line 246 of file DebugLoc.h.

Constructor & Destructor Documentation

◆ DebugLoc() [1/3]

llvm::DebugLoc::DebugLoc ( )
default

◆ DebugLoc() [2/3]

DebugLoc::DebugLoc ( const DILocation L)

Construct from an DILocation.

Definition at line 47 of file DebugLoc.cpp.

◆ DebugLoc() [3/3]

DebugLoc::DebugLoc ( const MDNode N)
explicit

Construct from an MDNode.

Note: if N is not an DILocation, a verifier check will fail, and accessors will crash. However, construction from other nodes is supported in order to handle forward references when reading textual IR.

Definition at line 48 of file DebugLoc.cpp.

Member Function Documentation

◆ appendInlinedAt()

DebugLoc DebugLoc::appendInlinedAt ( const DebugLoc DL,
DILocation InlinedAt,
LLVMContext Ctx,
DenseMap< const MDNode *, MDNode * > &  Cache 
)
static

Rebuild the entire inlined-at chain for this instruction so that the top of the chain now is inlined-at the new call site.

Parameters
InlinedAtThe new outermost inlined-at in the chain.

Definition at line 140 of file DebugLoc.cpp.

References DL, llvm::MDNode::getDistinct(), llvm::Last, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::reverse().

Referenced by inlineDebugLoc().

◆ dump()

LLVM_DUMP_METHOD void DebugLoc::dump ( ) const

Definition at line 192 of file DebugLoc.cpp.

References llvm::dbgs(), and print().

◆ get()

DILocation * DebugLoc::get ( ) const

◆ getAsMDNode()

MDNode * llvm::DebugLoc::getAsMDNode ( ) const
inline

Return this as a bar MDNode.

Definition at line 291 of file DebugLoc.h.

Referenced by llvm::Instruction::eraseMetadataIf(), and llvm::Instruction::getMetadata().

◆ getCol()

unsigned DebugLoc::getCol ( ) const

◆ getCompilerGenerated()

static DebugLoc llvm::DebugLoc::getCompilerGenerated ( )
inlinestatic

◆ getCopied()

DebugLoc llvm::DebugLoc::getCopied ( ) const
inline

Definition at line 222 of file DebugLoc.h.

Referenced by llvm::Instruction::setDebugLoc().

◆ getDropped()

static DebugLoc llvm::DebugLoc::getDropped ( )
inlinestatic

◆ getFnDebugLoc()

DebugLoc DebugLoc::getFnDebugLoc ( ) const

Find the debug info location for the start of the function.

Walk up the scope chain of given debug loc and find line number info for the function.

FIXME: Remove this. Users should use DILocation/DILocalScope API to find the subprogram, and then DILocation::get().

Definition at line 78 of file DebugLoc.cpp.

References DebugLoc(), llvm::MDNode::get(), llvm::getDISubprogram(), and getInlinedAtScope().

◆ getInlinedAt()

DILocation * DebugLoc::getInlinedAt ( ) const

◆ getInlinedAtScope()

MDNode * DebugLoc::getInlinedAtScope ( ) const

Get the fully inlined-at scope for a DebugLoc.

Gets the inlined-at scope for a DebugLoc.

Definition at line 74 of file DebugLoc.cpp.

Referenced by getFnDebugLoc().

◆ getLine()

unsigned DebugLoc::getLine ( ) const

◆ getMergedLocation()

DebugLoc DebugLoc::getMergedLocation ( DebugLoc  LocA,
DebugLoc  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 183 of file DebugLoc.cpp.

References llvm::DILocation::getMergedLocation().

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

◆ getMergedLocations()

DebugLoc DebugLoc::getMergedLocations ( ArrayRef< DebugLoc 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 170 of file DebugLoc.cpp.

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

Referenced by llvm::promoteLoopAccessesToScalars().

◆ getScope()

MDNode * DebugLoc::getScope ( ) const

◆ getTemporary()

static DebugLoc llvm::DebugLoc::getTemporary ( )
inlinestatic

◆ getUnknown()

static DebugLoc llvm::DebugLoc::getUnknown ( )
inlinestatic

◆ hasTrivialDestructor()

bool llvm::DebugLoc::hasTrivialDestructor ( ) const
inline

Check whether this has a trivial destructor.

Definition at line 244 of file DebugLoc.h.

References llvm::TypedTrackingMDRef< T >::hasTrivialDestructor().

Referenced by llvm::SDNode::SDNode().

◆ isImplicitCode()

bool DebugLoc::isImplicitCode ( ) const

Check if the DebugLoc corresponds to an implicit code.

Definition at line 87 of file DebugLoc.cpp.

References get().

Referenced by inlineDebugLoc().

◆ isSameSourceLocation()

bool llvm::DebugLoc::isSameSourceLocation ( const DebugLoc Other) const
inline

Return true if the source locations match, ignoring isImplicitCode and source atom info.

Definition at line 256 of file DebugLoc.h.

References get(), getCol(), getInlinedAt(), getLine(), getScope(), and llvm::Other.

Referenced by cloneInstructionsIntoPredecessorBlockAndUpdateSSAUses().

◆ operator bool()

llvm::DebugLoc::operator bool ( ) const
inlineexplicit

Check for null.

Check for null in a way that is safe with broken debug info. Unlike the conversion to DILocation, this doesn't require that Loc is of the right type. Important for cases like llvm::StripDebugInfo() and Instruction::hasMetadata().

Definition at line 241 of file DebugLoc.h.

◆ operator DILocation *()

llvm::DebugLoc::operator DILocation * ( ) const
inline

Definition at line 230 of file DebugLoc.h.

References get().

◆ operator!=()

bool llvm::DebugLoc::operator!= ( const DebugLoc DL) const
inline

Definition at line 298 of file DebugLoc.h.

References DL.

◆ operator*()

DILocation & llvm::DebugLoc::operator* ( ) const
inline

Definition at line 232 of file DebugLoc.h.

References get().

◆ operator->()

DILocation * llvm::DebugLoc::operator-> ( ) const
inline

Definition at line 231 of file DebugLoc.h.

References get().

◆ operator==()

bool llvm::DebugLoc::operator== ( const DebugLoc DL) const
inline

Definition at line 297 of file DebugLoc.h.

References DL.

◆ orElse()

DebugLoc llvm::DebugLoc::orElse ( DebugLoc  Other) const
inline

If this DebugLoc is non-empty, returns this DebugLoc; otherwise, selects Other.

In coverage-tracking builds, this also accounts for whether this or Other have an annotative DebugLocKind applied, such that if both are empty but exactly one has an annotation, we prefer that annotated location.

Definition at line 196 of file DebugLoc.h.

References llvm::Other.

Referenced by llvm::IRBuilderBase::SetInstDebugLocation().

◆ print()

void DebugLoc::print ( raw_ostream OS) const

prints source location /path/to/file.exe:line:col @[inlined at]

Definition at line 195 of file DebugLoc.cpp.

References getCol(), getInlinedAt(), getLine(), getScope(), and OS.

Referenced by dump().

◆ replaceInlinedAtSubprogram()

DebugLoc DebugLoc::replaceInlinedAtSubprogram ( const DebugLoc DL,
DISubprogram NewSP,
LLVMContext Ctx,
DenseMap< const MDNode *, MDNode * > &  Cache 
)
static

◆ setImplicitCode()

void DebugLoc::setImplicitCode ( bool  ImplicitCode)

Definition at line 94 of file DebugLoc.cpp.

References get().


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