[DebugInfo] Removed assert on missing CountVarDIE

Summary:
The assert for a DISubrange's CountVarDIE to be available fails
when the dbg.value() has been optimized away for any reason.
Having the assert for that is a little heavy, so instead removing
it now in favor of not generating the 'count' expression.

Addresses http://llvm.org/PR36263 .

Reviewers: aprantl, dblaikie, probinson

Reviewed By: aprantl

Subscribers: JDevlieghere, llvm-commits, dstenb

Differential Revision: https://reviews.llvm.org/D43387

llvm-svn: 325427
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 4889abc..76e1228 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1382,14 +1382,9 @@
     addUInt(DW_Subrange, dwarf::DW_AT_lower_bound, None, LowerBound);
 
   if (auto *CV = SR->getCount().dyn_cast<DIVariable*>()) {
-    // 'finishVariableDefinition' that creates the types for a variable is
-    // always called _after_ the DIEs for variables are created.
-    auto *CountVarDIE = getDIE(CV);
-    assert(CountVarDIE && "DIE for count is not yet instantiated");
-    addDIEEntry(DW_Subrange, dwarf::DW_AT_count, *CountVarDIE);
+    if (auto *CountVarDIE = getDIE(CV))
+      addDIEEntry(DW_Subrange, dwarf::DW_AT_count, *CountVarDIE);
   } else if (Count != -1)
-    // FIXME: An unbounded array should reference the expression that defines
-    // the array.
     addUInt(DW_Subrange, dwarf::DW_AT_count, None, Count);
 }