1 ; RUN: rm -rf %t && split-file %s %t
2 ; RUN: llvm-link -S %t/1.ll %t/1-aux.ll -o - | FileCheck %s
3 ; RUN: llvm-link -S %t/2.ll %t/2-aux.ll -o - | FileCheck %s --check-prefix=CHECK2
5 ;; A private linkage variable can be copied.
6 ; RUN: llvm-link -S %t/3.ll %t/3-aux.ll -o - | FileCheck %s --check-prefix=CHECK3
9 ; CHECK: @foo = global i8 0, comdat
11 ; CHECK: define void @zed() {
12 ; CHECK: call void @bar()
16 ; CHECK: declare void @bar()
19 @foo = global i8 0, comdat
23 @foo = global i8 1, comdat
28 define void @bar() comdat($foo) {
35 @v1 = weak_odr global i32 42, comdat($c1)
36 define weak_odr i32 @f1(ptr) comdat($c1) {
46 @a11 = alias i32, ptr @v1
47 @a12 = alias i16, ptr @v1
49 @a13 = alias i32 (ptr), ptr @f1
50 @a14 = alias i16, ptr @f1
51 @a15 = alias i16, ptr @a14
53 ; CHECK2: $c1 = comdat any
54 ; CHECK2: $c2 = comdat any
56 ; CHECK2-DAG: @will_be_undefined = external global i32
58 ; CHECK2-DAG: @v1 = weak_odr global i32 42, comdat($c1)
60 ; CHECK2-DAG: @r11 = global ptr @v1{{$}}
61 ; CHECK2-DAG: @r12 = global ptr @f1{{$}}
63 ; CHECK2-DAG: @r21 = global ptr @v1{{$}}
64 ; CHECK2-DAG: @r22 = global ptr @f1{{$}}
66 ; CHECK2-DAG: @v1.1 = internal global i32 41, comdat($c2)
68 ; CHECK2-DAG: @a11 = alias i32, ptr @v1{{$}}
69 ; CHECK2-DAG: @a12 = alias i16, ptr @v1
71 ; CHECK2-DAG: @a13 = alias i32 (ptr), ptr @f1{{$}}
72 ; CHECK2-DAG: @a14 = alias i16, ptr @f1
74 ; CHECK2-DAG: @a21 = alias i32, ptr @v1.1{{$}}
75 ; CHECK2-DAG: @a22 = alias i16, ptr @v1.1
77 ; CHECK2-DAG: @a23 = alias i32 (ptr), ptr @f1.2{{$}}
78 ; CHECK2-DAG: @a24 = alias i16, ptr @f1.2
80 ; CHECK2: define weak_odr protected i32 @f1(ptr %0) comdat($c1) {
82 ; CHECK2-NEXT: br label %bb11{{$}}
84 ; CHECK2-NEXT: ret i32 42
87 ; CHECK2: define internal i32 @f1.2(ptr %this) comdat($c2) {
89 ; CHECK2-NEXT: store ptr %this, ptr null
90 ; CHECK2-NEXT: br label %bb21
92 ; CHECK2-NEXT: ret i32 41
99 ; This is only present in this file. The linker will keep $c1 from the first
100 ; file and this will be undefined.
101 @will_be_undefined = global i32 1, comdat($c1)
102 @use = global ptr @will_be_undefined
104 @v1 = weak_odr global i32 41, comdat($c2)
105 define weak_odr protected i32 @f1(ptr %this) comdat($c2) {
107 store ptr %this, ptr null
113 @r21 = global ptr @v1
114 @r22 = global ptr @f1
116 @a21 = alias i32, ptr @v1
117 @a22 = alias i16, ptr @v1
119 @a23 = alias i32(ptr), ptr @f1
120 @a24 = alias i16, ptr @f1
121 @a25 = alias i16, ptr @a24
124 ; CHECK3: @bar = global i32 0, comdat($a1)
125 ; CHECK3: @baz = private global i32 42, comdat($a1)
126 ; CHECK3: @a1 = internal alias i32, ptr @baz
128 @bar = global i32 0, comdat($a1)
132 @baz = private global i32 42, comdat($a1)
133 @a1 = internal alias i32, ptr @baz