Add a few passing lto tests.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 26 Nov 2015 19:53:12 +0000 (19:53 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 26 Nov 2015 19:53:12 +0000 (19:53 +0000)
I found these while trying to get a prototype to bootstrap.

They cover things like
* Handling of non linker visible stuff (append, available_externally)
* Type merging
* Alias to dropped globals
* Dropping linkage when converting to a declaration.

These should hopefully be generally useful for anyone refactoring the
plugin.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254174 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
test/tools/gold/X86/Inputs/ctors2.ll [new file with mode: 0644]
test/tools/gold/X86/Inputs/drop-linkage.ll [new file with mode: 0644]
test/tools/gold/X86/Inputs/type-merge.ll [new file with mode: 0644]
test/tools/gold/X86/Inputs/type-merge2.ll [new file with mode: 0644]
test/tools/gold/X86/alias2.ll [new file with mode: 0644]
test/tools/gold/X86/available-externally.ll [new file with mode: 0644]
test/tools/gold/X86/ctors.ll [new file with mode: 0644]
test/tools/gold/X86/ctors2.ll [new file with mode: 0644]
test/tools/gold/X86/drop-linkage.ll [new file with mode: 0644]
test/tools/gold/X86/type-merge.ll [new file with mode: 0644]
test/tools/gold/X86/type-merge2.ll [new file with mode: 0644]
test/tools/gold/X86/unnamed-addr.ll [new file with mode: 0644]

diff --git a/test/tools/gold/X86/Inputs/ctors2.ll b/test/tools/gold/X86/Inputs/ctors2.ll
new file mode 100644 (file)
index 0000000..af1590e
--- /dev/null
@@ -0,0 +1,5 @@
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @bar, i8* null }]
+
+define void @bar() {
+  ret void
+}
diff --git a/test/tools/gold/X86/Inputs/drop-linkage.ll b/test/tools/gold/X86/Inputs/drop-linkage.ll
new file mode 100644 (file)
index 0000000..0753061
--- /dev/null
@@ -0,0 +1,9 @@
+$foo = comdat any
+define linkonce void @foo() comdat {
+  ret void
+}
+
+define void @bar() {
+  call void @foo()
+  ret void
+}
diff --git a/test/tools/gold/X86/Inputs/type-merge.ll b/test/tools/gold/X86/Inputs/type-merge.ll
new file mode 100644 (file)
index 0000000..4dc2149
--- /dev/null
@@ -0,0 +1,5 @@
+define void @zed() {
+  call void @bar()
+  ret void
+}
+declare void @bar()
diff --git a/test/tools/gold/X86/Inputs/type-merge2.ll b/test/tools/gold/X86/Inputs/type-merge2.ll
new file mode 100644 (file)
index 0000000..a354757
--- /dev/null
@@ -0,0 +1,5 @@
+%zed = type { i16 }
+define void @bar(%zed* %this)  {
+  store %zed* %this, %zed** null
+  ret void
+}
diff --git a/test/tools/gold/X86/alias2.ll b/test/tools/gold/X86/alias2.ll
new file mode 100644 (file)
index 0000000..4727e05
--- /dev/null
@@ -0,0 +1,23 @@
+; RUN: llvm-as %s -o %t.o
+; RUN: %gold -shared -o %t2.bc -plugin %llvmshlibdir/LLVMgold.so %t.o -plugin-opt=emit-llvm
+; RUN: llvm-dis %t2.bc -o - | FileCheck %s
+
+@bar = alias void (), void ()* @zed
+define void @foo() {
+  call void @bar()
+  ret void
+}
+define void @zed() {
+  ret void
+}
+
+; CHECK: @bar = alias void (), void ()* @zed
+
+; CHECK:      define void @foo() {
+; CHECK-NEXT:   call void @bar()
+; CHECK-NEXT:   ret void
+; CHECK-NEXT: }
+
+; CHECK:      define void @zed() {
+; CHECK-NEXT:   ret void
+; CHECK-NEXT: }
diff --git a/test/tools/gold/X86/available-externally.ll b/test/tools/gold/X86/available-externally.ll
new file mode 100644 (file)
index 0000000..1adda35
--- /dev/null
@@ -0,0 +1,16 @@
+; RUN: llvm-as %s -o %t.o
+
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
+; RUN:    --plugin-opt=emit-llvm \
+; RUN:    -shared %t.o -o %t2.o
+; RUN: llvm-dis %t2.o -o - | FileCheck %s
+
+define void @foo() {
+  call void @bar()
+  ret void
+}
+define available_externally void @bar() {
+  ret void
+}
+
+; CHECK: define available_externally void @bar() {
diff --git a/test/tools/gold/X86/ctors.ll b/test/tools/gold/X86/ctors.ll
new file mode 100644 (file)
index 0000000..24c8e34
--- /dev/null
@@ -0,0 +1,13 @@
+; RUN: llvm-as %s -o %t.o
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
+; RUN:    --plugin-opt=emit-llvm \
+; RUN:    -shared %t.o -o %t2.o
+; RUN: llvm-dis %t2.o -o - | FileCheck %s
+
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }]
+
+define internal void @foo() {
+  ret void
+}
+
+; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }]
diff --git a/test/tools/gold/X86/ctors2.ll b/test/tools/gold/X86/ctors2.ll
new file mode 100644 (file)
index 0000000..c39cb71
--- /dev/null
@@ -0,0 +1,14 @@
+; RUN: llvm-as %s -o %t.o
+; RUN: llvm-as %p/Inputs/ctors2.ll -o %t2.o
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
+; RUN:    --plugin-opt=emit-llvm \
+; RUN:    -shared %t.o %t2.o -o %t3.o
+; RUN: llvm-dis %t3.o -o - | FileCheck %s
+
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }]
+
+define void @foo() {
+  ret void
+}
+
+; CHECK: @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @bar, i8* null }]
diff --git a/test/tools/gold/X86/drop-linkage.ll b/test/tools/gold/X86/drop-linkage.ll
new file mode 100644 (file)
index 0000000..14d3a96
--- /dev/null
@@ -0,0 +1,14 @@
+; RUN: llc %s -o %t.s
+; RUN: llvm-mc %t.s -o %t.o -filetype=obj
+; RUN: llvm-as %p/Inputs/drop-linkage.ll -o %t2.o
+
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
+; RUN:    --plugin-opt=emit-llvm \
+; RUN:    -shared %t.o %t2.o -o %t3.o
+; RUN: llvm-dis %t3.o -o - | FileCheck %s
+
+define void @foo() {
+  ret void
+}
+
+; CHECK: declare void @foo(){{$}}
diff --git a/test/tools/gold/X86/type-merge.ll b/test/tools/gold/X86/type-merge.ll
new file mode 100644 (file)
index 0000000..d903894
--- /dev/null
@@ -0,0 +1,24 @@
+; RUN: llvm-as %s -o %t.o
+; RUN: llvm-as %p/Inputs/type-merge.ll -o %t2.o
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
+; RUN:    --plugin-opt=emit-llvm \
+; RUN:    -shared %t.o %t2.o -o %t3.o
+; RUN: llvm-dis %t3.o -o - | FileCheck %s
+
+define void @foo()  {
+  call void @bar(i8* null)
+  ret void
+}
+declare void @bar(i8*)
+
+; CHECK:      define void @foo() {
+; CHECK-NEXT:   call void @bar(i8* null)
+; CHECK-NEXT:   ret void
+; CHECK-NEXT: }
+
+; CHECK: declare void @bar(i8*)
+
+; CHECK:      define void @zed() {
+; CHECK-NEXT:   call void bitcast (void (i8*)* @bar to void ()*)()
+; CHECK-NEXT:   ret void
+; CHECK-NEXT: }
diff --git a/test/tools/gold/X86/type-merge2.ll b/test/tools/gold/X86/type-merge2.ll
new file mode 100644 (file)
index 0000000..42ad0da
--- /dev/null
@@ -0,0 +1,26 @@
+; RUN: llvm-as %s -o %t.o
+; RUN: llvm-as %p/Inputs/type-merge2.ll -o %t2.o
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
+; RUN:    --plugin-opt=emit-llvm \
+; RUN:    -shared %t.o %t2.o -o %t3.o
+; RUN: llvm-dis %t3.o -o - | FileCheck %s
+
+%zed = type { i8 }
+define void @foo()  {
+  call void @bar(%zed* null)
+  ret void
+}
+declare void @bar(%zed*)
+
+; CHECK:      %zed = type { i8 }
+; CHECK-NEXT: %zed.0 = type { i16 }
+
+; CHECK:      define void @foo() {
+; CHECK-NEXT:   call void bitcast (void (%zed.0*)* @bar to void (%zed*)*)(%zed* null)
+; CHECK-NEXT:   ret void
+; CHECK-NEXT: }
+
+; CHECK:      define void @bar(%zed.0* %this) {
+; CHECK-NEXT:   store %zed.0* %this, %zed.0** null
+; CHECK-NEXT:   ret void
+; CHECK-NEXT: }
diff --git a/test/tools/gold/X86/unnamed-addr.ll b/test/tools/gold/X86/unnamed-addr.ll
new file mode 100644 (file)
index 0000000..290f73d
--- /dev/null
@@ -0,0 +1,14 @@
+; RUN: llvm-as %s -o %t.o
+
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
+; RUN:    --plugin-opt=emit-llvm \
+; RUN:    -shared %t.o -o %t2.o
+; RUN: llvm-dis %t2.o -o - | FileCheck %s
+
+@a = internal unnamed_addr constant i8 42
+
+define i8* @f() {
+  ret i8* @a
+}
+
+; CHECK: @a = internal unnamed_addr constant i8 42