blob: 6a316a3bf846c16b63e5996d785af6c2356caf69 [file] [log] [blame]
Rafael Espindolad8e637e2014-11-24 20:35:59 +00001; RUN: llvm-link %s %S/Inputs/testlink.ll -S | FileCheck %s
Chris Lattner285c68d2001-10-13 07:15:38 +00002
Chris Lattner1afcace2011-07-09 17:41:24 +00003; 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
Joey Gouly2b8f6ae2013-01-10 10:49:36 +000014; CHECK: %VecSize = type { <5 x i32> }
15; CHECK: %VecSize.{{[0-9]}} = type { <10 x i32> }
16%VecSize = type { <5 x i32> }
17
Chris Lattner1afcace2011-07-09 17:41:24 +000018%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
Rafael Espindolae77177b2014-12-08 16:46:52 +000027; CHECK-DAG: @MyIntList = global %intlist { %intlist* null, i32 17 }
Chris Lattner1afcace2011-07-09 17:41:24 +000028@MyIntList = global %intlist { %intlist* null, i32 17 }
29
30
31; Nothing to link here.
32
Rafael Espindolae77177b2014-12-08 16:46:52 +000033; CHECK-DAG: @0 = external global i32
Chris Lattner1afcace2011-07-09 17:41:24 +000034@0 = external global i32
Rafael Espindola0178d232015-12-07 16:31:41 +000035
36define i32* @use0() {
37 ret i32* @0
38}
39
Rafael Espindolae77177b2014-12-08 16:46:52 +000040; CHECK-DAG: @Inte = global i32 1
Chris Lattner1afcace2011-07-09 17:41:24 +000041@Inte = global i32 1
42
43; Intern1 is intern in both files, rename testlink2's.
Rafael Espindolae77177b2014-12-08 16:46:52 +000044; CHECK-DAG: @Intern1 = internal constant i32 42
Chris Lattner1afcace2011-07-09 17:41:24 +000045@Intern1 = internal constant i32 42
46
Rafael Espindola7fd7eff2014-12-08 18:45:16 +000047@UseIntern1 = global i32* @Intern1
48
Chris Lattner1afcace2011-07-09 17:41:24 +000049; This should get renamed since there is a definition that is non-internal in
50; the other module.
Rafael Espindolaa2197f82015-11-22 00:16:24 +000051; CHECK-DAG: @Intern2.{{[0-9]+}} = internal constant i32 792
Chris Lattner1afcace2011-07-09 17:41:24 +000052@Intern2 = internal constant i32 792
53
Rafael Espindola7fd7eff2014-12-08 18:45:16 +000054@UseIntern2 = global i32* @Intern2
Chris Lattner1afcace2011-07-09 17:41:24 +000055
Rafael Espindolae77177b2014-12-08 16:46:52 +000056; CHECK-DAG: @MyVarPtr = linkonce global { i32* } { i32* @MyVar }
Chris Lattner1afcace2011-07-09 17:41:24 +000057@MyVarPtr = linkonce global { i32* } { i32* @MyVar }
58
Rafael Espindola7fd7eff2014-12-08 18:45:16 +000059@UseMyVarPtr = global { i32* }* @MyVarPtr
60
Rafael Espindolae77177b2014-12-08 16:46:52 +000061; CHECK-DAG: @MyVar = global i32 4
Chris Lattner1afcace2011-07-09 17:41:24 +000062@MyVar = external global i32
63
64; Take value from other module.
Rafael Espindolae77177b2014-12-08 16:46:52 +000065; CHECK-DAG: AConst = constant i32 1234
Chris Lattner1afcace2011-07-09 17:41:24 +000066@AConst = linkonce constant i32 123
67
68; Renamed version of Intern1.
Sunil Srivastava561c44f2015-05-12 16:47:30 +000069; CHECK-DAG: @Intern1.{{[0-9]+}} = internal constant i32 52
Chris Lattner1afcace2011-07-09 17:41:24 +000070
71
72; Globals linked from testlink2.
Rafael Espindolae77177b2014-12-08 16:46:52 +000073; CHECK-DAG: @Intern2 = constant i32 12345
Chris Lattner1afcace2011-07-09 17:41:24 +000074
Rafael Espindolae77177b2014-12-08 16:46:52 +000075; CHECK-DAG: @MyIntListPtr = constant
76; CHECK-DAG: @1 = constant i32 412
Chris Lattner1afcace2011-07-09 17:41:24 +000077
Chris Lattner285c68d2001-10-13 07:15:38 +000078
Tanya Lattnerceca1942008-03-10 07:21:50 +000079declare i32 @foo(i32)
Andrew Lenharthc8782ad2006-12-15 17:34:37 +000080
Tanya Lattnerceca1942008-03-10 07:21:50 +000081declare void @print(i32)
Chris Lattner285c68d2001-10-13 07:15:38 +000082
Tanya Lattnerceca1942008-03-10 07:21:50 +000083define void @main() {
David Blaikie7c9c6ed2015-02-27 21:17:42 +000084 %v1 = load i32, i32* @MyVar
Chris Lattner1afcace2011-07-09 17:41:24 +000085 call void @print(i32 %v1)
David Blaikie198d8ba2015-02-27 19:29:02 +000086 %idx = getelementptr %intlist, %intlist* @MyIntList, i64 0, i32 1
David Blaikie7c9c6ed2015-02-27 21:17:42 +000087 %v2 = load i32, i32* %idx
Chris Lattner1afcace2011-07-09 17:41:24 +000088 call void @print(i32 %v2)
89 %1 = call i32 @foo(i32 5)
David Blaikie7c9c6ed2015-02-27 21:17:42 +000090 %v3 = load i32, i32* @MyVar
Chris Lattner1afcace2011-07-09 17:41:24 +000091 call void @print(i32 %v3)
David Blaikie7c9c6ed2015-02-27 21:17:42 +000092 %v4 = load i32, i32* %idx
Chris Lattner1afcace2011-07-09 17:41:24 +000093 call void @print(i32 %v4)
94 ret void
Tanya Lattnerceca1942008-03-10 07:21:50 +000095}
Chris Lattner285c68d2001-10-13 07:15:38 +000096
Tanya Lattnerceca1942008-03-10 07:21:50 +000097define internal void @testintern() {
Chris Lattner1afcace2011-07-09 17:41:24 +000098 ret void
Tanya Lattnerceca1942008-03-10 07:21:50 +000099}
Chris Lattnerb4b07c72001-11-26 19:17:06 +0000100
Tanya Lattnerceca1942008-03-10 07:21:50 +0000101define internal void @Testintern() {
Chris Lattner1afcace2011-07-09 17:41:24 +0000102 ret void
Tanya Lattnerceca1942008-03-10 07:21:50 +0000103}
104
105define void @testIntern() {
Chris Lattner1afcace2011-07-09 17:41:24 +0000106 ret void
Tanya Lattnerceca1942008-03-10 07:21:50 +0000107}
Joey Gouly2b8f6ae2013-01-10 10:49:36 +0000108
Rafael Espindola0178d232015-12-07 16:31:41 +0000109define void @VecSizeCrash(%VecSize) {
110 ret void
111}