Add a few passing lto tests.

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.

llvm-svn: 254174
This commit is contained in:
Rafael Espindola 2015-11-26 19:53:12 +00:00
parent 98712bd771
commit b38f7b5adc
12 changed files with 168 additions and 0 deletions

View File

@ -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
}

View File

@ -0,0 +1,9 @@
$foo = comdat any
define linkonce void @foo() comdat {
ret void
}
define void @bar() {
call void @foo()
ret void
}

View File

@ -0,0 +1,5 @@
define void @zed() {
call void @bar()
ret void
}
declare void @bar()

View File

@ -0,0 +1,5 @@
%zed = type { i16 }
define void @bar(%zed* %this) {
store %zed* %this, %zed** null
ret void
}

View File

@ -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: }

View File

@ -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() {

View File

@ -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 }]

View File

@ -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 }]

View File

@ -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(){{$}}

View File

@ -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: }

View File

@ -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: }

View File

@ -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