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