llvm.org GIT mirror llvm / fb6e8d6
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129156 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 9 years ago
3 changed file(s) with 51 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
707707 composite type. The low value defines
708708 the lower bounds typically zero for C/C++. The high value is the upper
709709 bounds. Values are 64 bit. High - low + 1 is the size of the array. If low
710 == high the array will be unbounded.

710 > high the array will be unbounded.

711711
712712
713713
12361236
12371237 /// constructSubrangeDIE - Construct subrange DIE from DISubrange.
12381238 void DwarfDebug::constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy){
1239 DIE *DW_Subrange = new DIE(dwarf::DW_TAG_subrange_type);
1240 addDIEEntry(DW_Subrange, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IndexTy);
12391241 int64_t L = SR.getLo();
12401242 int64_t H = SR.getHi();
1241 DIE *DW_Subrange = new DIE(dwarf::DW_TAG_subrange_type);
1242
1243 addDIEEntry(DW_Subrange, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IndexTy);
1243
1244 // The L value defines the lower bounds typically zero for C/C++. The H
1245 // value is the upper bounds. Values are 64 bit. H - L + 1 is the size
1246 // of the array. If L > H the array will be unbounded. If the L is
1247 // non zero and same is H then also the array will be unbounded. If L is
1248 // zero and H is zero then the array has one element and in such case do
1249 // not emit lower bound.
1250
1251 if (L > H || (L == H && L != 0)) {
1252 // This is an unbounded subrange.
1253 Buffer.addChild(DW_Subrange);
1254 return;
1255 }
1256
12441257 if (L)
12451258 addSInt(DW_Subrange, dwarf::DW_AT_lower_bound, 0, L);
12461259 addSInt(DW_Subrange, dwarf::DW_AT_upper_bound, 0, H);
1247
12481260 Buffer.addChild(DW_Subrange);
12491261 }
12501262
0 ; RUN: llc -O0 < %s | FileCheck %s
1 ; Do not emit AT_upper_bound for an unbounded array.
2
3 define i32 @main() nounwind ssp {
4 entry:
5 %retval = alloca i32, align 4
6 %a = alloca [0 x i32], align 4
7 store i32 0, i32* %retval
8 call void @llvm.dbg.declare(metadata !{[0 x i32]* %a}, metadata !6), !dbg !11
9 ret i32 0, !dbg !12
10 }
11
12 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
13
14 !llvm.dbg.sp = !{!0}
15
16 !0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 3, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 0, i1 false, i32 ()* @main, null} ; [ DW_TAG_subprogram ]
17 !1 = metadata !{i32 589865, metadata !"array.c", metadata !"/private/tmp", metadata !2} ; [ DW_TAG_file_type ]
18 !2 = metadata !{i32 589841, i32 0, i32 12, metadata !"array.c", metadata !"/private/tmp", metadata !"clang version 3.0 (trunk 129138)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
19 !3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
20 !4 = metadata !{metadata !5}
21 !5 = metadata !{i32 589860, metadata !2, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
22 !6 = metadata !{i32 590080, metadata !7, metadata !"a", metadata !1, i32 4, metadata !8, i32 0} ; [ DW_TAG_auto_variable ]
23 !7 = metadata !{i32 589835, metadata !0, i32 3, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ]
24 !8 = metadata !{i32 589825, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 32, i32 0, i32 0, metadata !5, metadata !9, i32 0, i32 0} ; [ DW_TAG_array_type ]
25 !9 = metadata !{metadata !10}
26 ;CHECK: DW_TAG_subrange_type
27 ;CHECK-NEXT: DW_AT_type
28 ;CHECK-NOT: DW_AT_lower_bound
29 ;CHECK-NOT: DW_AT_upper_bound
30 ;CHECK-NEXT: End Of Children Mark
31 !10 = metadata !{i32 589857, i64 1, i64 0} ; [ DW_TAG_subrange_type ]
32 !11 = metadata !{i32 4, i32 7, metadata !7, null}
33 !12 = metadata !{i32 5, i32 3, metadata !7, null}