1; RUN: llvm-link -S -o - %s %S/Inputs/dicompositetype-unique.ll \
2; RUN:   | FileCheck %s -check-prefix CHECK -check-prefix FORWARD
3; RUN: llvm-link -S -o - %S/Inputs/dicompositetype-unique.ll %s \
4; RUN:   | FileCheck %s -check-prefix CHECK -check-prefix REVERSE
5; RUN: llvm-link -disable-debug-info-type-map -S -o - %s %S/Inputs/dicompositetype-unique.ll \
6; RUN:   | FileCheck %s -check-prefix NOMAP
7
8; Check that the bitcode reader handles this too.
9; RUN: llvm-as -o %t1.bc <%s
10; RUN: llvm-as -o %t2.bc <%S/Inputs/dicompositetype-unique.ll
11; RUN: llvm-link -S -o - %t1.bc %t2.bc \
12; RUN:   | FileCheck %s -check-prefix CHECK -check-prefix FORWARD
13; RUN: llvm-link -S -o - %t2.bc %t1.bc \
14; RUN:   | FileCheck %s -check-prefix CHECK -check-prefix REVERSE
15; RUN: llvm-link -disable-debug-info-type-map -S -o - %t1.bc %t2.bc \
16; RUN:   | FileCheck %s -check-prefix NOMAP
17
18; Check that the type map will unique two DICompositeTypes.
19
20; CHECK:   !named = !{!0, !1, !2, !3, !0, !1, !2, !3}
21; NOMAP:   !named = !{!0, !1, !2, !3, !0, !4, !5, !6}
22!named = !{!0, !1, !2, !3}
23
24; Check both directions.
25; CHECK:        !1 = distinct !DICompositeType(
26; FORWARD-SAME:                                name: "T1"
27; REVERSE-SAME:                                name: "T2"
28; CHECK-SAME:                                  identifier: "T"
29; CHECK-NOT:       identifier: "T"
30; CHECK:        !2 = distinct !DICompositeType(
31; CHECK-SAME:                                  name: "FwdTDef"
32; CHECK-SAME:                                  identifier: "FwdT"
33; CHECK-NOT:       identifier: "FwdT"
34; CHECK:        !3 = distinct !DICompositeType(
35; FORWARD-SAME:                                name: "BothFwdT1"
36; REVERSE-SAME:                                name: "BothFwdT2"
37; CHECK-SAME:                                  identifier: "BothFwdT"
38; CHECK-NOT:       identifier: "BothFwdT"
39
40; These types are different, so we should get both copies when there is no map.
41; NOMAP:        !1 = !DICompositeType(
42; NOMAP-SAME:                         name: "T1"
43; NOMAP-SAME:                         identifier: "T"
44; NOMAP:        !2 = !DICompositeType(
45; NOMAP-SAME:                         name: "FwdTFwd"
46; NOMAP-SAME:                         identifier: "FwdT"
47; NOMAP:        !3 = !DICompositeType(
48; NOMAP-SAME:                         name: "BothFwdT1"
49; NOMAP-SAME:                         identifier: "BothFwdT"
50; NOMAP:        !4 = !DICompositeType(
51; NOMAP-SAME:                         name: "T2"
52; NOMAP-SAME:                         identifier: "T"
53; NOMAP-NOT:       identifier: "T"
54; NOMAP:        !5 = !DICompositeType(
55; NOMAP-SAME:                         name: "FwdTDef"
56; NOMAP-SAME:                         identifier: "FwdT"
57; NOMAP-NOT:       identifier: "FwdT"
58; NOMAP:        !6 = !DICompositeType(
59; NOMAP-SAME:                         name: "BothFwdT2"
60; NOMAP-SAME:                         identifier: "BothFwdT"
61; NOMAP-NOT:       identifier: "BothFwdT"
62!0 = !DIFile(filename: "abc", directory: "/path/to")
63!1 = !DICompositeType(tag: DW_TAG_class_type, name: "T1", identifier: "T", file: !0)
64!2 = !DICompositeType(tag: DW_TAG_class_type, flags: DIFlagFwdDecl, name: "FwdTFwd", identifier: "FwdT", file: !0)
65!3 = !DICompositeType(tag: DW_TAG_class_type, flags: DIFlagFwdDecl, name: "BothFwdT1", identifier: "BothFwdT", file: !0)
66