summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-04-08 21:55:10 +0000
committerDevang Patel <dpatel@apple.com>2011-04-08 21:55:10 +0000
commite39647951bee4e9d21643e60b007979fe9d2d170 (patch)
tree443ca94ccb21046ba19e8af4c47a4e57066fc899 /llvm/lib/CodeGen
parentc5d44ae3f49db055ca33a9d99bbed2f0326f1642 (diff)
downloadbcm5719-llvm-e39647951bee4e9d21643e60b007979fe9d2d170.tar.gz
bcm5719-llvm-e39647951bee4e9d21643e60b007979fe9d2d170.zip
Do not emit DW_AT_upper_bound and DW_AT_lower_bound for unbouded array.
If lower bound is more then upper bound then consider it is an unbounded array. An array is unbounded if non-zero lower bound is same as upper bound. If lower bound and upper bound are zero than array has one element. llvm-svn: 129156
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index bad87c1b558..b9bf37bd5ea 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1237,15 +1237,27 @@ DwarfDebug::getOrCreateTemplateValueParameterDIE(DITemplateValueParameter TPV) {
/// constructSubrangeDIE - Construct subrange DIE from DISubrange.
void DwarfDebug::constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy){
+ DIE *DW_Subrange = new DIE(dwarf::DW_TAG_subrange_type);
+ addDIEEntry(DW_Subrange, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IndexTy);
int64_t L = SR.getLo();
int64_t H = SR.getHi();
- DIE *DW_Subrange = new DIE(dwarf::DW_TAG_subrange_type);
- addDIEEntry(DW_Subrange, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IndexTy);
+ // The L value defines the lower bounds typically zero for C/C++. The H
+ // value is the upper bounds. Values are 64 bit. H - L + 1 is the size
+ // of the array. If L > H the array will be unbounded. If the L is
+ // non zero and same is H then also the array will be unbounded. If L is
+ // zero and H is zero then the array has one element and in such case do
+ // not emit lower bound.
+
+ if (L > H || (L == H && L != 0)) {
+ // This is an unbounded subrange.
+ Buffer.addChild(DW_Subrange);
+ return;
+ }
+
if (L)
addSInt(DW_Subrange, dwarf::DW_AT_lower_bound, 0, L);
addSInt(DW_Subrange, dwarf::DW_AT_upper_bound, 0, H);
-
Buffer.addChild(DW_Subrange);
}
OpenPOWER on IntegriCloud