[llvm] r233568 - DebugInfo: Implement MDLocation::getInlinedAtScope()
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Mar 30 10:41:25 PDT 2015
Author: dexonsmith
Date: Mon Mar 30 12:41:24 2015
New Revision: 233568
URL: http://llvm.org/viewvc/llvm-project?rev=233568&view=rev
Log:
DebugInfo: Implement MDLocation::getInlinedAtScope()
Write `MDLocation::getInlinedAtScope()` and use it to re-implement
`DebugLoc::getScopeNode()` (and simplify `DISubprogram::Verify()`).
This follows the inlined-at linked list and returns the scope of the
deepest/last location.
Modified:
llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
llvm/trunk/lib/IR/DebugInfo.cpp
llvm/trunk/lib/IR/DebugLoc.cpp
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=233568&r1=233567&r2=233568&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Mon Mar 30 12:41:24 2015
@@ -949,6 +949,16 @@ public:
return cast_or_null<MDLocation>(getRawInlinedAt());
}
+ /// \brief Get the scope where this is inlined.
+ ///
+ /// Walk through \a getInlinedAt() and return \a getScope() from the deepest
+ /// location.
+ MDLocalScope *getInlinedAtScope() const {
+ if (auto *IA = getInlinedAt())
+ return IA->getInlinedAtScope();
+ return getScope();
+ }
+
Metadata *getRawScope() const { return getOperand(0); }
Metadata *getRawInlinedAt() const {
if (getNumOperands() == 2)
Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=233568&r1=233567&r2=233568&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Mar 30 12:41:24 2015
@@ -349,9 +349,7 @@ bool DISubprogram::Verify() const {
continue;
// walk the inlined-at scopes
- while (MDLocation *IA = DL->getInlinedAt())
- DL = IA;
- MDScope *Scope = DL->getScope();
+ MDScope *Scope = DL->getInlinedAtScope();
if (!Scope)
return false;
while (!isa<MDSubprogram>(Scope)) {
Modified: llvm/trunk/lib/IR/DebugLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugLoc.cpp?rev=233568&r1=233567&r2=233568&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugLoc.cpp (original)
+++ llvm/trunk/lib/IR/DebugLoc.cpp Mon Mar 30 12:41:24 2015
@@ -33,9 +33,7 @@ void DebugLoc::getScopeAndInlinedAt(MDNo
}
MDNode *DebugLoc::getScopeNode() const {
- if (MDNode *InlinedAt = getInlinedAt())
- return DebugLoc::getFromDILocation(InlinedAt).getScopeNode();
- return getScope();
+ return cast<MDLocation>(Loc)->getInlinedAtScope();
}
DebugLoc DebugLoc::getFnDebugLoc() const {
More information about the llvm-commits
mailing list