From 72ad17c48c15562fe31c65f6daa09c83f42860c1 Mon Sep 17 00:00:00 2001 From: Venkatraman Govindaraju Date: Sat, 1 Jun 2013 04:51:18 +0000 Subject: [Sparc] Generate correct code for leaf functions with stack objects git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183067 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/SPARC/leafproc.ll | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/CodeGen/SPARC') diff --git a/test/CodeGen/SPARC/leafproc.ll b/test/CodeGen/SPARC/leafproc.ll index 5abdfba..a162df1 100644 --- a/test/CodeGen/SPARC/leafproc.ll +++ b/test/CodeGen/SPARC/leafproc.ll @@ -55,3 +55,26 @@ entry: %6 = add nsw i32 %5, %h ret i32 %6 } + +; CHECK: leaf_proc_with_local_array: +; CHECK: add %sp, -104, %sp +; CHECK: or %g0, 1, [[R1:%[go][0-7]]] +; CHECK: st [[R1]], [%sp+96] +; CHECK: or %g0, 2, [[R2:%[go][0-7]]] +; CHECK: st [[R2]], [%sp+100] +; CHECK: ld {{.+}}, %o0 +; CHECK: jmp %o7+8 +; CHECK-NEXT: add %sp, 104, %sp + +define i32 @leaf_proc_with_local_array(i32 %a, i32 %b, i32 %c) { +entry: + %array = alloca [2 x i32], align 4 + %0 = sub nsw i32 %b, %c + %1 = getelementptr inbounds [2 x i32]* %array, i32 0, i32 0 + store i32 1, i32* %1, align 4 + %2 = getelementptr inbounds [2 x i32]* %array, i32 0, i32 1 + store i32 2, i32* %2, align 4 + %3 = getelementptr inbounds [2 x i32]* %array, i32 0, i32 %a + %4 = load i32* %3, align 4 + ret i32 %4 +} -- cgit v1.1