[llvm] [DebugInfo] Helper method for finding the deepest inlining location (PR #161696)
Akshay Deodhar via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 2 12:59:44 PDT 2025
https://github.com/akshayrdeodhar updated https://github.com/llvm/llvm-project/pull/161696
>From 394b18e397b2bf7aae5c1d0aeafcf66ffcf4c734 Mon Sep 17 00:00:00 2001
From: Akshay Deodhar <adeodhar at nvidia.com>
Date: Thu, 25 Sep 2025 21:21:01 +0000
Subject: [PATCH] [DebugInfo] Helper method for finding the deepest inlining
location
---
llvm/include/llvm/IR/DebugInfoMetadata.h | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 6652e303a6648..3536fcdbb911f 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -2600,14 +2600,23 @@ class DILocation : public MDNode {
StringRef getDirectory() const { return getScope()->getDirectory(); }
std::optional<StringRef> getSource() const { return getScope()->getSource(); }
+ /// Get the location where this is inlined
+ ///
+ /// Walk through \a getInlinedAt() and return the \a DILocation where this is
+ /// inlined.
+ const DILocation *getInlinedAtLocation() const {
+ const DILocation *Current = this, *Next = nullptr;
+ while (Next = Current->getInlinedAt())
+ Current = Next;
+ return Current;
+ }
+
/// Get the scope where this is inlined.
///
/// Walk through \a getInlinedAt() and return \a getScope() from the deepest
/// location.
DILocalScope *getInlinedAtScope() const {
- if (auto *IA = getInlinedAt())
- return IA->getInlinedAtScope();
- return getScope();
+ return getInlinedAtLocation()->getScope();
}
/// Get the DWARF discriminator.
More information about the llvm-commits
mailing list