diff options
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/tools/llvm-split/preserve-locals.ll | 65 | ||||
-rw-r--r-- | llvm/test/tools/llvm-split/scc-alias.ll | 48 | ||||
-rw-r--r-- | llvm/test/tools/llvm-split/scc-callchain.ll | 48 | ||||
-rw-r--r-- | llvm/test/tools/llvm-split/scc-comdat.ll | 32 | ||||
-rw-r--r-- | llvm/test/tools/llvm-split/scc-constants.ll | 48 | ||||
-rw-r--r-- | llvm/test/tools/llvm-split/scc-cycle.ll | 44 | ||||
-rw-r--r-- | llvm/test/tools/llvm-split/scc-global2global.ll | 28 |
7 files changed, 313 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-split/preserve-locals.ll b/llvm/test/tools/llvm-split/preserve-locals.ll new file mode 100644 index 00000000000..7556c25bba3 --- /dev/null +++ b/llvm/test/tools/llvm-split/preserve-locals.ll @@ -0,0 +1,65 @@ +; RUN: llvm-split -preserve-locals -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK0 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK1 %s + +; The local_var and local_func must not be separated. +; CHECK0: @local_var +; CHECK0: define internal fastcc void @local_func +; The main and a must not be separated. +; The main and local_func must not be together. +; CHECK1: @a +; CHECK1: define i32 @main +; CHECK1: declare fastcc void @local_func + +@a = internal global i32 0, align 4 +@global_storage = common global i32 0, align 4 +@local_var = internal global i32 0, align 4 + +; Function Attrs: nounwind +define i32 @main(i32 %x) { +entry: + %call = call fastcc i32 @foo(i32 %x, i32* nonnull @a) + %call1 = call fastcc i32 @baz(i32 %x) + %add = add nsw i32 %call, %call1 + ret i32 %add +} + +; Function Attrs: nounwind +define fastcc i32 @bar(i32 %b) { +entry: + %call = call fastcc i32 @baz(i32 %b) + ret i32 %call +} + +; Function Attrs: nounwind +define fastcc i32 @baz(i32 %x) { +entry: + store i32 %x, i32* @global_storage, align 4 + %shl = shl i32 %x, %x + ret i32 %shl +} + +; Function Attrs: noinline nounwind +define fastcc i32 @foo(i32 %a, i32* nocapture %b) { +entry: + call fastcc void @local_func() + %call = call fastcc i32 @bar(i32 %a) + %0 = load i32, i32* @global_storage, align 4 + %call1 = call fastcc i32 @baz(i32 %0) + %add = add nsw i32 %call, %call1 + store i32 %add, i32* %b, align 4 + %call.i = call fastcc i32 @baz(i32 %add) #2 + %add.i = add nsw i32 %call.i, 2 + %1 = load volatile i32, i32* @local_var, align 4 + %add3 = add nsw i32 %add.i, %1 + ret i32 %add3 +} + +; Function Attrs: noinline nounwind +define internal fastcc void @local_func() section ".text" { +entry: + %0 = load i32, i32* @global_storage, align 4 + %call = call fastcc i32 @foo(i32 %0, i32* null) + store volatile i32 %call, i32* @local_var, align 4 + ret void +} diff --git a/llvm/test/tools/llvm-split/scc-alias.ll b/llvm/test/tools/llvm-split/scc-alias.ll new file mode 100644 index 00000000000..f8400bd2c87 --- /dev/null +++ b/llvm/test/tools/llvm-split/scc-alias.ll @@ -0,0 +1,48 @@ +; All of the functions in this module must end up +; in the same partition without change of scope. +; RUN: llvm-split -j=2 -preserve-locals -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK1 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK0 %s + +; CHECK0: declare i32 @funInternal +; CHECK0: declare i32 @funExternal +; CHECK0: declare i32 @funInternal2 +; CHECK0: declare i32 @funExternal2 + +; All functions are in the same file. +; Local functions are still local. +; CHECK1: define internal i32 @funInternal +; CHECK1: define i32 @funExternal +; CHECK1: define internal i32 @funInternal2 +; CHECK1: define i32 @funExternal2 + + +@funInternalAlias = internal alias i32 (), i32 ()* @funInternal + +define internal i32 @funInternal() { +entry: + ret i32 0 +} + +; Direct call to local alias + +define i32 @funExternal() { +entry: + %x = call i32 @funInternalAlias() + ret i32 %x +} + +; Call to local function that calls local alias + +define internal i32 @funInternal2() { +entry: + %x = call i32 @funInternalAlias() + ret i32 %x +} + +define i32 @funExternal2() { +entry: + %x = call i32 @funInternal2() + ret i32 %x +} + diff --git a/llvm/test/tools/llvm-split/scc-callchain.ll b/llvm/test/tools/llvm-split/scc-callchain.ll new file mode 100644 index 00000000000..953a0244ae7 --- /dev/null +++ b/llvm/test/tools/llvm-split/scc-callchain.ll @@ -0,0 +1,48 @@ +; All of the functions in this module must end up +; in the same partition. + +; RUN: llvm-split -j=2 -preserve-locals -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK1 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK0 %s + +; CHECK0: declare i32 @funInternal0 +; CHECK0: declare i32 @funInternal1 +; CHECK0: declare i32 @funInternal2 +; CHECK0: declare i32 @funExternal + +; All functions are in the same file. +; Local functions are still local. +; CHECK1: define internal i32 @funInternal0 +; CHECK1: define internal i32 @funInternal1 +; CHECK1: define internal i32 @funInternal2 +; CHECK1: define i32 @funExternal +; CHECK1: define i32 @funExternal2 + +define internal i32 @funInternal0() { +entry: + ret i32 0 +} + +define internal i32 @funInternal1() { +entry: + %x = call i32 @funInternal0() + ret i32 %x +} + +define internal i32 @funInternal2() { +entry: + %x = call i32 @funInternal1() + ret i32 %x +} + +define i32 @funExternal() { +entry: + %x = call i32 @funInternal2() + ret i32 %x +} + +define i32 @funExternal2() { +entry: + %x = call i32 @funInternal0() + ret i32 %x +} diff --git a/llvm/test/tools/llvm-split/scc-comdat.ll b/llvm/test/tools/llvm-split/scc-comdat.ll new file mode 100644 index 00000000000..40fa930110b --- /dev/null +++ b/llvm/test/tools/llvm-split/scc-comdat.ll @@ -0,0 +1,32 @@ +; All functions in the same comdat group must +; be in the same module + +; RUN: llvm-split -j=2 -preserve-locals -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK1 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK0 %s + +; CHECK0: declare i32 @fun1 +; CHECK0: declare i32 @fun2 +; CHECK0: declare i32 @fun3 + +; CHECK1: define internal i32 @fun1 +; CHECK1: define internal i32 @fun2 +; CHECK1: define i32 @fun3 + +$fun = comdat any + +define internal i32 @fun1() section ".text.funs" comdat($fun) { +entry: + ret i32 0 +} + +define internal i32 @fun2() section ".text.funs" comdat($fun) { +entry: + ret i32 0 +} + +define i32 @fun3() section ".text.funs" comdat($fun) { +entry: + ret i32 0 +} + diff --git a/llvm/test/tools/llvm-split/scc-constants.ll b/llvm/test/tools/llvm-split/scc-constants.ll new file mode 100644 index 00000000000..066a8dac6da --- /dev/null +++ b/llvm/test/tools/llvm-split/scc-constants.ll @@ -0,0 +1,48 @@ +; All of the functions in this module must end up +; in the same partition. + +; RUN: llvm-split -j=2 -preserve-locals -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK1 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK0 %s + +; CHECK0: declare i32 @foo +; CHECK0: declare i32 @baz +; CHECK0: declare i32 @bar +; CHECK0: declare i32 @bar2 + +; CHECK1: @bla +; CHECK1: @bla2 +; CHECK1: define internal i32 @foo +; CHECK1: define internal i32 @baz +; CHECK1: define i32 @bar +; CHECK1: define i32 @bar2 + +%struct.anon = type { i64, i64 } + +@bla = internal global %struct.anon { i64 1, i64 2 }, align 8 +@bla2 = internal global %struct.anon { i64 1, i64 2 }, align 8 + +define internal i32 @foo() { +entry: + store i64 5, i64* getelementptr inbounds (%struct.anon, %struct.anon* @bla, i32 0, i32 0), align 8 + store i32 -1, i32* bitcast (i64* getelementptr inbounds (%struct.anon, %struct.anon* @bla2, i32 0, i32 1) to i32*), align 8 + ret i32 0 +} + +define internal i32 @baz() { +entry: + store i64 5, i64* getelementptr inbounds (%struct.anon, %struct.anon* @bla, i32 0, i32 0), align 8 + store i32 -1, i32* bitcast (i64* getelementptr inbounds (%struct.anon, %struct.anon* @bla2, i32 0, i32 1) to i32*), align 8 + ret i32 0 +} + +define i32 @bar() { + %call = call i32 @foo() + ret i32 0 +} + +define i32 @bar2() { + %call = call i32 @baz() + ret i32 0 +} + diff --git a/llvm/test/tools/llvm-split/scc-cycle.ll b/llvm/test/tools/llvm-split/scc-cycle.ll new file mode 100644 index 00000000000..031fa9b0316 --- /dev/null +++ b/llvm/test/tools/llvm-split/scc-cycle.ll @@ -0,0 +1,44 @@ +; All of the functions in this module must end up +; in the same partition. + +; Mutually recursive calls +; RUN: llvm-split -j=2 -preserve-locals -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK1 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK0 %s + +; CHECK0: declare i32 @funInternal0 +; CHECK0: declare i32 @funInternal1 +; CHECK0: declare i32 @funExternal0 +; CHECK0: declare i32 @funExternal1 + +; CHECK1: define internal i32 @funInternal0 +; CHECK1: define internal i32 @funInternal1 +; CHECK1: define i32 @funExternal0 +; CHECK1: define i32 @funExternal1 + +define internal i32 @funInternal0() { +entry: + %x = call i32 @funInternal1() + ret i32 %x +} + +define internal i32 @funInternal1() { +entry: + %x = call i32 @funInternal0() + ret i32 %x +} + +; Extrnal functions + +define i32 @funExternal0() { +entry: + %x = call i32 @funInternal0() + ret i32 %x +} + +define i32 @funExternal1() { +entry: + %x = call i32 @funInternal1() + ret i32 %x +} + diff --git a/llvm/test/tools/llvm-split/scc-global2global.ll b/llvm/test/tools/llvm-split/scc-global2global.ll new file mode 100644 index 00000000000..95ff5357d5b --- /dev/null +++ b/llvm/test/tools/llvm-split/scc-global2global.ll @@ -0,0 +1,28 @@ +; All of the functions and globals in this module must end up +; in the same partition. + +; RUN: llvm-split -j=2 -preserve-locals -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK1 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK0 %s + +; CHECK0: declare %struct.anon* @local0 +; CHECK0: declare i8** @local1 + +; CHECK1: @bla +; CHECK1: @ptr +; CHECK1: define internal %struct.anon* @local0 +; CHECK1: define internal i8** @local1 + +%struct.anon = type { i64, i64 } + +@bla = internal global %struct.anon { i64 1, i64 2 }, align 8 +@ptr = internal global i8* bitcast (%struct.anon* @bla to i8*), align 4 + +define internal %struct.anon* @local0() { + ret %struct.anon* @bla +} + +define internal i8** @local1() { + ret i8** @ptr +} + |