1 ; RUN: llc < %s -O1 -mtriple thumbv7-apple-ios6 | FileCheck %s
2 ; Just make sure no one tries to make the assumption that the normal edge of an
3 ; invoke is never a critical edge. Previously, this code would assert.
5 %struct.__CFString = type opaque
7 declare void @bar(ptr, ptr)
9 define noalias ptr @foo(ptr nocapture %inRefURL) noreturn ssp personality ptr @__gxx_personality_sj0 {
11 %call = tail call ptr @bar3()
12 %call2 = invoke ptr @bar2()
13 to label %for.cond unwind label %lpad
15 for.cond: ; preds = %entry, %for.cond
16 invoke void @bar(ptr undef, ptr null)
17 to label %for.cond unwind label %lpad5
19 lpad: ; preds = %entry
20 %0 = landingpad { ptr, i32 }
22 %1 = extractvalue { ptr, i32 } %0, 0
23 %2 = extractvalue { ptr, i32 } %0, 1
26 lpad5: ; preds = %for.cond
27 %3 = landingpad { ptr, i32 }
29 %4 = extractvalue { ptr, i32 } %3, 0
30 %5 = extractvalue { ptr, i32 } %3, 1
31 invoke void @release(ptr %call2)
32 to label %ehcleanup unwind label %terminate.lpad.i.i16
34 terminate.lpad.i.i16: ; preds = %lpad5
35 %6 = landingpad { ptr, i32 }
37 tail call void @terminatev() noreturn nounwind
40 ehcleanup: ; preds = %lpad5, %lpad
41 %exn.slot.0 = phi ptr [ %1, %lpad ], [ %4, %lpad5 ]
42 %ehselector.slot.0 = phi i32 [ %2, %lpad ], [ %5, %lpad5 ]
43 invoke void @release(ptr %call)
44 to label %_ZN5SmartIPK10__CFStringED1Ev.exit unwind label %terminate.lpad.i.i
46 terminate.lpad.i.i: ; preds = %ehcleanup
47 %7 = landingpad { ptr, i32 }
49 tail call void @terminatev() noreturn nounwind
52 _ZN5SmartIPK10__CFStringED1Ev.exit: ; preds = %ehcleanup
53 %lpad.val = insertvalue { ptr, i32 } undef, ptr %exn.slot.0, 0
54 %lpad.val12 = insertvalue { ptr, i32 } %lpad.val, i32 %ehselector.slot.0, 1
55 resume { ptr, i32 } %lpad.val12
62 declare i32 @__gxx_personality_sj0(...)
64 declare void @release(ptr)
66 declare void @terminatev()
68 ; Make sure that the instruction DemoteRegToStack inserts to reload
69 ; %call.i.i.i14.i.i follows the instruction that saves the value to the stack in
70 ; basic block %entry.do.body.i.i.i_crit_edge.
71 ; Previously, DemoteRegToStack would insert a load instruction into the entry
72 ; block to reload %call.i.i.i14.i.i before the phi instruction (%0) in block
75 ; CHECK-LABEL: __Z4foo1c:
77 ; CHECK: {{.*}}@ %do.body.i.i.i.preheader
78 ; CHECK: str r0, [sp, [[OFFSET:#[0-9]+]]]
79 ; CHECK: {{.*}}@ %do.body.i.i.i
80 ; CHECK: ldr [[R0:r[0-9]+]], [sp, [[OFFSET]]]
83 %"class.std::__1::basic_string" = type { %"class.std::__1::__compressed_pair" }
84 %"class.std::__1::__compressed_pair" = type { %"class.std::__1::__libcpp_compressed_pair_imp" }
85 %"class.std::__1::__libcpp_compressed_pair_imp" = type { %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep" }
86 %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep" = type { %union.anon }
87 %union.anon = type { %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__long" }
88 %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__long" = type { i32, i32, ptr }
90 @.str = private unnamed_addr constant [12 x i8] c"some_string\00", align 1
92 define void @_Z4foo1c(i8 signext %a) personality ptr @__gxx_personality_sj0 {
94 %s1 = alloca %"class.std::__1::basic_string", align 4
95 call void @_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm(ptr %s1, ptr @.str, i32 11)
96 %call.i.i.i14.i.i = invoke noalias ptr @_Znwm(i32 1024)
97 to label %do.body.i.i.i unwind label %lpad.body
99 do.body.i.i.i: ; preds = %entry, %_ZNSt3__116allocator_traitsINS_9allocatorIcEEE9constructIccEEvRS2_PT_RKT0_.exit.i.i.i
100 %lsr.iv = phi i32 [ %lsr.iv.next, %_ZNSt3__116allocator_traitsINS_9allocatorIcEEE9constructIccEEvRS2_PT_RKT0_.exit.i.i.i ], [ -1024, %entry ]
101 %0 = phi ptr [ %incdec.ptr.i.i.i, %_ZNSt3__116allocator_traitsINS_9allocatorIcEEE9constructIccEEvRS2_PT_RKT0_.exit.i.i.i ], [ %call.i.i.i14.i.i, %entry ]
102 %new.isnull.i.i.i.i = icmp eq ptr %0, null
103 br i1 %new.isnull.i.i.i.i, label %_ZNSt3__116allocator_traitsINS_9allocatorIcEEE9constructIccEEvRS2_PT_RKT0_.exit.i.i.i, label %new.notnull.i.i.i.i
105 new.notnull.i.i.i.i: ; preds = %do.body.i.i.i
106 store i8 %a, ptr %0, align 1
107 br label %_ZNSt3__116allocator_traitsINS_9allocatorIcEEE9constructIccEEvRS2_PT_RKT0_.exit.i.i.i
109 _ZNSt3__116allocator_traitsINS_9allocatorIcEEE9constructIccEEvRS2_PT_RKT0_.exit.i.i.i: ; preds = %new.notnull.i.i.i.i, %do.body.i.i.i
110 %1 = phi ptr [ null, %do.body.i.i.i ], [ %0, %new.notnull.i.i.i.i ]
111 %incdec.ptr.i.i.i = getelementptr inbounds i8, ptr %1, i32 1
112 %lsr.iv.next = add i32 %lsr.iv, 1
113 %cmp.i16.i.i = icmp eq i32 %lsr.iv.next, 0
114 br i1 %cmp.i16.i.i, label %invoke.cont, label %do.body.i.i.i
116 invoke.cont: ; preds = %_ZNSt3__116allocator_traitsINS_9allocatorIcEEE9constructIccEEvRS2_PT_RKT0_.exit.i.i.i
117 invoke void @_Z4foo2Pci(ptr %call.i.i.i14.i.i, i32 1024)
118 to label %invoke.cont5 unwind label %lpad2
120 invoke.cont5: ; preds = %invoke.cont
121 %cmp.i.i.i15 = icmp eq ptr %call.i.i.i14.i.i, null
122 br i1 %cmp.i.i.i15, label %invoke.cont6, label %_ZNSt3__113__vector_baseIcNS_9allocatorIcEEE5clearEv.exit.i.i.i19
124 _ZNSt3__113__vector_baseIcNS_9allocatorIcEEE5clearEv.exit.i.i.i19: ; preds = %invoke.cont5
125 call void @_ZdlPv(ptr %call.i.i.i14.i.i)
126 br label %invoke.cont6
128 invoke.cont6: ; preds = %_ZNSt3__113__vector_baseIcNS_9allocatorIcEEE5clearEv.exit.i.i.i19, %invoke.cont5
129 %call10 = call ptr @_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev(ptr %s1)
132 lpad.body: ; preds = %entry
133 %2 = landingpad { ptr, i32 }
135 %3 = extractvalue { ptr, i32 } %2, 0
136 %4 = extractvalue { ptr, i32 } %2, 1
139 lpad2: ; preds = %invoke.cont
140 %5 = landingpad { ptr, i32 }
142 %6 = extractvalue { ptr, i32 } %5, 0
143 %7 = extractvalue { ptr, i32 } %5, 1
144 %cmp.i.i.i21 = icmp eq ptr %call.i.i.i14.i.i, null
145 br i1 %cmp.i.i.i21, label %ehcleanup, label %_ZNSt3__113__vector_baseIcNS_9allocatorIcEEE5clearEv.exit.i.i.i26
147 _ZNSt3__113__vector_baseIcNS_9allocatorIcEEE5clearEv.exit.i.i.i26: ; preds = %lpad2
148 call void @_ZdlPv(ptr %call.i.i.i14.i.i)
151 ehcleanup: ; preds = %_ZNSt3__113__vector_baseIcNS_9allocatorIcEEE5clearEv.exit.i.i.i26, %lpad2, %lpad.body
152 %exn.slot.0 = phi ptr [ %3, %lpad.body ], [ %6, %lpad2 ], [ %6, %_ZNSt3__113__vector_baseIcNS_9allocatorIcEEE5clearEv.exit.i.i.i26 ]
153 %ehselector.slot.0 = phi i32 [ %4, %lpad.body ], [ %7, %lpad2 ], [ %7, %_ZNSt3__113__vector_baseIcNS_9allocatorIcEEE5clearEv.exit.i.i.i26 ]
154 %call12 = invoke ptr @_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev(ptr %s1)
155 to label %eh.resume unwind label %terminate.lpad
157 eh.resume: ; preds = %ehcleanup
158 %lpad.val = insertvalue { ptr, i32 } undef, ptr %exn.slot.0, 0
159 %lpad.val13 = insertvalue { ptr, i32 } %lpad.val, i32 %ehselector.slot.0, 1
160 resume { ptr, i32 } %lpad.val13
162 terminate.lpad: ; preds = %ehcleanup
163 %8 = landingpad { ptr, i32 }
165 %9 = extractvalue { ptr, i32 } %8, 0
166 call void @__clang_call_terminate(ptr %9)
170 declare void @_Z4foo2Pci(ptr, i32)
172 define linkonce_odr hidden void @__clang_call_terminate(ptr) {
173 %2 = tail call ptr @__cxa_begin_catch(ptr %0)
174 tail call void @_ZSt9terminatev()
178 declare ptr @__cxa_begin_catch(ptr)
179 declare void @_ZSt9terminatev()
180 declare ptr @_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev(ptr returned)
181 declare void @_ZdlPv(ptr) #3
182 declare noalias ptr @_Znwm(i32)
183 declare void @_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm(ptr, ptr, i32)
184 declare void @_Unwind_SjLj_Register(ptr)
185 declare void @_Unwind_SjLj_Unregister(ptr)
186 declare ptr @llvm.frameaddress(i32)
187 declare ptr @llvm.stacksave()
188 declare void @llvm.stackrestore(ptr)
189 declare i32 @llvm.eh.sjlj.setjmp(ptr)
190 declare ptr @llvm.eh.sjlj.lsda()
191 declare void @llvm.eh.sjlj.callsite(i32)
192 declare void @llvm.eh.sjlj.functioncontext(ptr)