1*9880d681SAndroid Build Coastguard Worker; RUN: llvm-split -preserve-locals -o %t %s 2*9880d681SAndroid Build Coastguard Worker; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK0 %s 3*9880d681SAndroid Build Coastguard Worker; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK1 %s 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker; The local_var and local_func must not be separated. 6*9880d681SAndroid Build Coastguard Worker; CHECK0: @local_var 7*9880d681SAndroid Build Coastguard Worker; CHECK0: define internal fastcc void @local_func 8*9880d681SAndroid Build Coastguard Worker; The main and a must not be separated. 9*9880d681SAndroid Build Coastguard Worker; The main and local_func must not be together. 10*9880d681SAndroid Build Coastguard Worker; CHECK1: @a 11*9880d681SAndroid Build Coastguard Worker; CHECK1: define i32 @main 12*9880d681SAndroid Build Coastguard Worker; CHECK1: declare fastcc void @local_func 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker@a = internal global i32 0, align 4 15*9880d681SAndroid Build Coastguard Worker@global_storage = common global i32 0, align 4 16*9880d681SAndroid Build Coastguard Worker@local_var = internal global i32 0, align 4 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind 19*9880d681SAndroid Build Coastguard Workerdefine i32 @main(i32 %x) { 20*9880d681SAndroid Build Coastguard Workerentry: 21*9880d681SAndroid Build Coastguard Worker %call = call fastcc i32 @foo(i32 %x, i32* nonnull @a) 22*9880d681SAndroid Build Coastguard Worker %call1 = call fastcc i32 @baz(i32 %x) 23*9880d681SAndroid Build Coastguard Worker %add = add nsw i32 %call, %call1 24*9880d681SAndroid Build Coastguard Worker ret i32 %add 25*9880d681SAndroid Build Coastguard Worker} 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind 28*9880d681SAndroid Build Coastguard Workerdefine fastcc i32 @bar(i32 %b) { 29*9880d681SAndroid Build Coastguard Workerentry: 30*9880d681SAndroid Build Coastguard Worker %call = call fastcc i32 @baz(i32 %b) 31*9880d681SAndroid Build Coastguard Worker ret i32 %call 32*9880d681SAndroid Build Coastguard Worker} 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind 35*9880d681SAndroid Build Coastguard Workerdefine fastcc i32 @baz(i32 %x) { 36*9880d681SAndroid Build Coastguard Workerentry: 37*9880d681SAndroid Build Coastguard Worker store i32 %x, i32* @global_storage, align 4 38*9880d681SAndroid Build Coastguard Worker %shl = shl i32 %x, %x 39*9880d681SAndroid Build Coastguard Worker ret i32 %shl 40*9880d681SAndroid Build Coastguard Worker} 41*9880d681SAndroid Build Coastguard Worker 42*9880d681SAndroid Build Coastguard Worker; Function Attrs: noinline nounwind 43*9880d681SAndroid Build Coastguard Workerdefine fastcc i32 @foo(i32 %a, i32* nocapture %b) { 44*9880d681SAndroid Build Coastguard Workerentry: 45*9880d681SAndroid Build Coastguard Worker call fastcc void @local_func() 46*9880d681SAndroid Build Coastguard Worker %call = call fastcc i32 @bar(i32 %a) 47*9880d681SAndroid Build Coastguard Worker %0 = load i32, i32* @global_storage, align 4 48*9880d681SAndroid Build Coastguard Worker %call1 = call fastcc i32 @baz(i32 %0) 49*9880d681SAndroid Build Coastguard Worker %add = add nsw i32 %call, %call1 50*9880d681SAndroid Build Coastguard Worker store i32 %add, i32* %b, align 4 51*9880d681SAndroid Build Coastguard Worker %call.i = call fastcc i32 @baz(i32 %add) #2 52*9880d681SAndroid Build Coastguard Worker %add.i = add nsw i32 %call.i, 2 53*9880d681SAndroid Build Coastguard Worker %1 = load volatile i32, i32* @local_var, align 4 54*9880d681SAndroid Build Coastguard Worker %add3 = add nsw i32 %add.i, %1 55*9880d681SAndroid Build Coastguard Worker ret i32 %add3 56*9880d681SAndroid Build Coastguard Worker} 57*9880d681SAndroid Build Coastguard Worker 58*9880d681SAndroid Build Coastguard Worker; Function Attrs: noinline nounwind 59*9880d681SAndroid Build Coastguard Workerdefine internal fastcc void @local_func() section ".text" { 60*9880d681SAndroid Build Coastguard Workerentry: 61*9880d681SAndroid Build Coastguard Worker %0 = load i32, i32* @global_storage, align 4 62*9880d681SAndroid Build Coastguard Worker %call = call fastcc i32 @foo(i32 %0, i32* null) 63*9880d681SAndroid Build Coastguard Worker store volatile i32 %call, i32* @local_var, align 4 64*9880d681SAndroid Build Coastguard Worker ret void 65*9880d681SAndroid Build Coastguard Worker} 66