diff options
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 907ede0a633..71f452b6d8d 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1335,7 +1335,13 @@ void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const DISubrange *SR, if (DefaultLowerBound == -1 || LowerBound != DefaultLowerBound) addUInt(DW_Subrange, dwarf::DW_AT_lower_bound, None, LowerBound); - if (Count != -1) + 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); + } 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); |