diff options
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index e77e8d9b354..c009adc1e50 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -483,6 +483,7 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV, bool Abstract) { // Define variable debug information entry. auto VariableDie = DIE::get(DIEValueAllocator, DV.getTag()); + insertDIE(DV.getVariable(), VariableDie); if (Abstract) { applyVariableAttributes(DV, *VariableDie); 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); |