1; RUN: llvm-link %s -S -o - | FileCheck %s
2; RUN: llvm-link %s %S/Inputs/metadata-attach.ll -S -o - | FileCheck --check-prefix=CHECK-LINKED1 %s
3; RUN: llvm-link %S/Inputs/metadata-attach.ll %s -S -o - | FileCheck --check-prefix=CHECK-LINKED2 %s
4
5; CHECK: @g1 = global i32 0, !attach !0{{$}}
6; CHECK-LINKED1: @g1 = global i32 0, !attach !0{{$}}
7@g1 = global i32 0, !attach !0
8
9; CHECK: @g3 = weak global i32 1, !attach !0{{$}}
10; CHECK: @g2 = external global i32, !attach !0{{$}}
11; CHECK-LINKED1: @g2 = global i32 1, !attach !1{{$}}
12@g2 = external global i32, !attach !0
13
14; CHECK-LINKED1: @g3 = global i32 2, !attach !1{{$}}
15@g3 = weak global i32 1, !attach !0
16
17; CHECK-LINKED2: @g2 = global i32 1, !attach !0{{$}}
18; CHECK-LINKED2: @g3 = global i32 2, !attach !0{{$}}
19; CHECK-LINKED2: @g1 = global i32 0, !attach !1{{$}}
20
21; CHECK: define void @f1() !attach !0 {
22; CHECK-LINKED1: define void @f1() !attach !0 {
23define void @f1() !attach !0 {
24  call void @f2()
25  store i32 0, i32* @g2
26  ret void
27}
28
29; CHECK: declare !attach !0 void @f2()
30; CHECK-LINKED1: define void @f2() !attach !1 {
31declare !attach !0 void @f2()
32
33; CHECK: define weak void @f3() !attach !0 {
34; CHECK-LINKED1: define void @f3() !attach !1 {
35define weak void @f3() !attach !0 {
36  ret void
37}
38
39; CHECK-LINKED2: define void @f2() !attach !0 {
40; CHECK-LINKED2: define void @f3() !attach !0 {
41; CHECK-LINKED2: define void @f1() !attach !1 {
42
43; CHECK-LINKED1: !0 = !{i32 0}
44; CHECK-LINKED1: !1 = !{i32 1}
45
46; CHECK-LINKED2: !0 = !{i32 1}
47; CHECK-LINKED2: !1 = !{i32 0}
48
49!0 = !{i32 0}
50