diff options
author | Eric Christopher <echristo@apple.com> | 2011-10-11 22:59:11 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2011-10-11 22:59:11 +0000 |
commit | 6647b830872363979f7e946cb5d7642b4a95d3d8 (patch) | |
tree | 9c0f59f80b7b1fbd5c5be57748ec9b2d2ac95455 /llvm/lib/CodeGen | |
parent | 57d16927504a90f2ae7f8781134190aba4eb29c2 (diff) | |
download | bcm5719-llvm-6647b830872363979f7e946cb5d7642b4a95d3d8.tar.gz bcm5719-llvm-6647b830872363979f7e946cb5d7642b4a95d3d8.zip |
Add a new wrapper node for a DILexicalBlock that encapsulates it and a
file. Since it should only be used when necessary propagate it through
the backend code generation and tweak testcases accordingly.
This helps with code like in clang's test/CodeGen/debug-info-line.c where
we have multiple #line directives within a single lexical block and want
to generate only a single block that contains each file change.
Part of rdar://10246360
llvm-svn: 141729
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/LexicalScopes.cpp | 20 |
2 files changed, 21 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index d7c702a5fc4..1b7e370fca0 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1371,6 +1371,10 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S, DISubprogram SP(S); Fn = SP.getFilename(); Dir = SP.getDirectory(); + } else if (Scope.isLexicalBlockFile()) { + DILexicalBlockFile DBF(S); + Fn = DBF.getFilename(); + Dir = DBF.getDirectory(); } else if (Scope.isLexicalBlock()) { DILexicalBlock DB(S); Fn = DB.getFilename(); diff --git a/llvm/lib/CodeGen/LexicalScopes.cpp b/llvm/lib/CodeGen/LexicalScopes.cpp index ae06a407037..02fa52527dd 100644 --- a/llvm/lib/CodeGen/LexicalScopes.cpp +++ b/llvm/lib/CodeGen/LexicalScopes.cpp @@ -118,9 +118,16 @@ LexicalScope *LexicalScopes::findLexicalScope(DebugLoc DL) { MDNode *IA = NULL; DL.getScopeAndInlinedAt(Scope, IA, MF->getFunction()->getContext()); if (!Scope) return NULL; + + // The scope that we were created with could have an extra file - which + // isn't what we care about in this case. + DIDescriptor D = DIDescriptor(Scope); + if (D.isLexicalBlockFile()) + Scope = DILexicalBlockFile(Scope).getScope(); + if (IA) return InlinedLexicalScopeMap.lookup(DebugLoc::getFromDILocation(IA)); - return LexicalScopeMap.lookup(DL.getScope(Scope->getContext())); + return LexicalScopeMap.lookup(Scope); } /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If @@ -129,6 +136,7 @@ LexicalScope *LexicalScopes::getOrCreateLexicalScope(DebugLoc DL) { MDNode *Scope = NULL; MDNode *InlinedAt = NULL; DL.getScopeAndInlinedAt(Scope, InlinedAt, MF->getFunction()->getContext()); + if (InlinedAt) { // Create an abstract scope for inlined function. getOrCreateAbstractScope(Scope); @@ -141,12 +149,16 @@ LexicalScope *LexicalScopes::getOrCreateLexicalScope(DebugLoc DL) { /// getOrCreateRegularScope - Find or create a regular lexical scope. LexicalScope *LexicalScopes::getOrCreateRegularScope(MDNode *Scope) { + DIDescriptor D = DIDescriptor(Scope); + if (D.isLexicalBlockFile()) + Scope = DILexicalBlockFile(Scope).getScope(); + LexicalScope *WScope = LexicalScopeMap.lookup(Scope); if (WScope) return WScope; LexicalScope *Parent = NULL; - if (DIDescriptor(Scope).isLexicalBlock()) + if (D.isLexicalBlock()) Parent = getOrCreateLexicalScope(DebugLoc::getFromDILexicalBlock(Scope)); WScope = new LexicalScope(Parent, DIDescriptor(Scope), NULL, false); LexicalScopeMap.insert(std::make_pair(Scope, WScope)); @@ -176,12 +188,14 @@ LexicalScope *LexicalScopes::getOrCreateInlinedScope(MDNode *Scope, LexicalScope *LexicalScopes::getOrCreateAbstractScope(const MDNode *N) { assert(N && "Invalid Scope encoding!"); + DIDescriptor Scope(N); + if (Scope.isLexicalBlockFile()) + Scope = DILexicalBlockFile(Scope).getScope(); LexicalScope *AScope = AbstractScopeMap.lookup(N); if (AScope) return AScope; LexicalScope *Parent = NULL; - DIDescriptor Scope(N); if (Scope.isLexicalBlock()) { DILexicalBlock DB(N); DIDescriptor ParentDesc = DB.getContext(); |