1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
llvm-mirror/test/tools/llvm-split/preserve-locals.ll
Sergei Larin 72115d5fb6 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
2016-01-18 21:07:13 +00:00

66 lines
1.8 KiB
LLVM

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