summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
diff options
context:
space:
mode:
authorSander de Smalen <sander.desmalen@arm.com>2018-01-24 13:35:54 +0000
committerSander de Smalen <sander.desmalen@arm.com>2018-01-24 13:35:54 +0000
commitdc00becd1bd8128c4d0ab7cc4f935f1acadf645e (patch)
tree025adcaf44ebcc6b4095a6dc1ebca03c5bea64a7 /llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
parent48c63d879b4a3a84f4dd21256b4a3d29037055c8 (diff)
downloadbcm5719-llvm-dc00becd1bd8128c4d0ab7cc4f935f1acadf645e.tar.gz
bcm5719-llvm-dc00becd1bd8128c4d0ab7cc4f935f1acadf645e.zip
[DebugInfo] Emit DWARF reference for DIVariable 'count' in DISubrange
Summary: This patch implements the codegen of DWARF debug info for non-constant 'count' fields for DISubrange. This is patch [2/3] in a series to extend LLVM's DISubrange Metadata node to support debugging of C99 variable length arrays and vectors with runtime length like the Scalable Vector Extension for AArch64. It is also a first step towards representing more complex cases like arrays in Fortran. Reviewers: echristo, pcc, aprantl, dexonsmith, clayborg, kristof.beyls, dblaikie Reviewed By: aprantl Subscribers: fhahn, aemerson, rengolin, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D41696 llvm-svn: 323323
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp8
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);
OpenPOWER on IntegriCloud