10#include "llvm/Config/llvm-config.h"
15#if LLVM_ENABLE_DEBUGLOC_TRACKING_ORIGIN
18DbgLocOrigin::DbgLocOrigin(
bool ShouldCollectTrace) {
19 if (!ShouldCollectTrace)
21 auto &[
Depth, StackTrace] = StackTraces.emplace_back();
22 Depth = sys::getStackTrace(StackTrace);
24void DbgLocOrigin::addTrace() {
29 if (StackTraces.empty())
31 auto &[
Depth, StackTrace] = StackTraces.emplace_back();
32 Depth = sys::getStackTrace(StackTrace);
41 assert(
get() &&
"Expected valid DebugLoc");
42 return get()->getLine();
46 assert(
get() &&
"Expected valid DebugLoc");
47 return get()->getColumn();
51 assert(
get() &&
"Expected valid DebugLoc");
52 return get()->getScope();
56 assert(
get() &&
"Expected valid DebugLoc");
57 return get()->getInlinedAt();
77 return Loc->isImplicitCode();
83 Loc->setImplicitCode(ImplicitCode);
94 for (
DILocation *Loc = RootLoc; Loc; Loc = Loc->getInlinedAt()) {
95 if (
auto It = Cache.find(Loc); It != Cache.end()) {
108 *LocToUpdate->getScope(), NewSP, Ctx, Cache);
110 LocToUpdate->getColumn(), NewScope);
111 Cache[LocToUpdate] = UpdatedLoc;
119 LocToUpdate->getScope(), UpdatedLoc);
120 Cache[LocToUpdate] = UpdatedLoc;
134 while (
DILocation *IA = CurInlinedAt->getInlinedAt()) {
136 if (
auto *Found = Cache[IA]) {
151 Ctx, MD->getLine(), MD->getColumn(), MD->getScope(),
Last);
159 if (Locs.
size() == 1)
170 if (!LocA || !LocB) {
173#if LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE
174 if (!LocA && LocA.getKind() == DebugLocKind::Normal)
176 if (!LocB && LocB.getKind() == DebugLocKind::Normal)
186#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
196 OS << Scope->getFilename();
203 InlinedAtDL.print(OS);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
static LLVM_ABI DILocalScope * cloneScopeForSubprogram(DILocalScope &RootScope, DISubprogram &NewSP, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
Traverses the scope chain rooted at RootScope until it hits a Subprogram, recreating the chain with "...
static LLVM_ABI DILocation * getMergedLocation(DILocation *LocA, DILocation *LocB)
Attempts to merge LocA and LocB into a single location; see DebugLoc::getMergedLocation for more deta...
Base class for scope-like contexts.
Subprogram description. Uses SubclassData1.
LLVM_ABI void setImplicitCode(bool ImplicitCode)
LLVM_ABI unsigned getLine() const
DILocation * get() const
Get the underlying DILocation.
LLVM_ABI DebugLoc getFnDebugLoc() const
Find the debug info location for the start of the function.
LLVM_ABI MDNode * getScope() const
LLVM_ABI MDNode * getAsMDNode() const
Return this as a bar MDNode.
DebugLoc(const DILocation *L=nullptr)
Construct from an DILocation.
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-...
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 loc...
LLVM_ABI void print(raw_ostream &OS) const
prints source location /path/to/file.exe:line:col @[inlined at]
static LLVM_ABI DebugLoc getMergedLocations(ArrayRef< DebugLoc > Locs)
Try to combine the vector of locations passed as input in a single one.
LLVM_ABI unsigned getCol() const
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.
LLVM_ABI bool isImplicitCode() const
Check if the DebugLoc corresponds to an implicit code.
LLVM_ABI void dump() const
LLVM_ABI DILocation * getInlinedAt() const
LLVM_ABI MDNode * getInlinedAtScope() const
Get the fully inlined-at scope for a DebugLoc.
This is an important class for using LLVM in a threaded context.
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.