summaryrefslogtreecommitdiff
path: root/test/Bitcode
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2016-12-20 02:09:43 +0000
committerAdrian Prantl <aprantl@apple.com>2016-12-20 02:09:43 +0000
commit7b500b4bdf40cb40cb33bdcf5faf900db4930824 (patch)
tree2c5863a671783389e2588110cfc880f301efdc35 /test/Bitcode
parent23755c9509672822a2aeef123c89d64588586437 (diff)
[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
Diffstat (limited to 'test/Bitcode')
-rw-r--r--test/Bitcode/DIGlobalVariableExpression.ll31
-rw-r--r--test/Bitcode/DIGlobalVariableExpression.ll.bcbin0 -> 1120 bytes
-rw-r--r--test/Bitcode/diglobalvariable-3.8.ll20
-rw-r--r--test/Bitcode/diglobalvariable-3.8.ll.bcbin712 -> 788 bytes
-rw-r--r--test/Bitcode/dityperefs-3.8.ll15
5 files changed, 55 insertions, 11 deletions
diff --git a/test/Bitcode/DIGlobalVariableExpression.ll b/test/Bitcode/DIGlobalVariableExpression.ll
new file mode 100644
index 00000000000..0424a0e42a3
--- /dev/null
+++ b/test/Bitcode/DIGlobalVariableExpression.ll
@@ -0,0 +1,31 @@
+; RUN: llvm-dis -o - %s.bc | FileCheck %s
+
+; CHECK: @g = common global i32 0, align 4, !dbg ![[G:[0-9]+]]
+; CHECK: @h = common global i32 0, align 4, !dbg ![[H:[0-9]+]]
+; CHECK: ![[G]] = {{.*}}!DIGlobalVariableExpression(var: ![[GVAR:[0-9]+]], expr: ![[GEXPR:[0-9]+]])
+; CHECK: ![[GVAR]] = distinct !DIGlobalVariable(name: "g",
+; CHECK: !DIGlobalVariableExpression(var: ![[CVAR:[0-9]+]], expr: ![[CEXPR:[0-9]+]])
+; CHECK: ![[CVAR]] = distinct !DIGlobalVariable(name: "c",
+; CHECK: ![[CEXPR]] = !DIExpression(DW_OP_constu, 23, DW_OP_stack_value)
+; CHECK: ![[H]] = {{.*}}!DIGlobalVariableExpression(var: ![[HVAR:[0-9]+]])
+; CHECK: ![[HVAR]] = distinct !DIGlobalVariable(name: "h",
+; CHECK: ![[GEXPR]] = !DIExpression(DW_OP_plus, 1)
+@g = common global i32 0, align 4, !dbg !0
+@h = common global i32 0, align 4, !dbg !11
+
+!llvm.dbg.cu = !{!1}
+!llvm.module.flags = !{!6, !7, !8}
+!llvm.ident = !{!9}
+
+!0 = distinct !DIGlobalVariable(name: "g", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true, expr: !DIExpression(DW_OP_plus, 1))
+!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 4.0.0 (trunk 286129) (llvm/trunk 286128)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, globals: !4)
+!2 = !DIFile(filename: "a.c", directory: "/")
+!3 = !{}
+!4 = !{!0, !10, !11}
+!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!6 = !{i32 2, !"Dwarf Version", i32 4}
+!7 = !{i32 2, !"Debug Info Version", i32 3}
+!8 = !{i32 1, !"PIC Level", i32 2}
+!9 = !{!"clang version 4.0.0 (trunk 286129) (llvm/trunk 286128)"}
+!10 = distinct !DIGlobalVariable(name: "c", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true, expr: !DIExpression(DW_OP_constu, 23, DW_OP_stack_value))
+!11 = distinct !DIGlobalVariable(name: "h", scope: !1, file: !2, line: 2, type: !5, isLocal: false, isDefinition: true)
diff --git a/test/Bitcode/DIGlobalVariableExpression.ll.bc b/test/Bitcode/DIGlobalVariableExpression.ll.bc
new file mode 100644
index 00000000000..54b6dbd6351
--- /dev/null
+++ b/test/Bitcode/DIGlobalVariableExpression.ll.bc
Binary files differ
diff --git a/test/Bitcode/diglobalvariable-3.8.ll b/test/Bitcode/diglobalvariable-3.8.ll
index 55b3f656c57..f00a2dd86f7 100644
--- a/test/Bitcode/diglobalvariable-3.8.ll
+++ b/test/Bitcode/diglobalvariable-3.8.ll
@@ -1,8 +1,20 @@
; RUN: llvm-dis -o - %s.bc | FileCheck %s
-; CHECK: !0 = distinct !DIGlobalVariable(name: "a", scope: null, isLocal: false, isDefinition: true, expr: !1)
-; CHECK: !1 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!7, !8}
-!named = !{!0}
+; CHECK: !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.1", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3)
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.1", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, globals: !3)
+!1 = !DIFile(filename: "g.c", directory: "/")
+!2 = !{}
+; CHECK: !3 = !{!4}
+!3 = !{!4}
+; CHECK: !4 = {{.*}}!DIGlobalVariableExpression(var: !5, expr: !8)
+; CHECK: !5 = !DIGlobalVariable(name: "c", scope: !0, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true)
+; CHECK: !8 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)
+!4 = !DIGlobalVariable(name: "c", scope: !0, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, variable: i32 42)
+!5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6)
+!6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!7 = !{i32 2, !"Dwarf Version", i32 2}
+!8 = !{i32 2, !"Debug Info Version", i32 3}
-!0 = distinct !DIGlobalVariable(name: "a", variable: i32 42)
diff --git a/test/Bitcode/diglobalvariable-3.8.ll.bc b/test/Bitcode/diglobalvariable-3.8.ll.bc
index bfecedd75d9..693c738f649 100644
--- a/test/Bitcode/diglobalvariable-3.8.ll.bc
+++ b/test/Bitcode/diglobalvariable-3.8.ll.bc
Binary files differ
diff --git a/test/Bitcode/dityperefs-3.8.ll b/test/Bitcode/dityperefs-3.8.ll
index 09225d4eba3..b032805bd28 100644
--- a/test/Bitcode/dityperefs-3.8.ll
+++ b/test/Bitcode/dityperefs-3.8.ll
@@ -18,13 +18,14 @@
; 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 = !DIGlobalVariable(name: "G",{{.*}} type: !1,
-; CHECK-NEXT: !11 = !DITemplateValueParameter(type: !1, value: i32* @G1)
-; CHECK-NEXT: !12 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "T2", scope: !0, entity: !1)
-; CHECK-NEXT: !13 = !DICompositeType(tag: DW_TAG_structure_type, name: "T3", file: !0, elements: !14, identifier: "T3")
-; CHECK-NEXT: !14 = !{!15}
-; CHECK-NEXT: !15 = !DISubprogram(scope: !13,
-; CHECK-NEXT: !16 = !DIDerivedType(tag: DW_TAG_ptr_to_member_type,{{.*}} extraData: !13)
+; 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")