LLVM 22.0.0git
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]

◆ 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 llvm::cast(), DebugLoc(), 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 201 of file DebugLoc.cpp.

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

◆ get()

◆ getAsMDNode()

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

Return this as a bar MDNode.

Definition at line 291 of file DebugLoc.h.

◆ getCol()

unsigned DebugLoc::getCol ( ) const

◆ getCompilerGenerated()

◆ getCopied()

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

Definition at line 222 of file DebugLoc.h.

References DebugLoc().

◆ getDropped()

◆ 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()

◆ 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.

References llvm::cast().

Referenced by getFnDebugLoc().

◆ getLine()

◆ 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 DebugLoc(), and llvm::DILocation::getMergedLocation().

Referenced by llvm::Instruction::applyMergedLocation(), llvm::MachineBasicBlock::findBranchDebugLoc(), getMergedLocations(), mergeCompatibleInvokesImpl(), 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

Definition at line 64 of file DebugLoc.cpp.

References assert(), and get().

Referenced by llvm::getDebugValueLoc(), inlineDebugLoc(), isSameSourceLocation(), and print().

◆ getTemporary()

◆ getUnknown()

DebugLoc llvm::DebugLoc::getUnknown ( )
inlinestatic

Definition at line 162 of file DebugLoc.h.

References DebugLoc().

Referenced by llvm::VPlanTransforms::addExplicitVectorLength(), llvm::VPlanTransforms::addMinimumIterationCheck(), addVPLaneMaskPhiAndUpdateExitBranch(), llvm::checkDebugInfoMetadata(), llvm::VPBuilder::createAnd(), llvm::SSAUpdaterTraits< SSAUpdater >::CreateEmptyPHI(), llvm::VPBuilder::createFCmp(), llvm::VPBuilder::createICmp(), llvm::VPBuilder::createLogicalAnd(), llvm::VPBuilder::createNaryOp(), llvm::VPBuilder::createNaryOp(), llvm::VPBuilder::createNot(), llvm::VPBuilder::createNoWrapPtrAdd(), llvm::VPBuilder::createOr(), llvm::VPBuilder::createOverflowingOp(), llvm::VPBuilder::createPtrAdd(), createReplicateRegion(), llvm::VPBuilder::createSelect(), llvm::VPBuilder::createWidePtrAdd(), expandVPWidenIntOrFpInduction(), findDebugLoc(), getDebugLocFromInstOrOperands(), getDebugLocFromPHI(), llvm::InlineFunctionImpl(), optimizeLatchExitInductionUser(), transformRecipestoEVLRecipes(), llvm::VPHeaderPHIRecipe::VPHeaderPHIRecipe(), llvm::VPHistogramRecipe::VPHistogramRecipe(), llvm::VPInstruction::VPInstruction(), llvm::VPRecipeBase::VPRecipeBase(), llvm::VPRecipeWithIRFlags::VPRecipeWithIRFlags(), llvm::VPRecipeWithIRFlags::VPRecipeWithIRFlags(), llvm::VPReductionEVLRecipe::VPReductionEVLRecipe(), llvm::VPReductionRecipe::VPReductionRecipe(), llvm::VPReductionRecipe::VPReductionRecipe(), llvm::VPScalarIVStepsRecipe::VPScalarIVStepsRecipe(), llvm::VPSingleDefRecipe::VPSingleDefRecipe(), llvm::VPSingleDefRecipe::VPSingleDefRecipe(), llvm::VPWidenCallRecipe::VPWidenCallRecipe(), llvm::VPWidenIntrinsicRecipe::VPWidenIntrinsicRecipe(), llvm::VPWidenIntrinsicRecipe::VPWidenIntrinsicRecipe(), and llvm::VPWidenPHIRecipe::VPWidenPHIRecipe().

◆ hasTrivialDestructor()

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

Check whether this has a trivial destructor.

Definition at line 244 of file DebugLoc.h.

◆ 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 DebugLoc(), 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 DebugLoc(), and 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 DebugLoc(), and 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 DebugLoc(), and llvm::Other.

◆ print()

void DebugLoc::print ( raw_ostream & OS) const

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

Definition at line 204 of file DebugLoc.cpp.

References llvm::cast(), DebugLoc(), getCol(), getInlinedAt(), getLine(), and getScope().

Referenced by dump().

◆ replaceInlinedAtSubprogram()

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

Rebuild the entire inline-at chain by replacing the subprogram at the end of the chain with NewSP.

Definition at line 100 of file DebugLoc.cpp.

References llvm::cast(), llvm::DILocalScope::cloneScopeForSubprogram(), DebugLoc(), llvm::MDNode::get(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::reverse().

Referenced by fixupDebugInfoPostExtraction().

◆ 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: