summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorMichael Kuperstein <michael.m.kuperstein@intel.com>2015-07-01 12:33:11 +0000
committerMichael Kuperstein <michael.m.kuperstein@intel.com>2015-07-01 12:33:11 +0000
commit01e8185c31f323e288f030b0eff8584f535637a5 (patch)
treefec14a98a0d7a0844c1a0659205d594e889b84ba /llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parent21a3c184436acff043ed543d95938ebbfa382990 (diff)
downloadbcm5719-llvm-01e8185c31f323e288f030b0eff8584f535637a5.tar.gz
bcm5719-llvm-01e8185c31f323e288f030b0eff8584f535637a5.zip
[DWARF] Fix debug info generation for function static variables, typedefs, and records
Function static variables, typedefs and records (class, struct or union) declared inside a lexical scope were associated with the function as their parent scope, rather than the lexical scope they are defined or declared in. This fixes PR19238 Patch by: amjad.aboud@intel.com Differential Revision: http://reviews.llvm.org/D9758 llvm-svn: 241153
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 7d03a3930d7..363311e8c9e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -449,14 +449,14 @@ void DwarfDebug::beginModule() {
auto *CUNode = cast<DICompileUnit>(N);
DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
for (auto *IE : CUNode->getImportedEntities())
- ScopesWithImportedEntities.push_back(std::make_pair(IE->getScope(), IE));
- // Stable sort to preserve the order of appearance of imported entities.
- // This is to avoid out-of-order processing of interdependent declarations
- // within the same scope, e.g. { namespace A = base; namespace B = A; }
- std::stable_sort(ScopesWithImportedEntities.begin(),
- ScopesWithImportedEntities.end(), less_first());
- for (auto *GV : CUNode->getGlobalVariables())
- CU.getOrCreateGlobalVariableDIE(GV);
+ ScopesWithLocalDeclNodes.push_back(std::make_pair(IE->getScope(), IE));
+ for (auto *GV : CUNode->getGlobalVariables()) {
+ auto *Context = GV->getScope();
+ if (Context && isa<DILexicalBlockBase>(Context))
+ ScopesWithLocalDeclNodes.push_back(std::make_pair(Context, GV));
+ else
+ CU.getOrCreateGlobalVariableDIE(GV);
+ }
for (auto *SP : CUNode->getSubprograms())
SPMap.insert(std::make_pair(SP, &CU));
for (auto *Ty : CUNode->getEnumTypes()) {
@@ -467,12 +467,23 @@ void DwarfDebug::beginModule() {
for (auto *Ty : CUNode->getRetainedTypes()) {
// The retained types array by design contains pointers to
// MDNodes rather than DIRefs. Unique them here.
- CU.getOrCreateTypeDIE(cast<DIType>(resolve(Ty->getRef())));
+ DIType *RT = cast<DIType>(resolve(Ty->getRef()));
+ auto *Context = resolve(Ty->getScope());
+ if (Context && isa<DILexicalBlockBase>(Context))
+ ScopesWithLocalDeclNodes.push_back(std::make_pair(Context, RT));
+ else
+ CU.getOrCreateTypeDIE(RT);
}
// Emit imported_modules last so that the relevant context is already
// available.
for (auto *IE : CUNode->getImportedEntities())
constructAndAddImportedEntityDIE(CU, IE);
+
+ // Stable sort to preserve the order of appearance of imported entities.
+ // This is to avoid out-of-order processing of interdependent declarations
+ // within the same scope, e.g. { namespace A = base; namespace B = A; }
+ std::stable_sort(ScopesWithLocalDeclNodes.begin(),
+ ScopesWithLocalDeclNodes.end(), less_first());
}
// Tell MMI that we have debug info.
OpenPOWER on IntegriCloud