Index: lib/CodeGen/AsmPrinter/DwarfUnit.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1381,15 +1381,13 @@ if (DefaultLowerBound == -1 || LowerBound != DefaultLowerBound) addUInt(DW_Subrange, dwarf::DW_AT_lower_bound, None, LowerBound); - if (auto *CV = SR->getCount().dyn_cast()) { - // '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"); + DIE *CountVarDIE = nullptr; + if (auto *CV = SR->getCount().dyn_cast()) + CountVarDIE = getDIE(CV); + + if (CountVarDIE) addDIEEntry(DW_Subrange, dwarf::DW_AT_count, *CountVarDIE); - } else if (Count != -1) - // FIXME: An unbounded array should reference the expression that defines - // the array. + else if (Count != -1) addUInt(DW_Subrange, dwarf::DW_AT_count, None, Count); }