blob: a8746379b6cf14414b6914d68246c4dc16174a32 [file] [log] [blame]
Tanya Lattnerceca1942008-03-10 07:21:50 +00001; RUN: llvm-as < %s > %t.bc
2; RUN: llvm-as < %p/testlink2.ll > %t2.bc
Chris Lattner1afcace2011-07-09 17:41:24 +00003; RUN: llvm-link %t.bc %t2.bc -S | FileCheck %s
Chris Lattner285c68d2001-10-13 07:15:38 +00004
Chris Lattner1afcace2011-07-09 17:41:24 +00005; CHECK: %Ty2 = type { %Ty1* }
6; CHECK: %Ty1 = type { %Ty2* }
7%Ty1 = type opaque
8%Ty2 = type { %Ty1* }
9
10; CHECK: %intlist = type { %intlist*, i32 }
11%intlist = type { %intlist*, i32 }
12
13; The uses of intlist in the other file should be remapped.
14; CHECK-NOT: {{%intlist.[0-9]}}
15
16%Struct1 = type opaque
17@S1GV = external global %Struct1*
18
19
20@GVTy1 = external global %Ty1*
21@GVTy2 = global %Ty2* null
22
23
24; This should stay the same
25; CHECK: @MyIntList = global %intlist { %intlist* null, i32 17 }
26@MyIntList = global %intlist { %intlist* null, i32 17 }
27
28
29; Nothing to link here.
30
31; CHECK: @0 = external global i32
32@0 = external global i32
33; CHECK: @Inte = global i32 1
34@Inte = global i32 1
35
36; Intern1 is intern in both files, rename testlink2's.
37; CHECK: @Intern1 = internal constant i32 42
38@Intern1 = internal constant i32 42
39
40; This should get renamed since there is a definition that is non-internal in
41; the other module.
42; CHECK: @Intern2{{[0-9]+}} = internal constant i32 792
43@Intern2 = internal constant i32 792
44
45
46; CHECK: @MyVarPtr = linkonce global { i32* } { i32* @MyVar }
47@MyVarPtr = linkonce global { i32* } { i32* @MyVar }
48
49; CHECK: @MyVar = global i32 4
50@MyVar = external global i32
51
52; Take value from other module.
53; CHECK: AConst = constant i32 1234
54@AConst = linkonce constant i32 123
55
56; Renamed version of Intern1.
57; CHECK: @Intern1{{[0-9]+}} = internal constant i32 52
58
59
60; Globals linked from testlink2.
61; CHECK: @Intern2 = constant i32 12345
62
63; CHECK: @MyIntListPtr = constant
64; CHECK: @1 = constant i32 412
65
Chris Lattner285c68d2001-10-13 07:15:38 +000066
Tanya Lattnerceca1942008-03-10 07:21:50 +000067declare i32 @foo(i32)
Andrew Lenharthc8782ad2006-12-15 17:34:37 +000068
Tanya Lattnerceca1942008-03-10 07:21:50 +000069declare void @print(i32)
Chris Lattner285c68d2001-10-13 07:15:38 +000070
Tanya Lattnerceca1942008-03-10 07:21:50 +000071define void @main() {
Chris Lattner1afcace2011-07-09 17:41:24 +000072 %v1 = load i32* @MyVar
73 call void @print(i32 %v1)
74 %idx = getelementptr %intlist* @MyIntList, i64 0, i32 1
75 %v2 = load i32* %idx
76 call void @print(i32 %v2)
77 %1 = call i32 @foo(i32 5)
78 %v3 = load i32* @MyVar
79 call void @print(i32 %v3)
80 %v4 = load i32* %idx
81 call void @print(i32 %v4)
82 ret void
Tanya Lattnerceca1942008-03-10 07:21:50 +000083}
Chris Lattner285c68d2001-10-13 07:15:38 +000084
Tanya Lattnerceca1942008-03-10 07:21:50 +000085define internal void @testintern() {
Chris Lattner1afcace2011-07-09 17:41:24 +000086 ret void
Tanya Lattnerceca1942008-03-10 07:21:50 +000087}
Chris Lattnerb4b07c72001-11-26 19:17:06 +000088
Tanya Lattnerceca1942008-03-10 07:21:50 +000089define internal void @Testintern() {
Chris Lattner1afcace2011-07-09 17:41:24 +000090 ret void
Tanya Lattnerceca1942008-03-10 07:21:50 +000091}
92
93define void @testIntern() {
Chris Lattner1afcace2011-07-09 17:41:24 +000094 ret void
Tanya Lattnerceca1942008-03-10 07:21:50 +000095}