1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -simplifycfg-require-and-preserve-domtree=1 < %s -frame-pointer=all -verify-machineinstrs | FileCheck %s
4 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"
5 target triple = "i386-apple-macosx10.7"
7 ; This test case has a landing pad with two predecessors, and a variable that
8 ; is undef on the first edge while carrying the first function return value on
11 ; Live range splitting tries to isolate the block containing the first function
12 ; call, and it is important that the last split point is after the function call
13 ; so the return value can spill.
15 ; <rdar://problem/10664933>
17 @Exception = external unnamed_addr constant { ptr, ptr }
19 declare void @llvm.memset.p0.i32(ptr nocapture, i8, i32, i1) nounwind
21 define void @f(ptr nocapture %arg, ptr nocapture %arg1, ptr nocapture %arg2, ptr nocapture %arg3, i32 %arg4, i32 %arg5) optsize ssp personality ptr @__gxx_personality_v0 {
23 ; CHECK: ## %bb.0: ## %bb
24 ; CHECK-NEXT: pushl %ebp
25 ; CHECK-NEXT: .cfi_def_cfa_offset 8
26 ; CHECK-NEXT: .cfi_offset %ebp, -8
27 ; CHECK-NEXT: movl %esp, %ebp
28 ; CHECK-NEXT: .cfi_def_cfa_register %ebp
29 ; CHECK-NEXT: pushl %ebx
30 ; CHECK-NEXT: pushl %edi
31 ; CHECK-NEXT: pushl %esi
32 ; CHECK-NEXT: subl $28, %esp
33 ; CHECK-NEXT: .cfi_offset %esi, -20
34 ; CHECK-NEXT: .cfi_offset %edi, -16
35 ; CHECK-NEXT: .cfi_offset %ebx, -12
36 ; CHECK-NEXT: xorl %eax, %eax
37 ; CHECK-NEXT: xorl %edi, %edi
38 ; CHECK-NEXT: testb %al, %al
40 ; CHECK-NEXT: ## implicit-def: $ebx
41 ; CHECK-NEXT: calll __Znam
43 ; CHECK-NEXT: ## %bb.1: ## %bb11
44 ; CHECK-NEXT: movl %eax, %esi
45 ; CHECK-NEXT: movb $1, %al
46 ; CHECK-NEXT: testb %al, %al
47 ; CHECK-NEXT: jne LBB0_2
48 ; CHECK-NEXT: ## %bb.7: ## %bb31
49 ; CHECK-NEXT: ## implicit-def: $eax
50 ; CHECK-NEXT: ## kill: killed $eax
51 ; CHECK-NEXT: LBB0_8: ## %bb38
52 ; CHECK-NEXT: ## =>This Loop Header: Depth=1
53 ; CHECK-NEXT: ## Child Loop BB0_13 Depth 2
54 ; CHECK-NEXT: ## Child Loop BB0_16 Depth 3
55 ; CHECK-NEXT: ## Child Loop BB0_21 Depth 2
56 ; CHECK-NEXT: movb $1, %al
57 ; CHECK-NEXT: testb %al, %al
58 ; CHECK-NEXT: jne LBB0_9
59 ; CHECK-NEXT: ## %bb.10: ## %bb41
60 ; CHECK-NEXT: ## in Loop: Header=BB0_8 Depth=1
62 ; CHECK-NEXT: xorl %eax, %eax
63 ; CHECK-NEXT: movl %eax, {{[0-9]+}}(%esp)
64 ; CHECK-NEXT: movl %eax, {{[0-9]+}}(%esp)
65 ; CHECK-NEXT: movl %esi, (%esp)
66 ; CHECK-NEXT: calll _Pjii
68 ; CHECK-NEXT: ## %bb.11: ## %bb42
69 ; CHECK-NEXT: ## in Loop: Header=BB0_8 Depth=1
70 ; CHECK-NEXT: xorl %eax, %eax
71 ; CHECK-NEXT: decl %eax
72 ; CHECK-NEXT: testl %eax, %eax
73 ; CHECK-NEXT: jne LBB0_18
74 ; CHECK-NEXT: ## %bb.12: ## %bb45.preheader
75 ; CHECK-NEXT: ## in Loop: Header=BB0_8 Depth=1
76 ; CHECK-NEXT: movl $255, %eax
77 ; CHECK-NEXT: LBB0_13: ## %bb45
78 ; CHECK-NEXT: ## Parent Loop BB0_8 Depth=1
79 ; CHECK-NEXT: ## => This Loop Header: Depth=2
80 ; CHECK-NEXT: ## Child Loop BB0_16 Depth 3
81 ; CHECK-NEXT: movb $1, %cl
82 ; CHECK-NEXT: testb %cl, %cl
83 ; CHECK-NEXT: jne LBB0_19
84 ; CHECK-NEXT: ## %bb.14: ## %bb48
85 ; CHECK-NEXT: ## in Loop: Header=BB0_13 Depth=2
86 ; CHECK-NEXT: jne LBB0_17
87 ; CHECK-NEXT: ## %bb.15: ## %bb49.preheader
88 ; CHECK-NEXT: ## in Loop: Header=BB0_13 Depth=2
89 ; CHECK-NEXT: xorl %ecx, %ecx
90 ; CHECK-NEXT: movl %esi, %edx
91 ; CHECK-NEXT: movl %edi, %ebx
92 ; CHECK-NEXT: LBB0_16: ## %bb49
93 ; CHECK-NEXT: ## Parent Loop BB0_8 Depth=1
94 ; CHECK-NEXT: ## Parent Loop BB0_13 Depth=2
95 ; CHECK-NEXT: ## => This Inner Loop Header: Depth=3
96 ; CHECK-NEXT: incl %ecx
97 ; CHECK-NEXT: addl $4, %edx
98 ; CHECK-NEXT: decl %ebx
99 ; CHECK-NEXT: jne LBB0_16
100 ; CHECK-NEXT: LBB0_17: ## %bb57
101 ; CHECK-NEXT: ## in Loop: Header=BB0_13 Depth=2
102 ; CHECK-NEXT: decl %eax
103 ; CHECK-NEXT: jmp LBB0_13
104 ; CHECK-NEXT: LBB0_19: ## %bb59
105 ; CHECK-NEXT: ## in Loop: Header=BB0_8 Depth=1
106 ; CHECK-NEXT: movl $-4, %eax
107 ; CHECK-NEXT: movl %eax, {{[0-9]+}}(%esp)
108 ; CHECK-NEXT: movl $0, (%esp)
109 ; CHECK-NEXT: calll ___bzero
110 ; CHECK-NEXT: movb $1, %al
111 ; CHECK-NEXT: testb %al, %al
112 ; CHECK-NEXT: jne LBB0_22
113 ; CHECK-NEXT: ## %bb.20: ## %bb61.preheader
114 ; CHECK-NEXT: ## in Loop: Header=BB0_8 Depth=1
115 ; CHECK-NEXT: movl %esi, %eax
116 ; CHECK-NEXT: movl %edi, %ecx
117 ; CHECK-NEXT: LBB0_21: ## %bb61
118 ; CHECK-NEXT: ## Parent Loop BB0_8 Depth=1
119 ; CHECK-NEXT: ## => This Inner Loop Header: Depth=2
120 ; CHECK-NEXT: movl $0, (%eax)
121 ; CHECK-NEXT: addl $4, %eax
122 ; CHECK-NEXT: decl %ecx
123 ; CHECK-NEXT: jne LBB0_21
124 ; CHECK-NEXT: LBB0_22: ## %bb67
125 ; CHECK-NEXT: ## in Loop: Header=BB0_8 Depth=1
126 ; CHECK-NEXT: decl {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Folded Spill
127 ; CHECK-NEXT: jmp LBB0_8
128 ; CHECK-NEXT: LBB0_18: ## %bb43
130 ; CHECK-NEXT: movl %esi, %ebx
131 ; CHECK-NEXT: calll _OnOverFlow
133 ; CHECK-NEXT: jmp LBB0_3
134 ; CHECK-NEXT: LBB0_2: ## %bb29
136 ; CHECK-NEXT: movl %esi, %ebx
137 ; CHECK-NEXT: calll _OnOverFlow
139 ; CHECK-NEXT: LBB0_3: ## %bb30
141 ; CHECK-NEXT: LBB0_4: ## %bb20.loopexit
143 ; CHECK-NEXT: LBB0_9:
144 ; CHECK-NEXT: movl %esi, %ebx
145 ; CHECK-NEXT: LBB0_6: ## %bb23
146 ; CHECK-NEXT: testl %ebx, %ebx
147 ; CHECK-NEXT: addl $28, %esp
148 ; CHECK-NEXT: popl %esi
149 ; CHECK-NEXT: popl %edi
150 ; CHECK-NEXT: popl %ebx
151 ; CHECK-NEXT: popl %ebp
153 ; CHECK-NEXT: LBB0_5: ## %bb20.loopexit.split-lp
155 ; CHECK-NEXT: jmp LBB0_6
156 ; CHECK-NEXT: Lfunc_end0:
158 br i1 undef, label %bb6, label %bb7
161 %tmp = select i1 false, i32 0, i32 undef
164 bb7: ; preds = %bb6, %bb
165 %tmp8 = phi i32 [ %tmp, %bb6 ], [ 0, %bb ]
166 %tmp9 = shl i32 %tmp8, 2
167 %tmp10 = invoke noalias ptr @_Znam(i32 undef) optsize
168 to label %bb11 unwind label %bb20
171 %tmp12 = ptrtoint ptr %tmp10 to i32
172 %tmp14 = shl i32 %tmp8, 2
173 %tmp15 = getelementptr i32, ptr %tmp10, i32 undef
174 %tmp16 = getelementptr i32, ptr %tmp10, i32 undef
175 %tmp17 = zext i32 %tmp9 to i64
176 %tmp18 = add i64 %tmp17, -1
177 %tmp19 = icmp ugt i64 %tmp18, 4294967295
178 br i1 %tmp19, label %bb29, label %bb31
180 bb20: ; preds = %bb43, %bb41, %bb29, %bb7
181 %tmp21 = phi i32 [ undef, %bb7 ], [ %tmp12, %bb43 ], [ %tmp12, %bb29 ], [ %tmp12, %bb41 ]
182 %tmp22 = landingpad { ptr, i32 }
184 br i1 undef, label %bb23, label %bb69
186 bb23: ; preds = %bb38, %bb20
187 %tmp24 = phi i32 [ %tmp12, %bb38 ], [ %tmp21, %bb20 ]
188 %tmp25 = icmp eq i32 %tmp24, 0
189 br i1 %tmp25, label %bb28, label %bb26
191 bb26: ; preds = %bb23
192 %tmp27 = inttoptr i32 %tmp24 to ptr
195 bb28: ; preds = %bb26, %bb23
198 bb29: ; preds = %bb11
199 invoke void @OnOverFlow() optsize
200 to label %bb30 unwind label %bb20
202 bb30: ; preds = %bb29
205 bb31: ; preds = %bb11
206 %tmp33 = zext i32 %tmp8 to i64
207 %tmp34 = add i64 %tmp33, -1
208 %tmp35 = icmp ugt i64 %tmp34, 4294967295
209 %tmp36 = icmp sgt i32 %tmp8, 0
210 %tmp37 = add i32 %tmp9, -4
213 bb38: ; preds = %bb67, %bb31
214 %tmp39 = phi i32 [ %tmp68, %bb67 ], [ undef, %bb31 ]
215 %tmp40 = icmp sgt i32 %tmp39, undef
216 br i1 %tmp40, label %bb41, label %bb23
218 bb41: ; preds = %bb38
219 invoke void @Pjii(ptr %tmp16, i32 0, i32 %tmp8) optsize
220 to label %bb42 unwind label %bb20
222 bb42: ; preds = %bb41
223 tail call void @llvm.memset.p0.i32(ptr %tmp15, i8 0, i32 %tmp9, i1 false) nounwind
224 br i1 %tmp35, label %bb43, label %bb45
226 bb43: ; preds = %bb42
227 invoke void @OnOverFlow() optsize
228 to label %bb44 unwind label %bb20
230 bb44: ; preds = %bb43
233 bb45: ; preds = %bb57, %bb42
234 %tmp46 = phi i32 [ %tmp58, %bb57 ], [ 255, %bb42 ]
235 %tmp47 = icmp slt i32 undef, 0
236 br i1 %tmp47, label %bb48, label %bb59
238 bb48: ; preds = %bb45
239 tail call void @llvm.memset.p0.i32(ptr %tmp15, i8 0, i32 %tmp9, i1 false) nounwind
240 br i1 %tmp36, label %bb49, label %bb57
242 bb49: ; preds = %bb49, %bb48
243 %tmp50 = phi i32 [ %tmp55, %bb49 ], [ 0, %bb48 ]
244 %tmp51 = add i32 %tmp50, undef
245 %tmp52 = add i32 %tmp50, undef
246 %tmp53 = getelementptr i32, ptr %tmp10, i32 %tmp52
247 %tmp54 = load i32, ptr %tmp53, align 4
248 %tmp55 = add i32 %tmp50, 1
249 %tmp56 = icmp eq i32 %tmp55, %tmp8
250 br i1 %tmp56, label %bb57, label %bb49
252 bb57: ; preds = %bb49, %bb48
253 %tmp58 = add i32 %tmp46, -1
256 bb59: ; preds = %bb45
257 %tmp60 = ashr i32 %tmp46, 31
258 tail call void @llvm.memset.p0.i32(ptr null, i8 0, i32 %tmp37, i1 false) nounwind
259 br i1 %tmp36, label %bb61, label %bb67
261 bb61: ; preds = %bb61, %bb59
262 %tmp62 = phi i32 [ %tmp65, %bb61 ], [ 0, %bb59 ]
263 %tmp63 = add i32 %tmp62, %tmp14
264 %tmp64 = getelementptr i32, ptr %tmp10, i32 %tmp63
265 store i32 0, ptr %tmp64, align 4
266 %tmp65 = add i32 %tmp62, 1
267 %tmp66 = icmp eq i32 %tmp65, %tmp8
268 br i1 %tmp66, label %bb67, label %bb61
270 bb67: ; preds = %bb61, %bb59
271 %tmp68 = add i32 %tmp39, -1
274 bb69: ; preds = %bb20
275 resume { ptr, i32 } %tmp22
278 declare i32 @__gxx_personality_v0(...)
280 declare noalias ptr @_Znam(i32) optsize
282 declare void @Pjii(ptr, i32, i32) optsize
284 declare i32 @llvm.eh.typeid.for(ptr) nounwind readnone
286 declare void @OnOverFlow() noreturn optsize ssp align 2