aboutsummaryrefslogtreecommitdiff
path: root/test/Linker
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-06-02 17:52:33 +0000
committerEd Schouten <ed@FreeBSD.org>2009-06-02 17:52:33 +0000
commit009b1c42aa6266385f2c37e227516b24077e6dd7 (patch)
tree64ba909838c23261cace781ece27d106134ea451 /test/Linker
downloadsrc-009b1c42aa6266385f2c37e227516b24077e6dd7.tar.gz
src-009b1c42aa6266385f2c37e227516b24077e6dd7.zip
Import LLVM, at r72732.vendor/llvm/llvm-r72732
Notes
Notes: svn path=/vendor/llvm/dist/; revision=193323 svn path=/vendor/llvm/llvm-r72732/; revision=193324; tag=vendor/llvm/llvm-r72732
Diffstat (limited to 'test/Linker')
-rw-r--r--test/Linker/2002-07-17-GlobalFail.ll8
-rw-r--r--test/Linker/2002-07-17-LinkTest2.ll10
-rw-r--r--test/Linker/2002-08-20-ConstantExpr.ll9
-rw-r--r--test/Linker/2003-01-30-LinkerRename.ll9
-rw-r--r--test/Linker/2003-01-30-LinkerTypeRename.ll9
-rw-r--r--test/Linker/2003-04-21-Linkage.ll14
-rw-r--r--test/Linker/2003-04-23-LinkOnceLost.ll10
-rw-r--r--test/Linker/2003-04-26-NullPtrLinkProblem.ll17
-rw-r--r--test/Linker/2003-05-15-TypeProblem.ll10
-rw-r--r--test/Linker/2003-05-31-LinkerRename.ll17
-rw-r--r--test/Linker/2003-06-02-TypeResolveProblem.ll7
-rw-r--r--test/Linker/2003-06-02-TypeResolveProblem2.ll7
-rw-r--r--test/Linker/2003-08-20-OpaqueTypeResolve.ll8
-rw-r--r--test/Linker/2003-08-23-GlobalVarLinking.ll10
-rw-r--r--test/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll9
-rw-r--r--test/Linker/2003-08-24-InheritPtrSize.ll9
-rw-r--r--test/Linker/2003-08-28-TypeResolvesGlobal.ll12
-rw-r--r--test/Linker/2003-08-28-TypeResolvesGlobal2.ll18
-rw-r--r--test/Linker/2003-08-28-TypeResolvesGlobal3.ll15
-rw-r--r--test/Linker/2003-10-21-ConflictingTypesTolerance.ll6
-rw-r--r--test/Linker/2003-10-27-LinkOncePromote.ll8
-rw-r--r--test/Linker/2003-11-18-TypeResolution.ll20
-rw-r--r--test/Linker/2004-02-17-WeakStrongLinkage.ll7
-rw-r--r--test/Linker/2004-05-07-TypeResolution1.ll35
-rw-r--r--test/Linker/2004-05-07-TypeResolution2.ll15
-rw-r--r--test/Linker/2004-12-03-DisagreeingType.ll9
-rw-r--r--test/Linker/2005-02-12-ConstantGlobals-2.ll8
-rw-r--r--test/Linker/2005-02-12-ConstantGlobals.ll8
-rw-r--r--test/Linker/2005-12-06-AppendingZeroLengthArrays.ll10
-rw-r--r--test/Linker/2006-01-19-ConstantPacked.ll13
-rw-r--r--test/Linker/2006-06-15-GlobalVarAlignment.ll7
-rw-r--r--test/Linker/2008-03-05-AliasReference.ll17
-rw-r--r--test/Linker/2008-03-05-AliasReference2.ll11
-rw-r--r--test/Linker/2008-03-07-DroppedSection_a.ll11
-rw-r--r--test/Linker/2008-03-07-DroppedSection_b.ll10
-rw-r--r--test/Linker/2008-06-13-LinkOnceRedefinition.ll8
-rw-r--r--test/Linker/2008-06-26-AddressSpace.ll9
-rw-r--r--test/Linker/2008-07-06-AliasFnDecl.ll14
-rw-r--r--test/Linker/2008-07-06-AliasFnDecl2.ll13
-rw-r--r--test/Linker/2008-07-06-AliasWeakDest.ll18
-rw-r--r--test/Linker/2008-07-06-AliasWeakDest2.ll18
-rw-r--r--test/Linker/AppendingLinkage.ll15
-rw-r--r--test/Linker/AppendingLinkage2.ll8
-rw-r--r--test/Linker/ConstantGlobals1.ll9
-rw-r--r--test/Linker/ConstantGlobals2.ll9
-rw-r--r--test/Linker/ConstantGlobals3.ll8
-rw-r--r--test/Linker/LinkOnce.ll8
-rw-r--r--test/Linker/basiclink.ll13
-rw-r--r--test/Linker/dg.exp3
-rw-r--r--test/Linker/link-archive.ll15
-rw-r--r--test/Linker/link-global-to-func.ll13
-rw-r--r--test/Linker/link-messages.ll11
-rw-r--r--test/Linker/redefinition.ll10
-rw-r--r--test/Linker/testlink1.ll42
-rw-r--r--test/Linker/testlink2.ll41
-rw-r--r--test/Linker/weakextern.ll11
56 files changed, 699 insertions, 0 deletions
diff --git a/test/Linker/2002-07-17-GlobalFail.ll b/test/Linker/2002-07-17-GlobalFail.ll
new file mode 100644
index 000000000000..d3283106f6ec
--- /dev/null
+++ b/test/Linker/2002-07-17-GlobalFail.ll
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s > %t.bc
+; RUN: echo | llvm-as > %t.tmp.bc
+; RUN: llvm-link %t.tmp.bc %t.bc
+
+@X = constant i32 5 ; <i32*> [#uses=2]
+@Y = internal global [2 x i32*] [ i32* @X, i32* @X ] ; <[2 x i32*]*> [#uses=0]
+
+
diff --git a/test/Linker/2002-07-17-LinkTest2.ll b/test/Linker/2002-07-17-LinkTest2.ll
new file mode 100644
index 000000000000..fa986f157285
--- /dev/null
+++ b/test/Linker/2002-07-17-LinkTest2.ll
@@ -0,0 +1,10 @@
+; This fails linking when it is linked with an empty file as the first object file
+
+; RUN: llvm-as > %t1.bc < /dev/null
+; RUN: llvm-as < %s > %t2.bc
+; RUN: llvm-link %t1.bc %t2.bc
+
+@work = global i32 (i32, i32)* @zip ; <i32 (i32, i32)**> [#uses=0]
+
+declare i32 @zip(i32, i32)
+
diff --git a/test/Linker/2002-08-20-ConstantExpr.ll b/test/Linker/2002-08-20-ConstantExpr.ll
new file mode 100644
index 000000000000..5672014ff663
--- /dev/null
+++ b/test/Linker/2002-08-20-ConstantExpr.ll
@@ -0,0 +1,9 @@
+; This fails linking when it is linked with an empty file as the first object file
+
+; RUN: llvm-as > %t.LinkTest.bc < /dev/null
+; RUN: llvm-as < %s > %t.bc
+; RUN: llvm-link %t.LinkTest.bc %t.bc
+
+@work = global i32 4 ; <i32*> [#uses=1]
+@test = global i32* getelementptr (i32* @work, i64 1) ; <i32**> [#uses=0]
+
diff --git a/test/Linker/2003-01-30-LinkerRename.ll b/test/Linker/2003-01-30-LinkerRename.ll
new file mode 100644
index 000000000000..68812467e781
--- /dev/null
+++ b/test/Linker/2003-01-30-LinkerRename.ll
@@ -0,0 +1,9 @@
+; This fails because the linker renames the external symbol not the internal
+; one...
+
+; RUN: echo {define internal i32 @foo() \{ ret i32 7 \} } | llvm-as > %t.1.bc
+; RUN: llvm-as %s -o %t.2.bc -f
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep @foo() | grep -v internal
+
+define i32 @foo() { ret i32 0 }
+
diff --git a/test/Linker/2003-01-30-LinkerTypeRename.ll b/test/Linker/2003-01-30-LinkerTypeRename.ll
new file mode 100644
index 000000000000..288daf1cba1c
--- /dev/null
+++ b/test/Linker/2003-01-30-LinkerTypeRename.ll
@@ -0,0 +1,9 @@
+; This fails because the linker renames the non-opaque type not the opaque
+; one...
+
+; RUN: echo {%Ty = type opaque @GV = external global %Ty*} | llvm-as > %t.1.bc
+; RUN: llvm-as < %s > %t.2.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep {%Ty } | not grep opaque
+
+%Ty = type i32
+
diff --git a/test/Linker/2003-04-21-Linkage.ll b/test/Linker/2003-04-21-Linkage.ll
new file mode 100644
index 000000000000..31aace8e44c4
--- /dev/null
+++ b/test/Linker/2003-04-21-Linkage.ll
@@ -0,0 +1,14 @@
+; RUN: echo {@X = linkonce global i32 5 \
+; RUN: define linkonce i32 @foo() \{ ret i32 7 \} } | llvm-as > %t.1.bc
+; RUN: llvm-as %s -o %t.2.bc -f
+; RUN: llvm-link %t.1.bc %t.2.bc
+@X = external global i32
+
+declare i32 @foo()
+
+define void @bar() {
+ load i32* @X
+ call i32 @foo()
+ ret void
+}
+
diff --git a/test/Linker/2003-04-23-LinkOnceLost.ll b/test/Linker/2003-04-23-LinkOnceLost.ll
new file mode 100644
index 000000000000..d0858d95ab1c
--- /dev/null
+++ b/test/Linker/2003-04-23-LinkOnceLost.ll
@@ -0,0 +1,10 @@
+; This fails because the linker renames the non-opaque type not the opaque
+; one...
+
+; RUN: echo { define linkonce void @foo() \{ ret void \} } | \
+; RUN: llvm-as -o %t.2.bc -f
+; RUN: llvm-as %s -o %t.1.bc -f
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep foo | grep linkonce
+
+declare void @foo()
+
diff --git a/test/Linker/2003-04-26-NullPtrLinkProblem.ll b/test/Linker/2003-04-26-NullPtrLinkProblem.ll
new file mode 100644
index 000000000000..df12fb3a7a57
--- /dev/null
+++ b/test/Linker/2003-04-26-NullPtrLinkProblem.ll
@@ -0,0 +1,17 @@
+; This one fails because the LLVM runtime is allowing two null pointers of
+; the same type to be created!
+
+; RUN: echo {%T = type i32} | llvm-as > %t.2.bc
+; RUN: llvm-as %s -f -o %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc
+
+%T = type opaque
+
+declare %T* @create()
+
+define void @test() {
+ %X = call %T* @create( ) ; <%T*> [#uses=1]
+ %v = icmp eq %T* %X, null ; <i1> [#uses=0]
+ ret void
+}
+
diff --git a/test/Linker/2003-05-15-TypeProblem.ll b/test/Linker/2003-05-15-TypeProblem.ll
new file mode 100644
index 000000000000..e914a69e34fb
--- /dev/null
+++ b/test/Linker/2003-05-15-TypeProblem.ll
@@ -0,0 +1,10 @@
+; This one fails because the LLVM runtime is allowing two null pointers of
+; the same type to be created!
+
+; RUN: echo {%S = type \{ %T*\} %T = type opaque} | llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc
+
+%S = type { i32* }
+%T = type i32
+
diff --git a/test/Linker/2003-05-31-LinkerRename.ll b/test/Linker/2003-05-31-LinkerRename.ll
new file mode 100644
index 000000000000..c3661ae9aa3b
--- /dev/null
+++ b/test/Linker/2003-05-31-LinkerRename.ll
@@ -0,0 +1,17 @@
+; The funcresolve pass will (intentionally) llvm-link an _internal_ function
+; body with an external declaration. Because of this, if we LINK an internal
+; function body into a program that already has an external declaration for
+; the function name, we must rename the internal function to something that
+; does not conflict.
+
+; RUN: echo { define internal i32 @foo() \{ ret i32 7 \} } | llvm-as > %t.1.bc
+; RUN: llvm-as < %s > %t.2.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep internal | not grep @foo(
+
+declare i32 @foo()
+
+define i32 @test() {
+ %X = call i32 @foo()
+ ret i32 %X
+}
+
diff --git a/test/Linker/2003-06-02-TypeResolveProblem.ll b/test/Linker/2003-06-02-TypeResolveProblem.ll
new file mode 100644
index 000000000000..86979f60d172
--- /dev/null
+++ b/test/Linker/2003-06-02-TypeResolveProblem.ll
@@ -0,0 +1,7 @@
+; RUN: echo {%T = type opaque} | llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc
+
+%T = type opaque
+@a = constant { %T* } zeroinitializer ; <{ %T* }*> [#uses=0]
+
diff --git a/test/Linker/2003-06-02-TypeResolveProblem2.ll b/test/Linker/2003-06-02-TypeResolveProblem2.ll
new file mode 100644
index 000000000000..42cc0403ae77
--- /dev/null
+++ b/test/Linker/2003-06-02-TypeResolveProblem2.ll
@@ -0,0 +1,7 @@
+; RUN: echo {%T = type i32} | llvm-as > %t.1.bc
+; RUN: llvm-as < %s > %t.2.bc
+; RUN: llvm-link %t.1.bc %t.2.bc
+
+%T = type opaque
+@X = constant { %T* } zeroinitializer ; <{ %T* }*> [#uses=0]
+
diff --git a/test/Linker/2003-08-20-OpaqueTypeResolve.ll b/test/Linker/2003-08-20-OpaqueTypeResolve.ll
new file mode 100644
index 000000000000..a4d4bd543abe
--- /dev/null
+++ b/test/Linker/2003-08-20-OpaqueTypeResolve.ll
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s > %t.out1.bc
+; RUN: echo {%S = type \{ i32, i32* \} } | llvm-as > %t.out2.bc
+; RUN: llvm-link %t.out1.bc %t.out2.bc
+
+%S = type { i32, %T* }
+%T = type opaque
+
+;%X = global { int, %T* } { int 5, %T* null }
diff --git a/test/Linker/2003-08-23-GlobalVarLinking.ll b/test/Linker/2003-08-23-GlobalVarLinking.ll
new file mode 100644
index 000000000000..fd36d0422a69
--- /dev/null
+++ b/test/Linker/2003-08-23-GlobalVarLinking.ll
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s > %t.out1.bc
+; RUN: echo {@S = external global \{ i32, opaque* \} declare void @F(opaque*)}\
+; RUN: | llvm-as > %t.out2.bc
+; RUN: llvm-link %t.out1.bc %t.out2.bc | llvm-dis | not grep opaque
+
+; After linking this testcase, there should be no opaque types left. The two
+; S's should cause the opaque type to be resolved to 'int'.
+@S = global { i32, i32* } { i32 5, i32* null } ; <{ i32, i32* }*> [#uses=0]
+
+declare void @F(i32*)
diff --git a/test/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll b/test/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll
new file mode 100644
index 000000000000..5041467604ae
--- /dev/null
+++ b/test/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll
@@ -0,0 +1,9 @@
+; It's a bad idea to go recursively traipsing through types without a safety
+; net.
+
+; RUN: llvm-as < %s > %t.out1.bc
+; RUN: echo "%S = type { %S*, i32* }" | llvm-as > %t.out2.bc
+; RUN: llvm-link %t.out1.bc %t.out2.bc
+
+%S = type { %S*, opaque* }
+
diff --git a/test/Linker/2003-08-24-InheritPtrSize.ll b/test/Linker/2003-08-24-InheritPtrSize.ll
new file mode 100644
index 000000000000..f93c054dec7b
--- /dev/null
+++ b/test/Linker/2003-08-24-InheritPtrSize.ll
@@ -0,0 +1,9 @@
+; Linking a module with a specified pointer size to one without a
+; specified pointer size should not cause a warning!
+
+; RUN: llvm-as < %s > %t.out1.bc
+; RUN: echo {} | llvm-as > %t.out2.bc
+; RUN: llvm-link %t.out1.bc %t.out2.bc |& not grep warning
+
+target datalayout = "e-p:64:64"
+
diff --git a/test/Linker/2003-08-28-TypeResolvesGlobal.ll b/test/Linker/2003-08-28-TypeResolvesGlobal.ll
new file mode 100644
index 000000000000..5526b87ce77d
--- /dev/null
+++ b/test/Linker/2003-08-28-TypeResolvesGlobal.ll
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s > %t.out1.bc
+; RUN: echo "%S = type i32" | llvm-as > %t.out2.bc
+; RUN: llvm-link %t.out2.bc %t.out1.bc
+
+%S = type opaque
+
+define void @foo(i32* %V) {
+ ret void
+}
+
+declare void @foo.upgrd.1(%S*)
+
diff --git a/test/Linker/2003-08-28-TypeResolvesGlobal2.ll b/test/Linker/2003-08-28-TypeResolvesGlobal2.ll
new file mode 100644
index 000000000000..3f306b167b1d
--- /dev/null
+++ b/test/Linker/2003-08-28-TypeResolvesGlobal2.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-as < %s > %t.out1.bc
+; RUN: echo "%S = type i32" | llvm-as > %t.out2.bc
+; RUN: llvm-link %t.out2.bc %t.out1.bc
+
+%S = type opaque
+
+define void @foo(i32* %V) {
+ ret void
+}
+
+declare void @foo.upgrd.1(%S*)
+
+define void @other() {
+ call void @foo.upgrd.1( %S* null )
+ call void @foo( i32* null )
+ ret void
+}
+
diff --git a/test/Linker/2003-08-28-TypeResolvesGlobal3.ll b/test/Linker/2003-08-28-TypeResolvesGlobal3.ll
new file mode 100644
index 000000000000..38b7851ab860
--- /dev/null
+++ b/test/Linker/2003-08-28-TypeResolvesGlobal3.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s > %t.out1.bc
+; RUN: echo "%S = type i32" | llvm-as > %t.out2.bc
+; RUN: llvm-link %t.out2.bc %t.out1.bc
+
+%S = type opaque
+
+; GLobal using the resolved function prototype
+global void (%S*)* @foo ; <void (%S*)**>:0 [#uses=0]
+
+define void @foo.upgrd.1(i32* %V) {
+ ret void
+}
+
+declare void @foo(%S*)
+
diff --git a/test/Linker/2003-10-21-ConflictingTypesTolerance.ll b/test/Linker/2003-10-21-ConflictingTypesTolerance.ll
new file mode 100644
index 000000000000..4f98a2003253
--- /dev/null
+++ b/test/Linker/2003-10-21-ConflictingTypesTolerance.ll
@@ -0,0 +1,6 @@
+; RUN: llvm-as < %s > %t.out1.bc
+; RUN: echo { %S = type \[8 x i32\] external global %S } | llvm-as > %t.out2.bc
+; RUN: llvm-link %t.out1.bc %t.out2.bc | llvm-dis | grep %S | grep \\{
+%S = type { i32 }
+
+
diff --git a/test/Linker/2003-10-27-LinkOncePromote.ll b/test/Linker/2003-10-27-LinkOncePromote.ll
new file mode 100644
index 000000000000..f2d465ed80ea
--- /dev/null
+++ b/test/Linker/2003-10-27-LinkOncePromote.ll
@@ -0,0 +1,8 @@
+; The linker should merge link-once globals into strong external globals,
+; just like it does for weak symbols!
+
+; RUN: echo "@X = global i32 7" | llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc
+
+@X = linkonce global i32 7
diff --git a/test/Linker/2003-11-18-TypeResolution.ll b/test/Linker/2003-11-18-TypeResolution.ll
new file mode 100644
index 000000000000..d3152eda8e98
--- /dev/null
+++ b/test/Linker/2003-11-18-TypeResolution.ll
@@ -0,0 +1,20 @@
+; Linking these two translation units causes there to be two LLVM values in the
+; symbol table with the same name and same type. When this occurs, the symbol
+; table class is DROPPING one of the values, instead of renaming it like a nice
+; little symbol table. This is causing llvm-link to die, at no fault of its
+; own.
+
+; RUN: llvm-as < %s > %t.out2.bc
+; RUN: echo "%T1 = type opaque @GVar = external global %T1*" | llvm-as > %t.out1.bc
+; RUN: llvm-link %t.out1.bc %t.out2.bc
+
+%T1 = type opaque
+%T2 = type i32
+@GVar = global i32* null ; <i32**> [#uses=0]
+
+define void @foo(i32* %X) {
+ %X.upgrd.1 = bitcast i32* %X to %T1* ; <%T1*> [#uses=0]
+ ret void
+}
+
+
diff --git a/test/Linker/2004-02-17-WeakStrongLinkage.ll b/test/Linker/2004-02-17-WeakStrongLinkage.ll
new file mode 100644
index 000000000000..0e970ddb489a
--- /dev/null
+++ b/test/Linker/2004-02-17-WeakStrongLinkage.ll
@@ -0,0 +1,7 @@
+; RUN: llvm-as < %s > %t.out2.bc
+; RUN: echo "@me = global i32* null" | llvm-as > %t.out1.bc
+; RUN: llvm-link %t.out1.bc %t.out2.bc -o /dev/null -f
+
+@me = weak global i32* null ; <i32**> [#uses=0]
+
+
diff --git a/test/Linker/2004-05-07-TypeResolution1.ll b/test/Linker/2004-05-07-TypeResolution1.ll
new file mode 100644
index 000000000000..36651541e4d7
--- /dev/null
+++ b/test/Linker/2004-05-07-TypeResolution1.ll
@@ -0,0 +1,35 @@
+; RUN: llvm-as %s -f -o %t1.bc
+; RUN: llvm-as < %p/2004-05-07-TypeResolution2.ll -o %t2.bc -f
+; RUN: llvm-link -f -o %t3.bc %t1.bc %t2.bc
+
+target datalayout = "e-p:32:32"
+ %myint = type opaque
+ %struct1 = type { i32, void (%struct2*)*, %myint*, i32 (i32*)* }
+ %struct2 = type { %struct1 }
+@driver1 = global %struct1 zeroinitializer ; <%struct1*> [#uses=1]
+@m1 = external global [1 x i8]* ; <[1 x i8]**> [#uses=0]
+@str1 = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=0]
+@str2 = constant [2 x i8] zeroinitializer ; <[2 x i8]*> [#uses=0]
+@str3 = constant [3 x i8] zeroinitializer ; <[3 x i8]*> [#uses=0]
+@str4 = constant [4 x i8] zeroinitializer ; <[4 x i8]*> [#uses=0]
+@str5 = constant [5 x i8] zeroinitializer ; <[5 x i8]*> [#uses=0]
+@str6 = constant [6 x i8] zeroinitializer ; <[6 x i8]*> [#uses=0]
+@str7 = constant [7 x i8] zeroinitializer ; <[7 x i8]*> [#uses=0]
+@str8 = constant [8 x i8] zeroinitializer ; <[8 x i8]*> [#uses=0]
+@str9 = constant [9 x i8] zeroinitializer ; <[9 x i8]*> [#uses=0]
+@stra = constant [10 x i8] zeroinitializer ; <[10 x i8]*> [#uses=0]
+@strb = constant [11 x i8] zeroinitializer ; <[11 x i8]*> [#uses=0]
+@strc = constant [12 x i8] zeroinitializer ; <[12 x i8]*> [#uses=0]
+@strd = constant [13 x i8] zeroinitializer ; <[13 x i8]*> [#uses=0]
+@stre = constant [14 x i8] zeroinitializer ; <[14 x i8]*> [#uses=0]
+@strf = constant [15 x i8] zeroinitializer ; <[15 x i8]*> [#uses=0]
+@strg = constant [16 x i8] zeroinitializer ; <[16 x i8]*> [#uses=0]
+@strh = constant [17 x i8] zeroinitializer ; <[17 x i8]*> [#uses=0]
+
+declare void @func(%struct2*)
+
+define void @tty_init() {
+entry:
+ volatile store void (%struct2*)* @func, void (%struct2*)** getelementptr (%struct1* @driver1, i64 0, i32 1)
+ ret void
+}
diff --git a/test/Linker/2004-05-07-TypeResolution2.ll b/test/Linker/2004-05-07-TypeResolution2.ll
new file mode 100644
index 000000000000..74fe39f4d9f4
--- /dev/null
+++ b/test/Linker/2004-05-07-TypeResolution2.ll
@@ -0,0 +1,15 @@
+; This file is used by testlink1.ll, so it doesn't actually do anything itself
+;
+; RUN: echo
+target datalayout = "e-p:32:32"
+ %myint = type i16
+ %struct1 = type { i32, void (%struct2*)*, i16*, i32 (i32*)* }
+ %struct2 = type { %struct1 }
+
+define internal void @f1(%struct1* %tty) {
+loopentry.preheader:
+ %tmp.2.i.i = getelementptr %struct1* %tty, i64 0, i32 1 ; <void (%struct2*)**> [#uses=1]
+ %tmp.3.i.i = volatile load void (%struct2*)** %tmp.2.i.i ; <void (%struct2*)*> [#uses=0]
+ ret void
+}
+
diff --git a/test/Linker/2004-12-03-DisagreeingType.ll b/test/Linker/2004-12-03-DisagreeingType.ll
new file mode 100644
index 000000000000..7378fdd35795
--- /dev/null
+++ b/test/Linker/2004-12-03-DisagreeingType.ll
@@ -0,0 +1,9 @@
+; RUN: echo {@G = weak global \{\{\{\{double\}\}\}\} zeroinitializer } | \
+; RUN: llvm-as > %t.out2.bc
+; RUN: llvm-as < %s > %t.out1.bc
+; RUN: llvm-link %t.out1.bc %t.out2.bc | llvm-dis | not grep {\\}}
+
+; When linked, the global above should be eliminated, being merged with the
+; global below.
+
+@G = global double 1.0
diff --git a/test/Linker/2005-02-12-ConstantGlobals-2.ll b/test/Linker/2005-02-12-ConstantGlobals-2.ll
new file mode 100644
index 000000000000..bedeb5106950
--- /dev/null
+++ b/test/Linker/2005-02-12-ConstantGlobals-2.ll
@@ -0,0 +1,8 @@
+; Test that a prototype can be marked const, and the definition is allowed
+; to be nonconst.
+
+; RUN: echo {@X = external constant i32} | llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep {global i32 7}
+
+@X = global i32 7
diff --git a/test/Linker/2005-02-12-ConstantGlobals.ll b/test/Linker/2005-02-12-ConstantGlobals.ll
new file mode 100644
index 000000000000..407737287369
--- /dev/null
+++ b/test/Linker/2005-02-12-ConstantGlobals.ll
@@ -0,0 +1,8 @@
+; Test that a prototype can be marked const, and the definition is allowed
+; to be nonconst.
+
+; RUN: echo {@X = global i32 7} | llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep {global i32 7}
+
+@X = external constant i32 ; <i32*> [#uses=0]
diff --git a/test/Linker/2005-12-06-AppendingZeroLengthArrays.ll b/test/Linker/2005-12-06-AppendingZeroLengthArrays.ll
new file mode 100644
index 000000000000..2637da17f3f9
--- /dev/null
+++ b/test/Linker/2005-12-06-AppendingZeroLengthArrays.ll
@@ -0,0 +1,10 @@
+; RUN: echo { @G = appending global \[0 x i32\] zeroinitializer } | \
+; RUN: llvm-as > %t.out2.bc
+; RUN: llvm-as < %s > %t.out1.bc
+; RUN: llvm-link %t.out1.bc %t.out2.bc | llvm-dis | grep {@G =}
+
+; When linked, the globals should be merged, and the result should still
+; be named '@G'.
+
+@G = appending global [1 x i32] zeroinitializer ; <[1 x i32]*> [#uses=0]
+
diff --git a/test/Linker/2006-01-19-ConstantPacked.ll b/test/Linker/2006-01-19-ConstantPacked.ll
new file mode 100644
index 000000000000..d7d864b41b16
--- /dev/null
+++ b/test/Linker/2006-01-19-ConstantPacked.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-as %s -f -o %t1.bc
+; RUN: llvm-link -f -o %t2.bc %t1.bc
+
+target datalayout = "E-p:32:32"
+target triple = "powerpc-apple-darwin7.7.0"
+deplibs = [ "c", "crtend" ]
+@source = global <4 x i32> < i32 0, i32 1, i32 2, i32 3 > ; <<4 x i32>*> [#uses=0]
+
+define i32 @main() {
+entry:
+ ret i32 0
+}
+
diff --git a/test/Linker/2006-06-15-GlobalVarAlignment.ll b/test/Linker/2006-06-15-GlobalVarAlignment.ll
new file mode 100644
index 000000000000..6e6d56a039ec
--- /dev/null
+++ b/test/Linker/2006-06-15-GlobalVarAlignment.ll
@@ -0,0 +1,7 @@
+; The linker should choose the largest alignment when linking.
+
+; RUN: echo {@X = global i32 7, align 8} | llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep {align 8}
+
+@X = weak global i32 7, align 4
diff --git a/test/Linker/2008-03-05-AliasReference.ll b/test/Linker/2008-03-05-AliasReference.ll
new file mode 100644
index 000000000000..1663b00845e5
--- /dev/null
+++ b/test/Linker/2008-03-05-AliasReference.ll
@@ -0,0 +1,17 @@
+; PR2054
+; RUN: llvm-as %s -o %t1.bc -f
+; RUN: llvm-as %p/2008-03-05-AliasReference2.ll -o %t2.bc -f
+; RUN: llvm-link %t2.bc %t1.bc -f -o %t3.bc
+
+; ModuleID = 'bug.o'
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+target triple = "x86_64-unknown-linux-gnu"
+@foo = weak global i32 0 ; <i32*> [#uses=1]
+
+@bar = alias weak i32* @foo ; <i32*> [#uses=1]
+
+define i32 @baz() nounwind {
+entry:
+ %tmp1 = load i32* @bar, align 4 ; <i32> [#uses=1]
+ ret i32 %tmp1
+}
diff --git a/test/Linker/2008-03-05-AliasReference2.ll b/test/Linker/2008-03-05-AliasReference2.ll
new file mode 100644
index 000000000000..05c0a25bb9d9
--- /dev/null
+++ b/test/Linker/2008-03-05-AliasReference2.ll
@@ -0,0 +1,11 @@
+; This file is used by 2008-03-05-AliasReference.ll
+; RUN: true
+
+; ModuleID = 'bug.o'
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @baz1() nounwind {
+entry:
+ ret i32 0
+}
diff --git a/test/Linker/2008-03-07-DroppedSection_a.ll b/test/Linker/2008-03-07-DroppedSection_a.ll
new file mode 100644
index 000000000000..4458971eba07
--- /dev/null
+++ b/test/Linker/2008-03-07-DroppedSection_a.ll
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s > %t.bc
+; RUN: llvm-as < %p/2008-03-07-DroppedSection_b.ll > %t2.bc
+; RUN: llvm-ld -r -disable-opt %t.bc %t2.bc -o %t3.bc
+; RUN: llvm-dis < %t3.bc | grep ".data.init_task"
+
+; ModuleID = 't.bc'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
+target triple = "i686-pc-linux-gnu"
+
+@init_task_union = global i32 1, section ".data.init_task", align 32
+
diff --git a/test/Linker/2008-03-07-DroppedSection_b.ll b/test/Linker/2008-03-07-DroppedSection_b.ll
new file mode 100644
index 000000000000..884bf0a27440
--- /dev/null
+++ b/test/Linker/2008-03-07-DroppedSection_b.ll
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s > %t.bc
+; RUN: llvm-as < %p/2008-03-07-DroppedSection_a.ll > %t2.bc
+; RUN: llvm-ld -r -disable-opt %t.bc %t2.bc -o %t3.bc
+; RUN: llvm-dis < %t3.bc | grep ".data.init_task"
+
+; ModuleID = 'u.bc'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
+target triple = "i686-pc-linux-gnu"
+@init_task_union = external global i32
+
diff --git a/test/Linker/2008-06-13-LinkOnceRedefinition.ll b/test/Linker/2008-06-13-LinkOnceRedefinition.ll
new file mode 100644
index 000000000000..3478880ebdac
--- /dev/null
+++ b/test/Linker/2008-06-13-LinkOnceRedefinition.ll
@@ -0,0 +1,8 @@
+; Test linking two functions with different prototypes and two globals
+; in different modules.
+; RUN: llvm-as %s -o %t.foo1.bc -f
+; RUN: llvm-as %s -o %t.foo2.bc -f
+; RUN: echo {define linkonce void @foo(i32 %x) { ret void }} | llvm-as -o %t.foo3.bc -f
+; RUN: llvm-link %t.foo1.bc %t.foo2.bc | llvm-dis
+; RUN: llvm-link %t.foo1.bc %t.foo3.bc | llvm-dis
+define linkonce void @foo() { ret void }
diff --git a/test/Linker/2008-06-26-AddressSpace.ll b/test/Linker/2008-06-26-AddressSpace.ll
new file mode 100644
index 000000000000..7f2110628e08
--- /dev/null
+++ b/test/Linker/2008-06-26-AddressSpace.ll
@@ -0,0 +1,9 @@
+; Test linking two functions with different prototypes and two globals
+; in different modules.
+; RUN: llvm-as %s -o %t.foo1.bc -f
+; RUN: echo | llvm-as -o %t.foo2.bc -f
+; RUN: llvm-link %t.foo2.bc %t.foo1.bc | llvm-dis | grep {addrspace(2)}
+; RUN: llvm-link %t.foo1.bc %t.foo2.bc | llvm-dis | grep {addrspace(2)}
+; rdar://6038021
+
+@G = addrspace(2) global i32 256
diff --git a/test/Linker/2008-07-06-AliasFnDecl.ll b/test/Linker/2008-07-06-AliasFnDecl.ll
new file mode 100644
index 000000000000..dca9cd8e8fa4
--- /dev/null
+++ b/test/Linker/2008-07-06-AliasFnDecl.ll
@@ -0,0 +1,14 @@
+; PR2146
+; RUN: llvm-as %s -o %t1.bc -f
+; RUN: llvm-as %p/2008-07-06-AliasFnDecl2.ll -o %t2.bc -f
+; RUN: llvm-link %t1.bc %t2.bc -f -o %t3.bc
+
+@b = alias void ()* @a
+
+define void @a() nounwind {
+entry:
+ br label %return
+
+return:
+ ret void
+}
diff --git a/test/Linker/2008-07-06-AliasFnDecl2.ll b/test/Linker/2008-07-06-AliasFnDecl2.ll
new file mode 100644
index 000000000000..2380dffff613
--- /dev/null
+++ b/test/Linker/2008-07-06-AliasFnDecl2.ll
@@ -0,0 +1,13 @@
+; This file is used by 2008-07-06-AliasFnDecl2.ll
+; RUN: true
+
+define void @c() nounwind {
+entry:
+ call void @b( ) nounwind
+ br label %return
+
+return:
+ ret void
+}
+
+declare void @b()
diff --git a/test/Linker/2008-07-06-AliasWeakDest.ll b/test/Linker/2008-07-06-AliasWeakDest.ll
new file mode 100644
index 000000000000..af8964064c9a
--- /dev/null
+++ b/test/Linker/2008-07-06-AliasWeakDest.ll
@@ -0,0 +1,18 @@
+; PR2463
+; RUN: llvm-as %s -o %t1.bc -f
+; RUN: llvm-as %p/2008-07-06-AliasWeakDest2.ll -o %t2.bc -f
+; RUN: llvm-link %t1.bc %t2.bc -f -o %t3.bc
+; RUN: llvm-link %t2.bc %t1.bc -f -o %t4.bc
+
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
+target triple = "i386-pc-linux-gnu"
+
+@sched_clock = alias i64 ()* @native_sched_clock
+
+@foo = alias i32* @realfoo
+@realfoo = global i32 0
+
+define i64 @native_sched_clock() nounwind {
+entry:
+ ret i64 0
+}
diff --git a/test/Linker/2008-07-06-AliasWeakDest2.ll b/test/Linker/2008-07-06-AliasWeakDest2.ll
new file mode 100644
index 000000000000..e4e2bf395bbc
--- /dev/null
+++ b/test/Linker/2008-07-06-AliasWeakDest2.ll
@@ -0,0 +1,18 @@
+; This file is used by 2008-07-06-AliasWeakDest2.ll
+; RUN: true
+
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
+target triple = "i386-pc-linux-gnu"
+
+@foo = weak global i32 2
+
+define i64 @sched_clock_cpu(i32 inreg %cpu) nounwind {
+entry:
+ %tmp = call i64 @sched_clock( ) nounwind ; <i64>
+ ret i64 %tmp
+}
+
+define weak i64 @sched_clock() {
+entry:
+ ret i64 1
+}
diff --git a/test/Linker/AppendingLinkage.ll b/test/Linker/AppendingLinkage.ll
new file mode 100644
index 000000000000..da08ca098893
--- /dev/null
+++ b/test/Linker/AppendingLinkage.ll
@@ -0,0 +1,15 @@
+; Test that appending linkage works correctly.
+
+; RUN: echo {@X = appending global \[1 x i32\] \[i32 8\] } | \
+; RUN: llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep 7 | grep 4 | grep 8
+
+@X = appending global [2 x i32] [ i32 7, i32 4 ] ; <[2 x i32]*> [#uses=2]
+@Y = global i32* getelementptr ([2 x i32]* @X, i64 0, i64 0) ; <i32**> [#uses=0]
+
+define void @foo(i64 %V) {
+ %Y = getelementptr [2 x i32]* @X, i64 0, i64 %V ; <i32*> [#uses=0]
+ ret void
+}
+
diff --git a/test/Linker/AppendingLinkage2.ll b/test/Linker/AppendingLinkage2.ll
new file mode 100644
index 000000000000..fddc4941be97
--- /dev/null
+++ b/test/Linker/AppendingLinkage2.ll
@@ -0,0 +1,8 @@
+; Test that appending linkage works correctly when arrays are the same size.
+
+; RUN: echo {@X = appending global \[1 x i32\] \[i32 8\] } | \
+; RUN: llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep 7 | grep 8
+
+@X = appending global [1 x i32] [ i32 7 ] ; <[1 x i32]*> [#uses=0]
diff --git a/test/Linker/ConstantGlobals1.ll b/test/Linker/ConstantGlobals1.ll
new file mode 100644
index 000000000000..5d42f4bf5483
--- /dev/null
+++ b/test/Linker/ConstantGlobals1.ll
@@ -0,0 +1,9 @@
+; Test that appending linkage works correctly when arrays are the same size.
+
+; RUN: echo {@X = constant \[1 x i32\] \[i32 8\] } | \
+; RUN: llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep constant
+
+@X = external global [1 x i32] ; <[1 x i32]*> [#uses=0]
+
diff --git a/test/Linker/ConstantGlobals2.ll b/test/Linker/ConstantGlobals2.ll
new file mode 100644
index 000000000000..9cd6bdb8c49a
--- /dev/null
+++ b/test/Linker/ConstantGlobals2.ll
@@ -0,0 +1,9 @@
+; Test that appending linkage works correctly when arrays are the same size.
+
+; RUN: echo {@X = external global \[1 x i32\] } | \
+; RUN: llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep constant
+
+@X = constant [1 x i32] [ i32 12 ] ; <[1 x i32]*> [#uses=0]
+
diff --git a/test/Linker/ConstantGlobals3.ll b/test/Linker/ConstantGlobals3.ll
new file mode 100644
index 000000000000..f9aa07d1bc50
--- /dev/null
+++ b/test/Linker/ConstantGlobals3.ll
@@ -0,0 +1,8 @@
+; Test that appending linkage works correctly when arrays are the same size.
+
+; RUN: echo {@X = external constant \[1 x i32\] } | \
+; RUN: llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep constant
+
+@X = external global [1 x i32] ; <[1 x i32]*> [#uses=0]
diff --git a/test/Linker/LinkOnce.ll b/test/Linker/LinkOnce.ll
new file mode 100644
index 000000000000..5befd77a4aaa
--- /dev/null
+++ b/test/Linker/LinkOnce.ll
@@ -0,0 +1,8 @@
+; This fails because the linker renames the non-opaque type not the opaque
+; one...
+
+; RUN: echo "@X = linkonce global i32 8" | llvm-as > %t.2.bc
+; RUN: llvm-as < %s > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis
+
+@X = linkonce global i32 7 ; <i32*> [#uses=0]
diff --git a/test/Linker/basiclink.ll b/test/Linker/basiclink.ll
new file mode 100644
index 000000000000..711a0f4715ed
--- /dev/null
+++ b/test/Linker/basiclink.ll
@@ -0,0 +1,13 @@
+; Test linking two functions with different prototypes and two globals
+; in different modules. This is for PR411
+; RUN: llvm-as %s -o %t.bar.bc -f
+; RUN: echo {define i32* @foo(i32 %x) \{ ret i32* @baz \} \
+; RUN: @baz = external global i32 } | llvm-as -o %t.foo.bc -f
+; RUN: llvm-link %t.bar.bc %t.foo.bc -o %t.bc -f
+; RUN: llvm-link %t.foo.bc %t.bar.bc -o %t.bc -f
+declare i32* @foo(...)
+define i32* @bar() {
+ %ret = call i32* (...)* @foo( i32 123 )
+ ret i32* %ret
+}
+@baz = global i32 0
diff --git a/test/Linker/dg.exp b/test/Linker/dg.exp
new file mode 100644
index 000000000000..f2005891a59a
--- /dev/null
+++ b/test/Linker/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
diff --git a/test/Linker/link-archive.ll b/test/Linker/link-archive.ll
new file mode 100644
index 000000000000..33088c09c37b
--- /dev/null
+++ b/test/Linker/link-archive.ll
@@ -0,0 +1,15 @@
+; Test linking of a bc file to an archive via llvm-ld.
+; PR1434
+; RUN: llvm-as %s -o %t.bar.bc -f
+; RUN: echo {define i32* @foo(i32 %x) \{ ret i32* @baz \} \
+; RUN: @baz = external global i32 } | llvm-as -o %t.foo.bc -f
+; RUN: llvm-ar rcf %t.foo.a %t.foo.bc
+; RUN: llvm-ar rcf %t.bar.a %t.bar.bc
+; RUN: llvm-ld -disable-opt %t.bar.bc %t.foo.a -o %t.bc
+; RUN: llvm-ld -disable-opt %t.foo.bc %t.bar.a -o %t.bc
+declare i32* @foo(...)
+define i32* @bar() {
+ %ret = call i32* (...)* @foo( i32 123 )
+ ret i32* %ret
+}
+@baz = global i32 0
diff --git a/test/Linker/link-global-to-func.ll b/test/Linker/link-global-to-func.ll
new file mode 100644
index 000000000000..f9cbc46f7333
--- /dev/null
+++ b/test/Linker/link-global-to-func.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-as %s -o %t1.bc -f
+; RUN: echo {declare void @__eprintf(i8*, i8*, i32, i8*) noreturn define void @foo() { tail call void @__eprintf( i8* undef, i8* undef, i32 4, i8* null ) noreturn nounwind unreachable }} | llvm-as -o %t2.bc -f
+; RUN: llvm-link %t2.bc %t1.bc -o - | llvm-dis | grep __eprintf
+; RUN: llvm-link %t1.bc %t2.bc -o - | llvm-dis | grep __eprintf
+
+; rdar://6072702
+
+@__eprintf = external global i8* ; <i8**> [#uses=1]
+
+define i8* @test() {
+ %A = load i8** @__eprintf ; <i8*> [#uses=1]
+ ret i8* %A
+}
diff --git a/test/Linker/link-messages.ll b/test/Linker/link-messages.ll
new file mode 100644
index 000000000000..f0f10aa83267
--- /dev/null
+++ b/test/Linker/link-messages.ll
@@ -0,0 +1,11 @@
+; Test that linking two files with the same definition causes an error and
+; that error is printed out.
+; RUN: llvm-as %s -o %t.one.bc -f
+; RUN: llvm-as %s -o %t.two.bc -f
+; RUN: not llvm-ld -disable-opt -link-as-library %t.one.bc %t.two.bc \
+; RUN: -o %t.bc 2>%t.err
+; RUN: grep "symbol multiply defined" %t.err
+
+define i32 @bar() {
+ ret i32 0
+}
diff --git a/test/Linker/redefinition.ll b/test/Linker/redefinition.ll
new file mode 100644
index 000000000000..15d03bce29a0
--- /dev/null
+++ b/test/Linker/redefinition.ll
@@ -0,0 +1,10 @@
+; Test linking two functions with different prototypes and two globals
+; in different modules.
+; RUN: llvm-as %s -o %t.foo1.bc -f
+; RUN: llvm-as %s -o %t.foo2.bc -f
+; RUN: echo {define void @foo(i32 %x) { ret void }} | llvm-as -o %t.foo3.bc -f
+; RUN: not llvm-link %t.foo1.bc %t.foo2.bc -o %t.bc |& \
+; RUN: grep {symbol multiply defined}
+; RUN: not llvm-link %t.foo1.bc %t.foo3.bc -o %t.bc |& \
+; RUN: grep {symbol multiply defined}
+define void @foo() { ret void }
diff --git a/test/Linker/testlink1.ll b/test/Linker/testlink1.ll
new file mode 100644
index 000000000000..4a9402576ef2
--- /dev/null
+++ b/test/Linker/testlink1.ll
@@ -0,0 +1,42 @@
+; RUN: llvm-as < %s > %t.bc
+; RUN: llvm-as < %p/testlink2.ll > %t2.bc
+; RUN: llvm-link %t.bc %t2.bc
+
+@MyVar = external global i32 ; <i32*> [#uses=3]
+@MyIntList = global { \2*, i32 } { { \2*, i32 }* null, i32 17 } ; <{ \2*, i32 }*> [#uses=1]
+external global i32 ; <i32*>:0 [#uses=0]
+@Inte = global i32 1 ; <i32*> [#uses=0]
+@AConst = linkonce constant i32 123 ; <i32*> [#uses=0]
+@Intern1 = internal constant i32 42 ; <i32*> [#uses=0]
+@Intern2 = internal constant i32 792 ; <i32*> [#uses=0]
+@MyVarPtr = linkonce global { i32* } { i32* @MyVar } ; <{ i32* }*> [#uses=0]
+
+declare i32 @foo(i32)
+
+declare void @print(i32)
+
+define void @main() {
+ %v1 = load i32* @MyVar ; <i32> [#uses=1]
+ call void @print( i32 %v1 )
+ %idx = getelementptr { \2*, i32 }* @MyIntList, i64 0, i32 1 ; <i32*> [#uses=2]
+ %v2 = load i32* %idx ; <i32> [#uses=1]
+ call void @print( i32 %v2 )
+ call i32 @foo( i32 5 ) ; <i32>:1 [#uses=0]
+ %v3 = load i32* @MyVar ; <i32> [#uses=1]
+ call void @print( i32 %v3 )
+ %v4 = load i32* %idx ; <i32> [#uses=1]
+ call void @print( i32 %v4 )
+ ret void
+}
+
+define internal void @testintern() {
+ ret void
+}
+
+define internal void @Testintern() {
+ ret void
+}
+
+define void @testIntern() {
+ ret void
+}
diff --git a/test/Linker/testlink2.ll b/test/Linker/testlink2.ll
new file mode 100644
index 000000000000..d243e3c7d1a3
--- /dev/null
+++ b/test/Linker/testlink2.ll
@@ -0,0 +1,41 @@
+; This file is used by testlink1.ll, so it doesn't actually do anything itself
+;
+; RUN: true
+
+@MyVar = global i32 4 ; <i32*> [#uses=2]
+@MyIntList = external global { \2*, i32 } ; <{ \2*, i32 }*> [#uses=2]
+@AConst = constant i32 123 ; <i32*> [#uses=0]
+
+;; Intern in both testlink[12].ll
+@Intern1 = internal constant i32 52 ; <i32*> [#uses=0]
+
+;; Intern in one but not in other
+@Intern2 = constant i32 12345 ; <i32*> [#uses=0]
+
+@MyIntListPtr = constant { { \2*, i32 }* } { { \2*, i32 }* @MyIntList } ; <{ { \2*, i32 }* }*> [#uses=0]
+@MyVarPtr = linkonce global { i32* } { i32* @MyVar } ; <{ i32* }*> [#uses=0]
+constant i32 412 ; <i32*>:0 [#uses=1]
+
+define i32 @foo(i32 %blah) {
+ store i32 %blah, i32* @MyVar
+ %idx = getelementptr { \2*, i32 }* @MyIntList, i64 0, i32 1 ; <i32*> [#uses=1]
+ store i32 12, i32* %idx
+ %ack = load i32* @0 ; <i32> [#uses=1]
+ %fzo = add i32 %ack, %blah ; <i32> [#uses=1]
+ ret i32 %fzo
+}
+
+declare void @unimp(float, double)
+
+define internal void @testintern() {
+ ret void
+}
+
+define void @Testintern() {
+ ret void
+}
+
+define internal void @testIntern() {
+ ret void
+}
+
diff --git a/test/Linker/weakextern.ll b/test/Linker/weakextern.ll
new file mode 100644
index 000000000000..edb23bc4b707
--- /dev/null
+++ b/test/Linker/weakextern.ll
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s > %t.bc
+; RUN: llvm-as < %p/testlink1.ll > %t2.bc
+; RUN: llvm-link %t.bc %t.bc %t2.bc -o %t1.bc -f
+; RUN: llvm-dis < %t1.bc | grep {kallsyms_names = extern_weak}
+; RUN: llvm-dis < %t1.bc | grep {MyVar = external global i32}
+; RUN: llvm-dis < %t1.bc | grep {Inte = global i32}
+
+@kallsyms_names = extern_weak global [0 x i8] ; <[0 x i8]*> [#uses=0]
+@MyVar = extern_weak global i32 ; <i32*> [#uses=0]
+@Inte = extern_weak global i32 ; <i32*> [#uses=0]
+