10#include "llvm/Config/llvm-config.h"
13#if LLVM_ENABLE_DEBUGLOC_TRACKING_ORIGIN
17DbgLocOrigin::DbgLocOrigin(
bool ShouldCollectTrace) {
18 if (!ShouldCollectTrace)
20 auto &[
Depth, StackTrace] = StackTraces.emplace_back();
21 Depth = sys::getStackTrace(StackTrace);
23void DbgLocOrigin::addTrace() {
28 if (StackTraces.empty())
30 auto &[
Depth, StackTrace] = StackTraces.emplace_back();
31 Depth = sys::getStackTrace(StackTrace);
38#if LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE
39DILocAndCoverageTracking::DILocAndCoverageTracking(
const DILocation *L)
51 return cast_or_null<DILocation>(Loc.
get());
55 assert(
get() &&
"Expected valid DebugLoc");
56 return get()->getLine();
60 assert(
get() &&
"Expected valid DebugLoc");
61 return get()->getColumn();
65 assert(
get() &&
"Expected valid DebugLoc");
66 return get()->getScope();
70 assert(
get() &&
"Expected valid DebugLoc");
71 return get()->getInlinedAt();
75 return cast<DILocation>(Loc)->getInlinedAtScope();
89 return Loc->isImplicitCode();
96 Loc->setImplicitCode(ImplicitCode);
108 for (
DILocation *Loc = RootLoc; Loc; Loc = Loc->getInlinedAt()) {
109 if (
auto It = Cache.
find(Loc); It != Cache.
end()) {
110 CachedResult = cast<DILocation>(It->second);
122 *LocToUpdate->getScope(), NewSP, Ctx, Cache);
124 LocToUpdate->getColumn(), NewScope);
125 Cache[LocToUpdate] = UpdatedLoc;
133 LocToUpdate->getScope(), UpdatedLoc);
134 Cache[LocToUpdate] = UpdatedLoc;
148 while (
DILocation *IA = CurInlinedAt->getInlinedAt()) {
150 if (
auto *Found = Cache[IA]) {
151 Last = cast<DILocation>(Found);
165 Ctx, MD->getLine(), MD->getColumn(), MD->getScope(),
Last);
173 if (Locs.
size() == 1)
191#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
200 auto *Scope = cast<DIScope>(
getScope());
201 OS << Scope->getFilename();
208 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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - 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
LLVM_ABI DebugLoc getFnDebugLoc() const
Find the debug info location for the start of the function.
LLVM_ABI DILocation * get() const
Get the underlying DILocation.
LLVM_ABI MDNode * getScope() const
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.
iterator find(const_arg_type_t< KeyT > Val)
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.
LLVM_ABI DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.