diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-11-04 19:00:29 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-11-04 19:00:29 +0000 |
commit | 6cf4e830ce1b4b73bc2827676872fa43c83a4158 (patch) | |
tree | bfbf864831c1574709d0acff46a9b8a93f0af665 /llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | |
parent | 2ccf84e3a5871c9be41885de22c0af80bda5f6fd (diff) | |
download | bcm5719-llvm-6cf4e830ce1b4b73bc2827676872fa43c83a4158.tar.gz bcm5719-llvm-6cf4e830ce1b4b73bc2827676872fa43c83a4158.zip |
Emit declarations before definitions if they are available. This causes DW_AT_specification to
point back in the file in the included testcase. Fixes PR11300.
llvm-svn: 143726
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 0f4ea051a23..b022c430ac6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -194,11 +194,7 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(CompileUnit *SPCU, DISubprogram SP(SPNode); DISubprogram SPDecl = SP.getFunctionDeclaration(); - if (SPDecl.isSubprogram()) - // Refer function declaration directly. - SPCU->addDIEEntry(SPDie, dwarf::DW_AT_specification, dwarf::DW_FORM_ref4, - SPCU->getOrCreateSubprogramDIE(SPDecl)); - else { + if (!SPDecl.isSubprogram()) { // There is not any need to generate specification DIE for a function // defined at compile unit level. If a function is defined inside another // function then gdb prefers the definition at top level and but does not @@ -512,14 +508,31 @@ CompileUnit *DwarfDebug::constructCompileUnit(const MDNode *N) { /// construct SubprogramDIE - Construct subprogram DIE. void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N) { + CompileUnit *&CURef = SPMap[N]; + if (CURef) + return; + CURef = TheCU; + DISubprogram SP(N); if (!SP.isDefinition()) // This is a method declaration which will be handled while constructing // class type. return; + DISubprogram SPDecl = SP.getFunctionDeclaration(); + DIE *DeclDie = NULL; + if (SPDecl.isSubprogram()) { + DeclDie = TheCU->getOrCreateSubprogramDIE(SPDecl); + } + DIE *SubprogramDie = TheCU->getOrCreateSubprogramDIE(SP); + if (DeclDie) { + // Refer function declaration directly. + TheCU->addDIEEntry(SubprogramDie, dwarf::DW_AT_specification, + dwarf::DW_FORM_ref4, DeclDie); + } + // Add to map. TheCU->insertDIE(N, SubprogramDie); @@ -529,7 +542,6 @@ void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU, // Expose as global. TheCU->addGlobal(SP.getName(), SubprogramDie); - SPMap[N] = TheCU; return; } |