[llvm-commits] [llvm] r129156 - in /llvm/trunk: docs/SourceLevelDebugging.html lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/DebugInfo/array.ll

Duncan Sands baldrick at free.fr
Fri Apr 8 15:19:44 PDT 2011


Hi Devang,

> 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.

why is this?  If I have a one element Ada array, and the index of that element
is 27, then won't the lower and upper bounds equal 27?  That doesn't make it an
unbounded array.

Ciao, Duncan.

> If lower bound and upper bound are zero than array has one element.
>
> Added:
>      llvm/trunk/test/DebugInfo/array.ll
> Modified:
>      llvm/trunk/docs/SourceLevelDebugging.html
>      llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>
> Modified: llvm/trunk/docs/SourceLevelDebugging.html
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/SourceLevelDebugging.html?rev=129156&r1=129155&r2=129156&view=diff
> ==============================================================================
> --- llvm/trunk/docs/SourceLevelDebugging.html (original)
> +++ llvm/trunk/docs/SourceLevelDebugging.html Fri Apr  8 16:55:10 2011
> @@ -708,7 +708,7 @@
>      <a href="#format_composite_type">composite type</a>.  The low value defines
>      the lower bounds typically zero for C/C++.  The high value is the upper
>      bounds.  Values are 64 bit.  High - low + 1 is the size of the array.  If low
> -   == high the array will be unbounded.</p>
> +>  high the array will be unbounded.</p>
>
>   </div>
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=129156&r1=129155&r2=129156&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Apr  8 16:55:10 2011
> @@ -1237,15 +1237,27 @@
>
>   /// 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);
>   }
>
>
> Added: llvm/trunk/test/DebugInfo/array.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/array.ll?rev=129156&view=auto
> ==============================================================================
> --- llvm/trunk/test/DebugInfo/array.ll (added)
> +++ llvm/trunk/test/DebugInfo/array.ll Fri Apr  8 16:55:10 2011
> @@ -0,0 +1,34 @@
> +; RUN: llc -O0<  %s | FileCheck %s
> +; Do not emit AT_upper_bound for an unbounded array.
> +
> +define i32 @main() nounwind ssp {
> +entry:
> +  %retval = alloca i32, align 4
> +  %a = alloca [0 x i32], align 4
> +  store i32 0, i32* %retval
> +  call void @llvm.dbg.declare(metadata !{[0 x i32]* %a}, metadata !6), !dbg !11
> +  ret i32 0, !dbg !12
> +}
> +
> +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
> +
> +!llvm.dbg.sp = !{!0}
> +
> +!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 ]
> +!1 = metadata !{i32 589865, metadata !"array.c", metadata !"/private/tmp", metadata !2} ; [ DW_TAG_file_type ]
> +!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 ]
> +!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 ]
> +!4 = metadata !{metadata !5}
> +!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 ]
> +!6 = metadata !{i32 590080, metadata !7, metadata !"a", metadata !1, i32 4, metadata !8, i32 0} ; [ DW_TAG_auto_variable ]
> +!7 = metadata !{i32 589835, metadata !0, i32 3, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ]
> +!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 ]
> +!9 = metadata !{metadata !10}
> +;CHECK: DW_TAG_subrange_type
> +;CHECK-NEXT: DW_AT_type
> +;CHECK-NOT: DW_AT_lower_bound
> +;CHECK-NOT: DW_AT_upper_bound
> +;CHECK-NEXT: End Of Children Mark
> +!10 = metadata !{i32 589857, i64 1, i64 0}        ; [ DW_TAG_subrange_type ]
> +!11 = metadata !{i32 4, i32 7, metadata !7, null}
> +!12 = metadata !{i32 5, i32 3, metadata !7, null}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list