1 ; RUN: llvm-split -preserve-locals -o %t %s
2 ; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK0 %s
3 ; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK1 %s
5 ; The local_var and local_func must not be separated.
7 ; CHECK0: define internal fastcc void @local_func
8 ; The main and a must not be separated.
9 ; The main and local_func must not be together.
11 ; CHECK1: define i32 @main
12 ; CHECK1: declare dso_local fastcc void @local_func
14 @a = internal global i32 0, align 4
15 @global_storage = common global i32 0, align 4
16 @local_var = internal global i32 0, align 4
18 ; Function Attrs: nounwind
19 define i32 @main(i32 %x) {
21 %call = call fastcc i32 @foo(i32 %x, ptr nonnull @a)
22 %call1 = call fastcc i32 @baz(i32 %x)
23 %add = add nsw i32 %call, %call1
27 ; Function Attrs: nounwind
28 define fastcc i32 @bar(i32 %b) {
30 %call = call fastcc i32 @baz(i32 %b)
34 ; Function Attrs: nounwind
35 define fastcc i32 @baz(i32 %x) {
37 store i32 %x, ptr @global_storage, align 4
42 ; Function Attrs: noinline nounwind
43 define fastcc i32 @foo(i32 %a, ptr nocapture %b) {
45 call fastcc void @local_func()
46 %call = call fastcc i32 @bar(i32 %a)
47 %0 = load i32, ptr @global_storage, align 4
48 %call1 = call fastcc i32 @baz(i32 %0)
49 %add = add nsw i32 %call, %call1
50 store i32 %add, ptr %b, align 4
51 %call.i = call fastcc i32 @baz(i32 %add) #2
52 %add.i = add nsw i32 %call.i, 2
53 %1 = load volatile i32, ptr @local_var, align 4
54 %add3 = add nsw i32 %add.i, %1
58 ; Function Attrs: noinline nounwind
59 define internal fastcc void @local_func() section ".text" {
61 %0 = load i32, ptr @global_storage, align 4
62 %call = call fastcc i32 @foo(i32 %0, ptr null)
63 store volatile i32 %call, ptr @local_var, align 4