1 ; RUN: llc %s -o - | FileCheck %s --check-prefix=CHECK
3 ; This test checks that we do not use shrink-wrapping when
4 ; the function does not have any frame pointer and may unwind.
5 ; This is a workaround for a limitation in the emission of
6 ; the CFI directives, that are not correct in such case.
9 ; Note: This test cannot be merged with the shrink-wrapping tests
10 ; because the booleans set on the command line take precedence on
11 ; the target logic that disable shrink-wrapping.
12 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
13 target triple = "x86_64-apple-macosx"
16 ; No shrink-wrapping should occur here, until the CFI information are fixed.
17 ; CHECK-LABEL: framelessUnwind:
20 ; (What we push does not matter. It should be some random sratch register.)
23 ; Compare the arguments and jump to exit.
24 ; After the prologue is set.
25 ; CHECK: movl %edi, [[ARG0CPY:%e[a-z]+]]
26 ; CHECK-NEXT: cmpl %esi, [[ARG0CPY]]
27 ; CHECK-NEXT: jge [[EXIT_LABEL:LBB[0-9_]+]]
29 ; Store %a in the alloca.
30 ; CHECK: movl [[ARG0CPY]], 4(%rsp)
31 ; Set the alloca address in the second argument.
32 ; CHECK-NEXT: leaq 4(%rsp), %rsi
33 ; Set the first argument to zero.
34 ; CHECK-NEXT: xorl %edi, %edi
35 ; CHECK-NEXT: callq _doSomething
37 ; CHECK: [[EXIT_LABEL]]:
39 ; Without shrink-wrapping, epilogue is in the exit block.
40 ; Epilogue code. (What we pop does not matter.)
44 define i32 @framelessUnwind(i32 %a, i32 %b) #0 {
45 %tmp = alloca i32, align 4
46 %tmp2 = icmp slt i32 %a, %b
47 br i1 %tmp2, label %true, label %false
50 store i32 %a, i32* %tmp, align 4
51 %tmp4 = call i32 @doSomething(i32 0, i32* %tmp)
55 %tmp.0 = phi i32 [ %tmp4, %true ], [ %a, %0 ]
59 declare i32 @doSomething(i32, i32*)
61 attributes #0 = { "no-frame-pointer-elim"="false" }
63 ; Shrink-wrapping should occur here. We have a frame pointer.
64 ; CHECK-LABEL: frameUnwind:
66 ; Compare the arguments and jump to exit.
69 ; Compare the arguments and jump to exit.
70 ; After the prologue is set.
71 ; CHECK: movl %edi, [[ARG0CPY:%e[a-z]+]]
72 ; CHECK-NEXT: cmpl %esi, [[ARG0CPY]]
73 ; CHECK-NEXT: jge [[EXIT_LABEL:LBB[0-9_]+]]
77 ; CHECK: movq %rsp, %rbp
79 ; Store %a in the alloca.
80 ; CHECK: movl [[ARG0CPY]], -4(%rbp)
81 ; Set the alloca address in the second argument.
82 ; CHECK-NEXT: leaq -4(%rbp), %rsi
83 ; Set the first argument to zero.
84 ; CHECK-NEXT: xorl %edi, %edi
85 ; CHECK-NEXT: callq _doSomething
87 ; Epilogue code. (What we pop does not matter.)
90 ; CHECK: [[EXIT_LABEL]]:
92 define i32 @frameUnwind(i32 %a, i32 %b) #1 {
93 %tmp = alloca i32, align 4
94 %tmp2 = icmp slt i32 %a, %b
95 br i1 %tmp2, label %true, label %false
98 store i32 %a, i32* %tmp, align 4
99 %tmp4 = call i32 @doSomething(i32 0, i32* %tmp)
103 %tmp.0 = phi i32 [ %tmp4, %true ], [ %a, %0 ]
107 attributes #1 = { "no-frame-pointer-elim"="true" }
109 ; Shrink-wrapping should occur here. We do not have to unwind.
110 ; CHECK-LABEL: framelessnoUnwind:
112 ; Compare the arguments and jump to exit.
113 ; No prologue needed.
115 ; Compare the arguments and jump to exit.
116 ; After the prologue is set.
117 ; CHECK: movl %edi, [[ARG0CPY:%e[a-z]+]]
118 ; CHECK-NEXT: cmpl %esi, [[ARG0CPY]]
119 ; CHECK-NEXT: jge [[EXIT_LABEL:LBB[0-9_]+]]
122 ; (What we push does not matter. It should be some random sratch register.)
125 ; Store %a in the alloca.
126 ; CHECK: movl [[ARG0CPY]], 4(%rsp)
127 ; Set the alloca address in the second argument.
128 ; CHECK-NEXT: leaq 4(%rsp), %rsi
129 ; Set the first argument to zero.
130 ; CHECK-NEXT: xorl %edi, %edi
131 ; CHECK-NEXT: callq _doSomething
136 ; CHECK: [[EXIT_LABEL]]:
138 define i32 @framelessnoUnwind(i32 %a, i32 %b) #2 {
139 %tmp = alloca i32, align 4
140 %tmp2 = icmp slt i32 %a, %b
141 br i1 %tmp2, label %true, label %false
144 store i32 %a, i32* %tmp, align 4
145 %tmp4 = call i32 @doSomething(i32 0, i32* %tmp)
149 %tmp.0 = phi i32 [ %tmp4, %true ], [ %a, %0 ]
153 attributes #2 = { "no-frame-pointer-elim"="false" nounwind }