DebugInfo: Reapply r209984 (reverted in r210143), asserting that abstract DbgVariables have DIEs.

Abstract variables within abstract scopes that are entirely optimized
away in their first inlining are omitted because their scope is not
present so the variable is never created. Instead, we should ensure the
scope is created so the variable can be added, even if it's been
optimized away in its first inlining.

This fixes the incorrect debug info in missing-abstract-variable.ll
(added in r210143) and passes an asserts self-hosting build, so
hopefully there's not more of these issues left behind... *fingers
crossed*.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210221 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2014-06-04 23:50:52 +00:00
parent 7afb107a27
commit 06ac3ffc8f
5 changed files with 59 additions and 26 deletions

View File

@ -1782,12 +1782,10 @@ std::unique_ptr<DIE> DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
// Define variable debug information entry.
auto VariableDie = make_unique<DIE>(DV.getTag());
DbgVariable *AbsVar = DV.getAbstractVariable();
// FIXME: any missing abstract variable missing a DIE will result in incorrect
// DWARF. More details in test/DebugInfo/missing-abstract-variable.ll for an
// example of why this is happening.
if (AbsVar && AbsVar->getDIE())
if (AbsVar) {
assert(AbsVar->getDIE());
addDIEEntry(*VariableDie, dwarf::DW_AT_abstract_origin, *AbsVar->getDIE());
else {
} else {
if (!Name.empty())
addString(*VariableDie, dwarf::DW_AT_name, Name);
addSourceLine(*VariableDie, DV.getVariable());