1 ; RUN: llc -march=sparc -disable-sparc-leaf-proc=0 < %s | FileCheck %s
3 ; CHECK-LABEL: func_nobody:
6 define void @func_nobody() {
12 ; CHECK-LABEL: return_int_const:
14 ; CHECK-NEXT: mov 1729, %o0
15 define i32 @return_int_const() {
20 ; CHECK-LABEL: return_double_const:
23 ; CHECK-NEXT: ldd {{.*}}, %f0
25 define double @return_double_const() {
27 ret double 0.000000e+00
30 ; CHECK-LABEL: leaf_proc_with_args:
31 ; CHECK: add {{%o[0-1]}}, {{%o[0-1]}}, [[R:%[go][0-7]]]
33 ; CHECK-NEXT: add [[R]], %o2, %o0
35 define i32 @leaf_proc_with_args(i32 %a, i32 %b, i32 %c) {
37 %0 = add nsw i32 %b, %a
38 %1 = add nsw i32 %0, %c
42 ; CHECK-LABEL: leaf_proc_with_args_in_stack:
43 ; CHECK-DAG: ld [%sp+92], {{%[go][0-7]}}
44 ; CHECK-DAG: ld [%sp+96], {{%[go][0-7]}}
46 ; CHECK-NEXT: add {{.*}}, %o0
47 define i32 @leaf_proc_with_args_in_stack(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h) {
49 %0 = add nsw i32 %b, %a
50 %1 = add nsw i32 %0, %c
51 %2 = add nsw i32 %1, %d
52 %3 = add nsw i32 %2, %e
53 %4 = add nsw i32 %3, %f
54 %5 = add nsw i32 %4, %g
55 %6 = add nsw i32 %5, %h
59 ; CHECK-LABEL: leaf_proc_with_local_array:
60 ; CHECK: add %sp, -104, %sp
61 ; CHECK: mov 1, [[R1:%[go][0-7]]]
62 ; CHECK: st [[R1]], [%sp+96]
63 ; CHECK: mov 2, [[R2:%[go][0-7]]]
64 ; CHECK: st [[R2]], [%sp+100]
65 ; CHECK: ld {{.+}}, %o0
67 ; CHECK-NEXT: add %sp, 104, %sp
69 define i32 @leaf_proc_with_local_array(i32 %a, i32 %b, i32 %c) {
71 %array = alloca [2 x i32], align 4
72 %0 = sub nsw i32 %b, %c
73 %1 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 0
74 store i32 1, ptr %1, align 4
75 %2 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1
76 store i32 2, ptr %2, align 4
77 %3 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 %a
78 %4 = load i32, ptr %3, align 4
82 ; Here we have a leaf function where it contains inline assembly, which means
83 ; that register renumbering might interfere with the register constraints.
84 ; As a result the function is not marked as being a leaf one.
86 ; CHECK-LABEL: leaf_proc_give_up
87 ; CHECK: save %sp, -96, %sp
88 ; CHECK: ld [%fp+92], %o5
96 ; CHECK-NEXT: restore %g0, %o0, %o0
98 define i32 @leaf_proc_give_up(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
100 %g = call i32 asm sideeffect "", "={o0},{g1},{o0},{o1},{o2},{o3},{o4},{o5}"(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6)