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*.
llvm-svn: 210221
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 2325ab8..0bac3be 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1782,12 +1782,10 @@
// 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());