aboutsummaryrefslogtreecommitdiffstats
path: root/test/Linker
diff options
context:
space:
mode:
authorDan Gohman <djg@cray.com>2007-07-18 16:29:46 +0000
committerDan Gohman <djg@cray.com>2007-07-18 16:29:46 +0000
commitf17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc (patch)
treeebb79ea1ee5e3bc1fdf38541a811a8b804f0679a /test/Linker
downloadexternal_llvm-f17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc.zip
external_llvm-f17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc.tar.gz
external_llvm-f17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc.tar.bz2
It's not necessary to do rounding for alloca operations when the requested
alignment is equal to the stack alignment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Linker')
-rw-r--r--test/Linker/2002-07-17-GlobalFail.ll8
-rw-r--r--test/Linker/2002-07-17-LinkTest2.ll9
-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.ll19
-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.ll8
-rw-r--r--test/Linker/2003-08-20-OpaqueTypeResolve.ll7
-rw-r--r--test/Linker/2003-08-23-GlobalVarLinking.ll10
-rw-r--r--test/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll8
-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.ll17
-rw-r--r--test/Linker/2003-08-28-TypeResolvesGlobal3.ll15
-rw-r--r--test/Linker/2003-10-21-ConflictingTypesTolerance.ll7
-rw-r--r--test/Linker/2003-10-27-LinkOncePromote.ll8
-rw-r--r--test/Linker/2003-11-18-TypeResolution.ll23
-rw-r--r--test/Linker/2004-02-17-WeakStrongLinkage.ll7
-rw-r--r--test/Linker/2004-05-07-TypeResolution1.ll45
-rw-r--r--test/Linker/2004-05-07-TypeResolution2.ll25
-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.ll9
-rw-r--r--test/Linker/2006-01-19-ConstantPacked.ll15
-rw-r--r--test/Linker/2006-06-15-GlobalVarAlignment.ll7
-rw-r--r--test/Linker/AppendingLinkage.ll15
-rw-r--r--test/Linker/AppendingLinkage2.ll8
-rw-r--r--test/Linker/ConstantGlobals1.ll8
-rw-r--r--test/Linker/ConstantGlobals2.ll8
-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/redefinition.ll10
-rw-r--r--test/Linker/testlink1.ll48
-rw-r--r--test/Linker/testlink2.ll36
-rw-r--r--test/Linker/weakextern.ll12
44 files changed, 570 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 0000000..d950e40
--- /dev/null
+++ b/test/Linker/2002-07-17-GlobalFail.ll
@@ -0,0 +1,8 @@
+; RUN: llvm-upgrade < %s | llvm-as > %t.bc
+; RUN: echo | llvm-as > %t.tmp.bc
+; RUN: llvm-link %t.tmp.bc %t.bc
+
+%X = constant int 5
+%Y = internal global [2 x int*] [ int* %X, int * %X]
+
+
diff --git a/test/Linker/2002-07-17-LinkTest2.ll b/test/Linker/2002-07-17-LinkTest2.ll
new file mode 100644
index 0000000..312b9b9
--- /dev/null
+++ b/test/Linker/2002-07-17-LinkTest2.ll
@@ -0,0 +1,9 @@
+; 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-upgrade < %s | llvm-as > %t2.bc
+; RUN: llvm-link %t1.bc %t2.bc
+
+%work = global int (int, int)* %zip
+
+declare int %zip(int, int)
diff --git a/test/Linker/2002-08-20-ConstantExpr.ll b/test/Linker/2002-08-20-ConstantExpr.ll
new file mode 100644
index 0000000..03b178e
--- /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-upgrade < %s | llvm-as > %t.bc
+; RUN: llvm-link %t.LinkTest.bc %t.bc
+
+%work = global int 4
+%test = global int* getelementptr( int* %work, long 1)
+
diff --git a/test/Linker/2003-01-30-LinkerRename.ll b/test/Linker/2003-01-30-LinkerRename.ll
new file mode 100644
index 0000000..c5f3bde
--- /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 0000000..288daf1
--- /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 0000000..7e00943
--- /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 0000000..cf63fb3
--- /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 0000000..029bce2
--- /dev/null
+++ b/test/Linker/2003-04-26-NullPtrLinkProblem.ll
@@ -0,0 +1,19 @@
+; This one fails because the LLVM runtime is allowing two null pointers of
+; the same type to be created!
+
+; RUN: echo {%T = type int} | llvm-upgrade | llvm-as > %t.2.bc
+; RUN: llvm-upgrade < %s | llvm-as -f > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc
+
+%T = type opaque
+
+declare %T* %create()
+
+implementation
+
+void %test() {
+ %X = call %T* %create()
+ %v = seteq %T* %X, null
+ 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 0000000..2c7576f
--- /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-upgrade < %s | llvm-as > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc
+
+%S = type { %T* }
+%T = type int
+
diff --git a/test/Linker/2003-05-31-LinkerRename.ll b/test/Linker/2003-05-31-LinkerRename.ll
new file mode 100644
index 0000000..3e8b2c8
--- /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 0000000..9b1c6f4
--- /dev/null
+++ b/test/Linker/2003-06-02-TypeResolveProblem.ll
@@ -0,0 +1,7 @@
+; RUN: echo {%T = type opaque} | llvm-upgrade | llvm-as > %t.2.bc
+; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc
+
+%T = type opaque
+%a = constant { %T* } { %T* null }
+
diff --git a/test/Linker/2003-06-02-TypeResolveProblem2.ll b/test/Linker/2003-06-02-TypeResolveProblem2.ll
new file mode 100644
index 0000000..0dcca98
--- /dev/null
+++ b/test/Linker/2003-06-02-TypeResolveProblem2.ll
@@ -0,0 +1,8 @@
+; RUN: echo {%T = type int} | llvm-upgrade | llvm-as > %t.1.bc
+; RUN: llvm-upgrade < %s | llvm-as > %t.2.bc
+; RUN: llvm-link %t.1.bc %t.2.bc
+
+%T = type opaque
+
+%X = constant {%T*} {%T* null }
+
diff --git a/test/Linker/2003-08-20-OpaqueTypeResolve.ll b/test/Linker/2003-08-20-OpaqueTypeResolve.ll
new file mode 100644
index 0000000..b659b1a
--- /dev/null
+++ b/test/Linker/2003-08-20-OpaqueTypeResolve.ll
@@ -0,0 +1,7 @@
+; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc
+; RUN: echo {%S = type \{ int, int* \} } | llvm-upgrade | llvm-as > %t.out2.bc
+; RUN: llvm-link %t.out1.bc %t.out2.bc
+
+%T = type opaque
+%S = type { int, %T* }
+;%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 0000000..45d7774
--- /dev/null
+++ b/test/Linker/2003-08-23-GlobalVarLinking.ll
@@ -0,0 +1,10 @@
+; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc
+; RUN: echo {%S = external global \{ int, opaque* \} declare void %F(opaque*)}\
+; RUN: | llvm-upgrade | 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 { int, int* } { int 5, int* null }
+
+declare void %F(int*)
diff --git a/test/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll b/test/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll
new file mode 100644
index 0000000..50aae13
--- /dev/null
+++ b/test/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll
@@ -0,0 +1,8 @@
+; It's a bad idea to go recursively traipsing through types without a safety
+; net.
+
+; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc
+; RUN: echo "%S = type { %S*, int* }" | llvm-upgrade | 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 0000000..f93c054
--- /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 0000000..41aef32
--- /dev/null
+++ b/test/Linker/2003-08-28-TypeResolvesGlobal.ll
@@ -0,0 +1,12 @@
+; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc
+; RUN: echo "%S = type int" | llvm-upgrade | llvm-as > %t.out2.bc
+; RUN: llvm-link %t.out2.bc %t.out1.bc
+
+%S = type opaque
+
+void %foo(int* %V) {
+ ret void
+}
+
+declare void %foo(%S*)
+
diff --git a/test/Linker/2003-08-28-TypeResolvesGlobal2.ll b/test/Linker/2003-08-28-TypeResolvesGlobal2.ll
new file mode 100644
index 0000000..212ef2b
--- /dev/null
+++ b/test/Linker/2003-08-28-TypeResolvesGlobal2.ll
@@ -0,0 +1,17 @@
+; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc
+; RUN: echo "%S = type int" | llvm-upgrade | llvm-as > %t.out2.bc
+; RUN: llvm-link %t.out2.bc %t.out1.bc
+
+%S = type opaque
+
+void %foo(int* %V) {
+ ret void
+}
+
+declare void %foo(%S*)
+
+void %other() {
+ call void %foo(%S* null) ; Add a use of the unresolved proto
+ call void %foo(int* null) ; Add a use of the resolved function
+ 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 0000000..5a52f9c
--- /dev/null
+++ b/test/Linker/2003-08-28-TypeResolvesGlobal3.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc
+; RUN: echo "%S = type int" | llvm-upgrade | 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 %foo(int* %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 0000000..07d4b2d
--- /dev/null
+++ b/test/Linker/2003-10-21-ConflictingTypesTolerance.ll
@@ -0,0 +1,7 @@
+; RUN: llvm-upgrade < %s | llvm-as > %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 { int }
+
+
diff --git a/test/Linker/2003-10-27-LinkOncePromote.ll b/test/Linker/2003-10-27-LinkOncePromote.ll
new file mode 100644
index 0000000..a4e5aa6
--- /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 int 7" | llvm-upgrade | llvm-as > %t.2.bc
+; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc
+
+%X = linkonce global int 7
diff --git a/test/Linker/2003-11-18-TypeResolution.ll b/test/Linker/2003-11-18-TypeResolution.ll
new file mode 100644
index 0000000..ff22e31
--- /dev/null
+++ b/test/Linker/2003-11-18-TypeResolution.ll
@@ -0,0 +1,23 @@
+; 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-upgrade %s | llvm-as > %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 int
+
+%GVar = global %T2 * null
+
+implementation
+
+void %foo(%T2 * %X) {
+ %X = cast %T2* %X to %T1 *
+ 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 0000000..4c6e8f8
--- /dev/null
+++ b/test/Linker/2004-02-17-WeakStrongLinkage.ll
@@ -0,0 +1,7 @@
+; RUN: llvm-upgrade < %s | llvm-as > %t.out2.bc
+; RUN: echo "%me = global int* null" | llvm-upgrade | llvm-as > %t.out1.bc
+; RUN: llvm-link %t.out1.bc %t.out2.bc -o /dev/null -f
+
+%me = weak global int * null
+
+
diff --git a/test/Linker/2004-05-07-TypeResolution1.ll b/test/Linker/2004-05-07-TypeResolution1.ll
new file mode 100644
index 0000000..1c90079
--- /dev/null
+++ b/test/Linker/2004-05-07-TypeResolution1.ll
@@ -0,0 +1,45 @@
+; RUN: llvm-upgrade < %s | llvm-as -f -o %t1.bc
+; RUN: llvm-upgrade < %p/2004-05-07-TypeResolution2.ll | \
+; RUN: llvm-as -o %t2.bc -f
+; RUN: llvm-link -f -o %t3.bc %t1.bc %t2.bc
+
+target endian = little
+target pointersize = 32
+
+ %myint = type opaque
+ %struct2 = type { %struct1 }
+
+ %struct1 = type { int, void (%struct2*)*, %myint *, int (uint *)* }
+
+
+%driver1 = global %struct1 zeroinitializer ; <%struct1*> [#uses=1]
+
+%m1 = external global [1 x sbyte] * ; <%struct.task_struct**> [#uses=0]
+;%m1 = external global uint ; <%struct.task_struct**> [#uses=0]
+%str1 = constant [1 x ubyte] zeroinitializer
+%str2 = constant [2 x ubyte] zeroinitializer
+%str3 = constant [3 x ubyte] zeroinitializer
+%str4 = constant [4 x ubyte] zeroinitializer
+%str5 = constant [5 x ubyte] zeroinitializer
+%str6 = constant [6 x ubyte] zeroinitializer
+%str7 = constant [7 x ubyte] zeroinitializer
+%str8 = constant [8 x ubyte] zeroinitializer
+%str9 = constant [9 x ubyte] zeroinitializer
+%stra = constant [10 x ubyte] zeroinitializer
+%strb = constant [11 x ubyte] zeroinitializer
+%strc = constant [12 x ubyte] zeroinitializer
+%strd = constant [13 x ubyte] zeroinitializer
+%stre = constant [14 x ubyte] zeroinitializer
+%strf = constant [15 x ubyte] zeroinitializer
+%strg = constant [16 x ubyte] zeroinitializer
+%strh = constant [17 x ubyte] zeroinitializer
+
+implementation ; Functions:
+
+declare void %func(%struct2*)
+
+void %tty_init() {
+entry:
+ volatile store void (%struct2*)* %func, void (%struct2 *)** getelementptr (%struct1* %driver1, uint 0, uint 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 0000000..05be611
--- /dev/null
+++ b/test/Linker/2004-05-07-TypeResolution2.ll
@@ -0,0 +1,25 @@
+; This file is used by testlink1.ll, so it doesn't actually do anything itself
+;
+; RUN: echo
+
+target endian = little
+target pointersize = 32
+
+ %myint = type ushort
+ %struct2 = type { %struct1 }
+ %struct1 = type { int, void (%struct2*)*, %myint *, int (uint *)* }
+
+implementation ; Functions:
+
+internal void %f1 (%struct1* %tty) {
+loopentry.preheader:
+
+ ; <void (%struct2*, ubyte)**> [#uses=1]
+ ; <void (%struct2*, ubyte)*> [#uses=0]
+
+ %tmp.2.i.i = getelementptr %struct1* %tty, uint 0, uint 1
+ %tmp.3.i.i = volatile load void (%struct2*)** %tmp.2.i.i
+
+ 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 0000000..63d851b1
--- /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 0000000..bedeb51
--- /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 0000000..fbc0bc1
--- /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-upgrade < %s | llvm-as > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep {global i32 7}
+
+@X = external constant i32
diff --git a/test/Linker/2005-12-06-AppendingZeroLengthArrays.ll b/test/Linker/2005-12-06-AppendingZeroLengthArrays.ll
new file mode 100644
index 0000000..3e57bec
--- /dev/null
+++ b/test/Linker/2005-12-06-AppendingZeroLengthArrays.ll
@@ -0,0 +1,9 @@
+; RUN: echo { @G = appending global \[0 x i32\] zeroinitializer } | \
+; RUN: llvm-as > %t.out2.bc
+; RUN: llvm-upgrade < %s | llvm-as > %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 int] zeroinitializer
diff --git a/test/Linker/2006-01-19-ConstantPacked.ll b/test/Linker/2006-01-19-ConstantPacked.ll
new file mode 100644
index 0000000..7aa0bc3
--- /dev/null
+++ b/test/Linker/2006-01-19-ConstantPacked.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-upgrade < %s | llvm-as -f -o %s.bc
+; RUN: llvm-link -f -o %s.linked %s.bc
+
+target endian = big
+target pointersize = 32
+target triple = "powerpc-apple-darwin7.7.0"
+deplibs = [ "c", "crtend" ]
+%source = global <4 x int> < int 0, int 1, int 2, int 3 >
+
+implementation ; Functions:
+
+int %main() {
+entry:
+ ret int 0
+}
diff --git a/test/Linker/2006-06-15-GlobalVarAlignment.ll b/test/Linker/2006-06-15-GlobalVarAlignment.ll
new file mode 100644
index 0000000..6e6d56a
--- /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/AppendingLinkage.ll b/test/Linker/AppendingLinkage.ll
new file mode 100644
index 0000000..d59a374
--- /dev/null
+++ b/test/Linker/AppendingLinkage.ll
@@ -0,0 +1,15 @@
+; Test that appending linkage works correctly.
+
+; RUN: echo {%X = appending global \[1 x int\] \[int 8\] } | \
+; RUN: llvm-upgrade | llvm-as > %t.2.bc
+; RUN: llvm-upgrade < %s | llvm-as > %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 int] [int 7, int 4]
+
+%Y = global int* getelementptr ([2 x int]* %X, long 0, long 0)
+
+void %foo(long %V) {
+ %Y = getelementptr [2 x int]* %X, long 0, long %V
+ ret void
+}
diff --git a/test/Linker/AppendingLinkage2.ll b/test/Linker/AppendingLinkage2.ll
new file mode 100644
index 0000000..fc992e0
--- /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 int\] \[int 8\] } | \
+; RUN: llvm-upgrade | llvm-as > %t.2.bc
+; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep 7 | grep 8
+
+%X = appending global [1 x int] [int 7]
diff --git a/test/Linker/ConstantGlobals1.ll b/test/Linker/ConstantGlobals1.ll
new file mode 100644
index 0000000..a5a9ce9
--- /dev/null
+++ b/test/Linker/ConstantGlobals1.ll
@@ -0,0 +1,8 @@
+; Test that appending linkage works correctly when arrays are the same size.
+
+; RUN: echo {%X = constant \[1 x int\] \[int 8\] } | \
+; RUN: llvm-upgrade | llvm-as > %t.2.bc
+; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep constant
+
+%X = uninitialized global [1 x int]
diff --git a/test/Linker/ConstantGlobals2.ll b/test/Linker/ConstantGlobals2.ll
new file mode 100644
index 0000000..612603d
--- /dev/null
+++ b/test/Linker/ConstantGlobals2.ll
@@ -0,0 +1,8 @@
+; Test that appending linkage works correctly when arrays are the same size.
+
+; RUN: echo {%X = external global \[1 x int\] } | \
+; RUN: llvm-upgrade | llvm-as > %t.2.bc
+; RUN: llvm-upgrade %s -o - | llvm-as > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep constant
+
+%X = constant [1 x int] [ int 12 ]
diff --git a/test/Linker/ConstantGlobals3.ll b/test/Linker/ConstantGlobals3.ll
new file mode 100644
index 0000000..4435f2d
--- /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 int\] } | \
+; RUN: llvm-upgrade | llvm-as > %t.2.bc
+; RUN: llvm-upgrade %s | llvm-as > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep constant
+
+%X = uninitialized global [1 x int]
diff --git a/test/Linker/LinkOnce.ll b/test/Linker/LinkOnce.ll
new file mode 100644
index 0000000..b1a0216
--- /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 int 8" | llvm-upgrade | llvm-as > %t.2.bc
+; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
+; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis
+
+%X = linkonce global int 7
diff --git a/test/Linker/basiclink.ll b/test/Linker/basiclink.ll
new file mode 100644
index 0000000..711a0f4
--- /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 0000000..879685c
--- /dev/null
+++ b/test/Linker/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]]
diff --git a/test/Linker/link-archive.ll b/test/Linker/link-archive.ll
new file mode 100644
index 0000000..43cf3f3
--- /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 rf %t.foo.a %t.foo.bc
+; RUN: llvm-ar rf %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/redefinition.ll b/test/Linker/redefinition.ll
new file mode 100644
index 0000000..bba60c5
--- /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: ignore llvm-link %t.foo1.bc %t.foo2.bc -o %t.bc |& \
+; RUN: grep {Function is already defined}
+; RUN: ignore llvm-link %t.foo1.bc %t.foo3.bc -o %t.bc |& \
+; RUN: grep {Function 'foo' defined as both}
+define void @foo() { ret void }
diff --git a/test/Linker/testlink1.ll b/test/Linker/testlink1.ll
new file mode 100644
index 0000000..df89d84
--- /dev/null
+++ b/test/Linker/testlink1.ll
@@ -0,0 +1,48 @@
+; RUN: llvm-upgrade < %s | llvm-as > %t.bc
+; RUN: llvm-upgrade < %p/testlink2.ll | llvm-as > %t2.bc
+; RUN: llvm-link %t.bc %t2.bc
+
+%MyVar = external global int
+%MyIntList = global { \2 *, int } { { \2, int }* null, int 17 }
+ external global int ; int*:0
+
+%Inte = global int 1
+
+%AConst = linkonce constant int 123
+
+%Intern1 = internal constant int 42
+%Intern2 = internal constant int 792
+
+; Initialized to point to external %MyVar
+%MyVarPtr = linkonce global { int * } { int * %MyVar }
+
+declare int "foo"(int %blah) ;; Declared in testlink2.ll
+
+declare void "print"(int %Value)
+
+implementation
+
+void "main"()
+begin
+ %v1 = load int* %MyVar
+ call void %print(int %v1) ;; Should start out 4
+
+ %idx = getelementptr { \2 *, int }* %MyIntList, long 0, uint 1
+ %v2 = load int* %idx
+ call void %print(int %v2) ;; Should start out 17
+
+ call int %foo(int 5) ;; Modify global variablesx
+
+ %v3 = load int* %MyVar
+ call void %print(int %v3) ;; Should now be 5
+
+ %v4 = load int* %idx
+ call void %print(int %v4) ;; Should start out 12
+
+ ret void
+end
+
+internal void "testintern"() begin ret void end
+internal void "Testintern"() begin ret void end
+ void "testIntern"() begin ret void end
+
diff --git a/test/Linker/testlink2.ll b/test/Linker/testlink2.ll
new file mode 100644
index 0000000..0f4468d
--- /dev/null
+++ b/test/Linker/testlink2.ll
@@ -0,0 +1,36 @@
+; This file is used by testlink1.ll, so it doesn't actually do anything itself
+;
+; RUN: true
+
+%MyVar = global int 4
+%MyIntList = external global { \2 *, int }
+
+%AConst = constant int 123
+
+%Intern1 = internal constant int 52 ;; Intern in both testlink[12].ll
+%Intern2 = constant int 12345 ;; Intern in one but not in other
+
+%MyIntListPtr = constant { {\2,int}* } { {\2,int}* %MyIntList }
+%MyVarPtr = linkonce global { int * } { int * %MyVar }
+
+constant int 412
+
+implementation
+
+int "foo"(int %blah)
+begin
+ store int %blah, int *%MyVar
+ %idx = getelementptr { \2 *, int } * %MyIntList, long 0, uint 1
+ store int 12, int* %idx
+
+ %ack = load int * %0 ;; Load from the unnamed constant
+ %fzo = add int %ack, %blah
+ ret int %fzo
+end
+
+declare void "unimp"(float, double)
+
+internal void "testintern"() begin ret void end
+ void "Testintern"() begin ret void end
+internal void "testIntern"() begin ret void end
+
diff --git a/test/Linker/weakextern.ll b/test/Linker/weakextern.ll
new file mode 100644
index 0000000..60ca596
--- /dev/null
+++ b/test/Linker/weakextern.ll
@@ -0,0 +1,12 @@
+; RUN: llvm-upgrade < %s | llvm-as > %t.bc
+; RUN: llvm-upgrade < %p/testlink1.ll | llvm-as > %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 ubyte]
+%MyVar = extern_weak global int
+%Inte = extern_weak global int
+
+implementation