forked from OSchip/llvm-project
[DWARF] Default lower bound should respect requested DWARF version.
DWARF may define a default lower-bound for arrays in languages defined in a particular DWARF version. But the logic to suppress an unnecessary lower-bound attribute was looking at the hard-coded default DWARF version, not the version that had been requested. Also updated the list with all languages defined in DWARF v5. Differential Revision: http://reviews.llvm.org/D30484 llvm-svn: 296652
This commit is contained in:
parent
e1b2d31468
commit
91d74813a6
|
@ -617,6 +617,8 @@ HANDLE_DW_LANG(0x0007, Fortran77)
|
|||
HANDLE_DW_LANG(0x0008, Fortran90)
|
||||
HANDLE_DW_LANG(0x0009, Pascal83)
|
||||
HANDLE_DW_LANG(0x000a, Modula2)
|
||||
|
||||
// New in DWARF v3:
|
||||
HANDLE_DW_LANG(0x000b, Java)
|
||||
HANDLE_DW_LANG(0x000c, C99)
|
||||
HANDLE_DW_LANG(0x000d, Ada95)
|
||||
|
@ -627,8 +629,10 @@ HANDLE_DW_LANG(0x0011, ObjC_plus_plus)
|
|||
HANDLE_DW_LANG(0x0012, UPC)
|
||||
HANDLE_DW_LANG(0x0013, D)
|
||||
|
||||
// New in DWARF v5:
|
||||
// New in DWARF v4:
|
||||
HANDLE_DW_LANG(0x0014, Python)
|
||||
|
||||
// New in DWARF v5:
|
||||
HANDLE_DW_LANG(0x0015, OpenCL)
|
||||
HANDLE_DW_LANG(0x0016, Go)
|
||||
HANDLE_DW_LANG(0x0017, Modula3)
|
||||
|
@ -645,6 +649,7 @@ HANDLE_DW_LANG(0x0021, C_plus_plus_14)
|
|||
HANDLE_DW_LANG(0x0022, Fortran03)
|
||||
HANDLE_DW_LANG(0x0023, Fortran08)
|
||||
HANDLE_DW_LANG(0x0024, RenderScript)
|
||||
HANDLE_DW_LANG(0x0025, BLISS)
|
||||
|
||||
// Vendor extensions.
|
||||
HANDLE_DW_LANG(0x8001, Mips_Assembler)
|
||||
|
|
|
@ -98,25 +98,35 @@ int64_t DwarfUnit::getDefaultLowerBound() const {
|
|||
default:
|
||||
break;
|
||||
|
||||
// The languages below have valid values in all DWARF versions.
|
||||
case dwarf::DW_LANG_C89:
|
||||
case dwarf::DW_LANG_C99:
|
||||
case dwarf::DW_LANG_C:
|
||||
case dwarf::DW_LANG_C_plus_plus:
|
||||
case dwarf::DW_LANG_ObjC:
|
||||
case dwarf::DW_LANG_ObjC_plus_plus:
|
||||
return 0;
|
||||
|
||||
case dwarf::DW_LANG_Fortran77:
|
||||
case dwarf::DW_LANG_Fortran90:
|
||||
case dwarf::DW_LANG_Fortran95:
|
||||
return 1;
|
||||
|
||||
// The languages below have valid values only if the DWARF version >= 4.
|
||||
// The languages below have valid values only if the DWARF version >= 3.
|
||||
case dwarf::DW_LANG_C99:
|
||||
case dwarf::DW_LANG_ObjC:
|
||||
case dwarf::DW_LANG_ObjC_plus_plus:
|
||||
if (DD->getDwarfVersion() >= 3)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case dwarf::DW_LANG_Fortran95:
|
||||
if (DD->getDwarfVersion() >= 3)
|
||||
return 1;
|
||||
break;
|
||||
|
||||
// Starting with DWARF v4, all defined languages have valid values.
|
||||
case dwarf::DW_LANG_Java:
|
||||
case dwarf::DW_LANG_Python:
|
||||
case dwarf::DW_LANG_UPC:
|
||||
case dwarf::DW_LANG_D:
|
||||
if (dwarf::DWARF_VERSION >= 4)
|
||||
if (DD->getDwarfVersion() >= 4)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
|
@ -127,11 +137,11 @@ int64_t DwarfUnit::getDefaultLowerBound() const {
|
|||
case dwarf::DW_LANG_Modula2:
|
||||
case dwarf::DW_LANG_Pascal83:
|
||||
case dwarf::DW_LANG_PLI:
|
||||
if (dwarf::DWARF_VERSION >= 4)
|
||||
if (DD->getDwarfVersion() >= 4)
|
||||
return 1;
|
||||
break;
|
||||
|
||||
// The languages below have valid values only if the DWARF version >= 5.
|
||||
// The languages below are new in DWARF v5.
|
||||
case dwarf::DW_LANG_OpenCL:
|
||||
case dwarf::DW_LANG_Go:
|
||||
case dwarf::DW_LANG_Haskell:
|
||||
|
@ -143,7 +153,9 @@ int64_t DwarfUnit::getDefaultLowerBound() const {
|
|||
case dwarf::DW_LANG_Swift:
|
||||
case dwarf::DW_LANG_Dylan:
|
||||
case dwarf::DW_LANG_C_plus_plus_14:
|
||||
if (dwarf::DWARF_VERSION >= 5)
|
||||
case dwarf::DW_LANG_BLISS:
|
||||
case dwarf::DW_LANG_RenderScript:
|
||||
if (DD->getDwarfVersion() >= 5)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
|
@ -151,7 +163,7 @@ int64_t DwarfUnit::getDefaultLowerBound() const {
|
|||
case dwarf::DW_LANG_Julia:
|
||||
case dwarf::DW_LANG_Fortran03:
|
||||
case dwarf::DW_LANG_Fortran08:
|
||||
if (dwarf::DWARF_VERSION >= 5)
|
||||
if (DD->getDwarfVersion() >= 5)
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
; RUN: llc -mtriple=x86_64-apple-darwin -O0 -filetype=obj -dwarf-version 4 \
|
||||
; RUN: -o - < %s | llvm-dwarfdump - -debug-dump=info \
|
||||
; RUN: | FileCheck %s -check-prefixes=CHECK,DWARF4
|
||||
; RUN: llc -mtriple=x86_64-apple-darwin -O0 -filetype=obj -dwarf-version 5 \
|
||||
; RUN: -o - < %s | llvm-dwarfdump - -debug-dump=info \
|
||||
; RUN: | FileCheck %s -check-prefixes=CHECK,DWARF5
|
||||
|
||||
; Check that we can omit default array lower-bounds.
|
||||
; DW_LANG_C_plus_plus_11 is new in DWARF v5, so if we use that with
|
||||
; DWARF v4, we should get the DW_AT_lower_bound attribute.
|
||||
|
||||
source_filename = "test/DebugInfo/X86/default-subrange-array.ll"
|
||||
|
||||
%class.A = type { [42 x i32] }
|
||||
|
||||
@a = global %class.A zeroinitializer, align 4, !dbg !0
|
||||
|
||||
; CHECK: DW_TAG_class_type
|
||||
; CHECK: DW_TAG_member
|
||||
; CHECK-NEXT: DW_AT_name {{.*}} "x"
|
||||
; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] {{.*}} => {[[ARRAY:0x[0-9a-f]+]]})
|
||||
|
||||
; CHECK: [[ARRAY]]: DW_TAG_array_type
|
||||
; CHECK-NEXT: DW_AT_type
|
||||
; CHECK: DW_TAG_subrange_type
|
||||
; CHECK-NEXT: DW_AT_type
|
||||
; DWARF4-NEXT: DW_AT_lower_bound [DW_FORM_data1] (0x00)
|
||||
; CHECK-NEXT: DW_AT_count [DW_FORM_data1] (0x2a)
|
||||
; DWARF5-NOT: DW_AT_lower_bound
|
||||
|
||||
|
||||
!llvm.dbg.cu = !{!14}
|
||||
!llvm.module.flags = !{!17}
|
||||
|
||||
!0 = !DIGlobalVariableExpression(var: !1)
|
||||
!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
|
||||
!2 = !DIFile(filename: "t.cpp", directory: "/Volumes/Sandbox/llvm")
|
||||
!3 = !DICompositeType(tag: DW_TAG_class_type, name: "A", file: !2, line: 1, align: 32, elements: !4)
|
||||
!4 = !{!5, !10}
|
||||
!5 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !3, file: !2, line: 1, baseType: !6, flags: DIFlagPrivate)
|
||||
!6 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, align: 32, elements: !8)
|
||||
!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
||||
!8 = !{!9}
|
||||
!9 = !DISubrange(count: 42, lowerBound: 0)
|
||||
!10 = !DISubprogram(name: "A", scope: !3, file: !2, line: 1, type: !11, isLocal: false, isDefinition: false, scopeLine: 1, virtualIndex: 6, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
|
||||
!11 = !DISubroutineType(types: !12)
|
||||
!12 = !{null, !13}
|
||||
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
|
||||
!14 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11, file: !2, producer: "clang version 3.3 (trunk 169136)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !15, retainedTypes: !15, globals: !16, imports: !15)
|
||||
!15 = !{}
|
||||
!16 = !{!0}
|
||||
!17 = !{i32 1, !"Debug Info Version", i32 3}
|
||||
|
Loading…
Reference in New Issue