summaryrefslogtreecommitdiff
path: root/lib/CodeGen/LexicalScopes.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-05-11 18:12:17 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-05-11 18:12:17 +0000
commit99ccb1fae75d3d7296c11f1ec4a6eb5e1cbbe4d4 (patch)
tree1eb2ec5f1415712c07e6ecb51a9cccf296266002 /lib/CodeGen/LexicalScopes.cpp
parentdb692e7d5539bcdac5b892904b06caef4591c096 (diff)
downloadllvm-99ccb1fae75d3d7296c11f1ec4a6eb5e1cbbe4d4.tar.gz
llvm-99ccb1fae75d3d7296c11f1ec4a6eb5e1cbbe4d4.tar.bz2
llvm-99ccb1fae75d3d7296c11f1ec4a6eb5e1cbbe4d4.tar.xz
DebugInfo: Include lexical scopes in inlined subroutines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208506 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LexicalScopes.cpp')
-rw-r--r--lib/CodeGen/LexicalScopes.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/lib/CodeGen/LexicalScopes.cpp b/lib/CodeGen/LexicalScopes.cpp
index 46f864ca55..8bf69ff630 100644
--- a/lib/CodeGen/LexicalScopes.cpp
+++ b/lib/CodeGen/LexicalScopes.cpp
@@ -104,6 +104,14 @@ void LexicalScopes::extractLexicalScopes(
}
}
+LexicalScope *LexicalScopes::findInlinedScope(DebugLoc DL) {
+ MDNode *Scope = nullptr;
+ MDNode *IA = nullptr;
+ DL.getScopeAndInlinedAt(Scope, IA, MF->getFunction()->getContext());
+ auto I = InlinedLexicalScopeMap.find(std::make_pair(Scope, IA));
+ return I != InlinedLexicalScopeMap.end() ? &I->second : nullptr;
+}
+
/// findLexicalScope - Find lexical scope, either regular or inlined, for the
/// given DebugLoc. Return NULL if not found.
LexicalScope *LexicalScopes::findLexicalScope(DebugLoc DL) {
@@ -119,8 +127,10 @@ LexicalScope *LexicalScopes::findLexicalScope(DebugLoc DL) {
if (D.isLexicalBlockFile())
Scope = DILexicalBlockFile(Scope).getScope();
- if (IA)
- return InlinedLexicalScopeMap.lookup(DebugLoc::getFromDILocation(IA));
+ if (IA) {
+ auto I = InlinedLexicalScopeMap.find(std::make_pair(Scope, IA));
+ return I != InlinedLexicalScopeMap.end() ? &I->second : nullptr;
+ }
return findLexicalScope(Scope);
}
@@ -170,21 +180,27 @@ LexicalScope *LexicalScopes::getOrCreateRegularScope(MDNode *Scope) {
}
/// getOrCreateInlinedScope - Find or create an inlined lexical scope.
-LexicalScope *LexicalScopes::getOrCreateInlinedScope(MDNode *Scope,
+LexicalScope *LexicalScopes::getOrCreateInlinedScope(MDNode *ScopeNode,
MDNode *InlinedAt) {
- auto I = LexicalScopeMap.find(InlinedAt);
- if (I != LexicalScopeMap.end())
+ std::pair<const MDNode*, const MDNode*> P(ScopeNode, InlinedAt);
+ auto I = InlinedLexicalScopeMap.find(P);
+ if (I != InlinedLexicalScopeMap.end())
return &I->second;
- DebugLoc InlinedLoc = DebugLoc::getFromDILocation(InlinedAt);
+ LexicalScope *Parent;
+ DILexicalBlock Scope(ScopeNode);
+ if (Scope.isLexicalBlock()) {
+ DILexicalBlock PB(Scope.getContext());
+ Parent = getOrCreateInlinedScope(PB, InlinedAt);
+ } else
+ Parent = getOrCreateLexicalScope(DebugLoc::getFromDILocation(InlinedAt));
+
// FIXME: Use forward_as_tuple instead of make_tuple, once MSVC2012
// compatibility is no longer required.
- I = LexicalScopeMap.emplace(
- std::piecewise_construct, std::make_tuple(InlinedAt),
- std::make_tuple(getOrCreateLexicalScope(InlinedLoc),
- DIDescriptor(Scope), InlinedAt,
- false)).first;
- InlinedLexicalScopeMap[InlinedLoc] = &I->second;
+ I = InlinedLexicalScopeMap.emplace(std::piecewise_construct,
+ std::make_tuple(P),
+ std::make_tuple(Parent, Scope, InlinedAt,
+ false)).first;
return &I->second;
}