Don't crash when the key of a comdat is lazily linked.
[oota-llvm.git] / test / Linker / testlink.ll
1 ; RUN: llvm-link %s %S/Inputs/testlink.ll -S | FileCheck %s
2
3 ; CHECK: %Ty2 = type { %Ty1* }
4 ; CHECK: %Ty1 = type { %Ty2* }
5 %Ty1 = type opaque
6 %Ty2 = type { %Ty1* }
7
8 ; CHECK: %intlist = type { %intlist*, i32 }
9 %intlist = type { %intlist*, i32 }
10
11 ; The uses of intlist in the other file should be remapped.
12 ; CHECK-NOT: {{%intlist.[0-9]}}
13
14 ; CHECK: %VecSize = type { <5 x i32> }
15 ; CHECK: %VecSize.{{[0-9]}} = type { <10 x i32> }
16 %VecSize = type { <5 x i32> }
17
18 %Struct1 = type opaque
19 @S1GV = external global %Struct1*
20
21
22 @GVTy1 = external global %Ty1*
23 @GVTy2 = global %Ty2* null
24
25
26 ; This should stay the same
27 ; CHECK-DAG: @MyIntList = global %intlist { %intlist* null, i32 17 }
28 @MyIntList = global %intlist { %intlist* null, i32 17 }
29
30
31 ; Nothing to link here.
32
33 ; CHECK-DAG: @0 = external global i32
34 @0 = external global i32
35 ; CHECK-DAG: @Inte = global i32 1
36 @Inte = global i32 1
37
38 ; Intern1 is intern in both files, rename testlink2's.
39 ; CHECK-DAG: @Intern1 = internal constant i32 42
40 @Intern1 = internal constant i32 42
41
42 ; This should get renamed since there is a definition that is non-internal in
43 ; the other module.
44 ; CHECK-DAG: @Intern2{{[0-9]+}} = internal constant i32 792
45 @Intern2 = internal constant i32 792
46
47
48 ; CHECK-DAG: @MyVarPtr = linkonce global { i32* } { i32* @MyVar }
49 @MyVarPtr = linkonce global { i32* } { i32* @MyVar }
50
51 ; CHECK-DAG: @MyVar = global i32 4
52 @MyVar = external global i32
53
54 ; Take value from other module.
55 ; CHECK-DAG: AConst = constant i32 1234
56 @AConst = linkonce constant i32 123
57
58 ; Renamed version of Intern1.
59 ; CHECK-DAG: @Intern1{{[0-9]+}} = internal constant i32 52
60
61
62 ; Globals linked from testlink2.
63 ; CHECK-DAG: @Intern2 = constant i32 12345
64
65 ; CHECK-DAG: @MyIntListPtr = constant
66 ; CHECK-DAG: @1 = constant i32 412
67
68
69 declare i32 @foo(i32)
70
71 declare void @print(i32)
72
73 define void @main() {
74   %v1 = load i32* @MyVar
75   call void @print(i32 %v1)
76   %idx = getelementptr %intlist* @MyIntList, i64 0, i32 1
77   %v2 = load i32* %idx
78   call void @print(i32 %v2)
79   %1 = call i32 @foo(i32 5)
80   %v3 = load i32* @MyVar
81   call void @print(i32 %v3)
82   %v4 = load i32* %idx
83   call void @print(i32 %v4)
84   ret void
85 }
86
87 define internal void @testintern() {
88   ret void
89 }
90
91 define internal void @Testintern() {
92   ret void
93 }
94
95 define void @testIntern() {
96   ret void
97 }
98
99 declare void @VecSizeCrash(%VecSize)