llvm/test/Bitcode/dityperefs-3.8.ll
Adrian Prantl 7b500b4bdf [IR] Remove the DIExpression field from DIGlobalVariable.
This patch implements PR31013 by introducing a
DIGlobalVariableExpression that holds a pair of DIGlobalVariable and
DIExpression.

Currently, DIGlobalVariables holds a DIExpression. This is not the
best way to model this:

(1) The DIGlobalVariable should describe the source level variable,
    not how to get to its location.

(2) It makes it unsafe/hard to update the expressions when we call
    replaceExpression on the DIGLobalVariable.

(3) It makes it impossible to represent a global variable that is in
    more than one location (e.g., a variable with multiple
    DW_OP_LLVM_fragment-s).  We also moved away from attaching the
    DIExpression to DILocalVariable for the same reasons.

This reapplies r289902 with additional testcase upgrades and a change
to the Bitcode record for DIGlobalVariable, that makes upgrading the
old format unambiguous also for variables without DIExpressions.

<rdar://problem/29250149>
https://llvm.org/bugs/show_bug.cgi?id=31013
Differential Revision: https://reviews.llvm.org/D26769

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290153 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-20 02:09:43 +00:00

49 lines
2.8 KiB
LLVM

; RUN: llvm-dis < %s.bc | FileCheck %s
; RUN: verify-uselistorder %s.bc
; Establish a stable order.
!named = !{!0, !1, !2, !3, !4, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16}
; Since this is incomplete debug info the !dbg attachement will be stripped.
; This doesn't matter for what is being tested here.
; CHECK: @G1 = global i32 0
; CHECK: !0 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
; CHECK-NEXT: !1 = !DICompositeType(tag: DW_TAG_structure_type, name: "T1"{{.*}}, identifier: "T1")
; CHECK-NEXT: !2 = !DICompositeType(tag: DW_TAG_structure_type, name: "T2", scope: !1{{.*}}, baseType: !1, vtableHolder: !1, identifier: "T2")
; CHECK-NEXT: !3 = !DIDerivedType(tag: DW_TAG_member, name: "M1", scope: !1{{.*}}, baseType: !2)
; CHECK-NEXT: !4 = !DISubroutineType(types: !5)
; CHECK-NEXT: !5 = !{!1, !2}
; CHECK-NEXT: !6 = !DISubprogram(scope: !1,{{.*}} containingType: !1{{[,)]}}
; CHECK-NEXT: !7 = !DILocalVariable(name: "V1", scope: !6, type: !2)
; CHECK-NEXT: !8 = !DIObjCProperty(name: "P1", type: !1)
; CHECK-NEXT: !9 = !DITemplateTypeParameter(type: !1)
; CHECK-NEXT: !10 = distinct !DIGlobalVariableExpression(var: !11)
; CHECK-NEXT: !11 = !DIGlobalVariable(name: "G",{{.*}} type: !1,
; CHECK-NEXT: !12 = !DITemplateValueParameter(type: !1, value: i32* @G1)
; CHECK-NEXT: !13 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "T2", scope: !0, entity: !1)
; CHECK-NEXT: !14 = !DICompositeType(tag: DW_TAG_structure_type, name: "T3", file: !0, elements: !15, identifier: "T3")
; CHECK-NEXT: !15 = !{!16}
; CHECK-NEXT: !16 = !DISubprogram(scope: !14,
; CHECK-NEXT: !17 = !DIDerivedType(tag: DW_TAG_ptr_to_member_type,{{.*}} extraData: !14)
!0 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
!1 = !DICompositeType(tag: DW_TAG_structure_type, name: "T1", file: !0, identifier: "T1")
!2 = !DICompositeType(tag: DW_TAG_structure_type, name: "T2", file: !0, scope: !"T1", baseType: !"T1", vtableHolder: !"T1", identifier: "T2")
!3 = !DIDerivedType(tag: DW_TAG_member, name: "M1", file: !0, scope: !"T1", baseType: !"T2")
!4 = !DISubroutineType(types: !5)
!5 = !{!"T1", !"T2"}
!6 = !DISubprogram(scope: !"T1", isDefinition: false, containingType: !"T1")
!7 = !DILocalVariable(name: "V1", scope: !6, type: !"T2")
!8 = !DIObjCProperty(name: "P1", type: !"T1")
!9 = !DITemplateTypeParameter(type: !"T1")
!10 = !DIGlobalVariable(name: "G", type: !"T1", isDefinition: false, variable: i32* @G1)
!11 = !DITemplateValueParameter(type: !"T1", value: i32* @G1)
!12 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "T2", scope: !0, entity: !"T1")
!13 = !DICompositeType(tag: DW_TAG_structure_type, name: "T3", file: !0, elements: !14, identifier: "T3")
!14 = !{!15}
!15 = !DISubprogram(scope: !"T3", isDefinition: false)
!16 = !DIDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: !4, extraData: !"T3")
@G1 = global i32 0