DebugInfo: Move new hierarchy into place
[oota-llvm.git] / test / DebugInfo / X86 / ref_addr_relocation.ll
1 ; RUN: llc -filetype=asm -O0 -mtriple=x86_64-linux-gnu < %s | FileCheck %s
2 ; RUN: llc -filetype=obj -O0 %s -mtriple=x86_64-linux-gnu -o %t
3 ; RUN: llvm-dwarfdump %t | FileCheck %s -check-prefix=CHECK-DWARF
4
5 ; RUN: llc -filetype=obj %s -mtriple=x86_64-apple-darwin -o %t2
6 ; RUN: llvm-dwarfdump %t2 | FileCheck %s -check-prefix=DARWIN-DWARF
7
8 ; Testing case generated from:
9 ; clang++ tu1.cpp tu2.cpp -g -emit-llvm -c
10 ; llvm-link tu1.bc tu2.bc -o tu12.ll -S
11 ; cat hdr.h
12 ; struct foo {
13 ; };
14 ; cat tu1.cpp
15 ; #include "hdr.h"
16 ; foo f;
17 ; cat tu2.cpp
18 ; #include "hdr.h"
19 ; foo g;
20
21 ; Make sure we use relocation for ref_addr on non-darwin platforms.
22 ; CHECK: DW_TAG_compile_unit
23 ; CHECK: DW_TAG_variable
24 ; CHECK: .long [[TYPE:.*]] # DW_AT_type
25 ; CHECK: DW_TAG_structure_type
26 ; CHECK: debug_info_begin1
27 ; CHECK: DW_TAG_compile_unit
28 ; CHECK-NOT: DW_TAG_structure_type
29 ; This variable's type is in the 1st CU.
30 ; CHECK: DW_TAG_variable
31 ; Make sure this is relocatable.
32 ; CHECK: .quad .Lsection_info+[[TYPE]] # DW_AT_type
33 ; CHECK-NOT: DW_TAG_structure_type
34 ; CHECK: .section
35
36 ; CHECK-DWARF: DW_TAG_compile_unit
37 ; CHECK-DWARF: 0x[[ADDR:.*]]: DW_TAG_structure_type
38 ; CHECK-DWARF: DW_TAG_compile_unit
39 ; CHECK-DWARF: DW_TAG_variable
40 ; CHECK-DWARF: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[ADDR]])
41
42 ; DARWIN-DWARF: DW_TAG_compile_unit
43 ; DARWIN-DWARF: 0x[[ADDR:.*]]: DW_TAG_structure_type
44 ; DARWIN-DWARF: DW_TAG_compile_unit
45 ; DARWIN-DWARF: DW_TAG_variable
46 ; DARWIN-DWARF: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[ADDR]])
47
48 %struct.foo = type { i8 }
49
50 @f = global %struct.foo zeroinitializer, align 1
51 @g = global %struct.foo zeroinitializer, align 1
52
53 !llvm.dbg.cu = !{!0, !9}
54 !llvm.module.flags = !{!14, !15}
55
56 !0 = !MDCompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.4 (trunk 191799)", isOptimized: false, emissionKind: 0, file: !1, enums: !2, retainedTypes: !3, subprograms: !2, globals: !6, imports: !2)
57 !1 = !MDFile(filename: "tu1.cpp", directory: "/Users/manmanren/test-Nov/type_unique_air/ref_addr")
58 !2 = !{}
59 !3 = !{!4}
60 !4 = !MDCompositeType(tag: DW_TAG_structure_type, name: "foo", line: 1, size: 8, align: 8, file: !5, elements: !2, identifier: "_ZTS3foo")
61 !5 = !MDFile(filename: "./hdr.h", directory: "/Users/manmanren/test-Nov/type_unique_air/ref_addr")
62 !6 = !{!7}
63 !7 = !MDGlobalVariable(name: "f", line: 2, isLocal: false, isDefinition: true, scope: null, file: !8, type: !4, variable: %struct.foo* @f)
64 !8 = !MDFile(filename: "tu1.cpp", directory: "/Users/manmanren/test-Nov/type_unique_air/ref_addr")
65 !9 = !MDCompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.4 (trunk 191799)", isOptimized: false, emissionKind: 0, file: !10, enums: !2, retainedTypes: !3, subprograms: !2, globals: !11, imports: !2)
66 !10 = !MDFile(filename: "tu2.cpp", directory: "/Users/manmanren/test-Nov/type_unique_air/ref_addr")
67 !11 = !{!12}
68 !12 = !MDGlobalVariable(name: "g", line: 2, isLocal: false, isDefinition: true, scope: null, file: !13, type: !4, variable: %struct.foo* @g)
69 !13 = !MDFile(filename: "tu2.cpp", directory: "/Users/manmanren/test-Nov/type_unique_air/ref_addr")
70 !14 = !{i32 2, !"Dwarf Version", i32 2}
71 !15 = !{i32 1, !"Debug Info Version", i32 3}