summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.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/DwarfCompileUnit.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/DwarfCompileUnit.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index fc54a2925be..86389f89783 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -101,7 +101,7 @@ static const ConstantExpr *getMergedGlobalExpr(const Value *V) {
/// getOrCreateGlobalVariableDIE - get or create global variable DIE.
DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
- const DIGlobalVariable *GV) {
+ const DIGlobalVariable *GV, DIE *ContextDIE) {
// Check for pre-existence.
if (DIE *Die = getDIE(GV))
return Die;
@@ -113,7 +113,8 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
// Construct the context before querying for the existence of the DIE in
// case such construction creates the DIE.
- DIE *ContextDIE = getOrCreateContextDIE(GVContext);
+ if (ContextDIE == nullptr)
+ ContextDIE = getOrCreateContextDIE(GVContext);
// Add to map.
DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV);
@@ -335,17 +336,16 @@ void DwarfCompileUnit::constructScopeDIE(
// null and the children will be added to the scope DIE.
createScopeChildrenDIE(Scope, Children, &ChildScopeCount);
- // Skip imported directives in gmlt-like data.
- if (!includeMinimalInlineScopes()) {
- // There is no need to emit empty lexical block DIE.
- for (const auto &E : DD->findImportedEntitiesForScope(DS))
- Children.push_back(
- constructImportedEntityDIE(cast<DIImportedEntity>(E.second)));
- }
+
+ DwarfDebug::LocalDeclMapRange LocalDeclNodeRangeForScope(nullptr, nullptr);
+ // Skip local decls in gmlt-like data.
+ if (!includeMinimalInlineScopes())
+ LocalDeclNodeRangeForScope = DD->findLocalDeclNodesForScope(DS);
// If there are only other scopes as children, put them directly in the
// parent instead, as this scope would serve no purpose.
- if (Children.size() == ChildScopeCount) {
+ if (Children.size() == ChildScopeCount &&
+ empty(LocalDeclNodeRangeForScope)) {
FinalChildren.insert(FinalChildren.end(),
std::make_move_iterator(Children.begin()),
std::make_move_iterator(Children.end()));
@@ -353,6 +353,15 @@ void DwarfCompileUnit::constructScopeDIE(
}
ScopeDIE = constructLexicalScopeDIE(Scope);
assert(ScopeDIE && "Scope DIE should not be null.");
+
+ for (const auto &DI : LocalDeclNodeRangeForScope) {
+ if (auto *IE = dyn_cast<DIImportedEntity>(DI.second))
+ Children.push_back(constructImportedEntityDIE(IE));
+ else if (auto *GV = dyn_cast<DIGlobalVariable>(DI.second))
+ getOrCreateGlobalVariableDIE(GV, ScopeDIE);
+ else if (auto *RT = dyn_cast<DIType>(DI.second))
+ getOrCreateTypeDIE(RT, ScopeDIE);
+ }
}
// Add children
OpenPOWER on IntegriCloud