Add to the split module utility an SCC based method which allows not to globalize any local variables.
Summary:
Currently llvm::SplitModule as the first step globalizes all local objects, which might not be desirable in some scenarios.
This change adds a new flag to llvm::SplitModule that uses SCC approach to search for a balanced partition without the need to externalize symbols.
Such partition might not be possible or fully balanced for a given number of partitions, and is a function of the module properties (global/local dependencies within the module).
Joint development Tobias Edler von Koch (tobias@codeaurora.org) and Sergei Larin (slarin@codeaurora.org)
Subscribers: llvm-commits, joker.eph
Differential Revision: http://reviews.llvm.org/D16124
llvm-svn: 258083
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 0000000..95ff535
--- /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
+}
+