1be2ea29eSFlorian Hahn; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2cee313d2SEric Christopher; RUN: opt < %s -loop-reduce -S | FileCheck %s 3cee313d2SEric Christopher 4cee313d2SEric Christophertarget datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" 5cee313d2SEric Christophertarget triple = "i686-pc-windows-msvc" 6cee313d2SEric Christopher 7cee313d2SEric Christopherdeclare i32 @_except_handler3(...) 8cee313d2SEric Christopherdeclare i32 @__CxxFrameHandler3(...) 9cee313d2SEric Christopher 10cee313d2SEric Christopherdeclare void @external(i32*) 11cee313d2SEric Christopherdeclare void @reserve() 12cee313d2SEric Christopher 13cee313d2SEric Christopherdefine void @f() personality i32 (...)* @_except_handler3 { 14be2ea29eSFlorian Hahn; CHECK-LABEL: @f( 15be2ea29eSFlorian Hahn; CHECK-NEXT: entry: 16be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[THROW:%.*]] 17be2ea29eSFlorian Hahn; CHECK: throw: 18*f3c5289eSMartin Storsjö; CHECK-NEXT: [[TMP96:%.*]] = getelementptr inbounds i8, i8* undef, i32 1 19be2ea29eSFlorian Hahn; CHECK-NEXT: invoke void @reserve() 20be2ea29eSFlorian Hahn; CHECK-NEXT: to label [[THROW]] unwind label [[PAD:%.*]] 21be2ea29eSFlorian Hahn; CHECK: pad: 22*f3c5289eSMartin Storsjö; CHECK-NEXT: [[PHI2:%.*]] = phi i8* [ [[TMP96]], [[THROW]] ] 23be2ea29eSFlorian Hahn; CHECK-NEXT: [[CS:%.*]] = catchswitch within none [label %unreachable] unwind label [[BLAH2:%.*]] 24be2ea29eSFlorian Hahn; CHECK: unreachable: 25be2ea29eSFlorian Hahn; CHECK-NEXT: [[TMP0:%.*]] = catchpad within [[CS]] [] 26be2ea29eSFlorian Hahn; CHECK-NEXT: unreachable 27be2ea29eSFlorian Hahn; CHECK: blah2: 28be2ea29eSFlorian Hahn; CHECK-NEXT: [[CLEANUPPADI4_I_I_I:%.*]] = cleanuppad within none [] 29*f3c5289eSMartin Storsjö; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[PHI2]], i32 -1 30be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[LOOP_BODY:%.*]] 31be2ea29eSFlorian Hahn; CHECK: loop_body: 32*f3c5289eSMartin Storsjö; CHECK-NEXT: [[LSR_IV:%.*]] = phi i8* [ [[SCEVGEP1:%.*]], [[ITER:%.*]] ], [ [[SCEVGEP]], [[BLAH2]] ] 33*f3c5289eSMartin Storsjö; CHECK-NEXT: [[SCEVGEP1]] = getelementptr i8, i8* [[LSR_IV]], i32 1 34*f3c5289eSMartin Storsjö; CHECK-NEXT: [[TMP100:%.*]] = icmp eq i8* [[SCEVGEP1]], undef 35be2ea29eSFlorian Hahn; CHECK-NEXT: br i1 [[TMP100]], label [[UNWIND_OUT:%.*]], label [[ITER]] 36be2ea29eSFlorian Hahn; CHECK: iter: 37be2ea29eSFlorian Hahn; CHECK-NEXT: br i1 true, label [[UNWIND_OUT]], label [[LOOP_BODY]] 38be2ea29eSFlorian Hahn; CHECK: unwind_out: 39be2ea29eSFlorian Hahn; CHECK-NEXT: cleanupret from [[CLEANUPPADI4_I_I_I]] unwind to caller 40be2ea29eSFlorian Hahn; 41cee313d2SEric Christopherentry: 42cee313d2SEric Christopher br label %throw 43cee313d2SEric Christopher 44cee313d2SEric Christopherthrow: ; preds = %throw, %entry 45cee313d2SEric Christopher %tmp96 = getelementptr inbounds i8, i8* undef, i32 1 46cee313d2SEric Christopher invoke void @reserve() 47cee313d2SEric Christopher to label %throw unwind label %pad 48cee313d2SEric Christopher 49cee313d2SEric Christopherpad: ; preds = %throw 50cee313d2SEric Christopher %phi2 = phi i8* [ %tmp96, %throw ] 51cee313d2SEric Christopher %cs = catchswitch within none [label %unreachable] unwind label %blah2 52cee313d2SEric Christopher 53cee313d2SEric Christopherunreachable: 54cee313d2SEric Christopher catchpad within %cs [] 55cee313d2SEric Christopher unreachable 56cee313d2SEric Christopher 57cee313d2SEric Christopherblah2: 58cee313d2SEric Christopher %cleanuppadi4.i.i.i = cleanuppad within none [] 59cee313d2SEric Christopher br label %loop_body 60cee313d2SEric Christopher 61cee313d2SEric Christopherloop_body: ; preds = %iter, %pad 62cee313d2SEric Christopher %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah2 ] 63cee313d2SEric Christopher %tmp100 = icmp eq i8* %tmp99, undef 64cee313d2SEric Christopher br i1 %tmp100, label %unwind_out, label %iter 65cee313d2SEric Christopher 66cee313d2SEric Christopheriter: ; preds = %loop_body 67cee313d2SEric Christopher %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1 68cee313d2SEric Christopher br i1 undef, label %unwind_out, label %loop_body 69cee313d2SEric Christopher 70cee313d2SEric Christopherunwind_out: ; preds = %iter, %loop_body 71cee313d2SEric Christopher cleanupret from %cleanuppadi4.i.i.i unwind to caller 72cee313d2SEric Christopher} 73cee313d2SEric Christopher 74cee313d2SEric Christopherdefine void @g() personality i32 (...)* @_except_handler3 { 75be2ea29eSFlorian Hahn; CHECK-LABEL: @g( 76be2ea29eSFlorian Hahn; CHECK-NEXT: entry: 77be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[THROW:%.*]] 78be2ea29eSFlorian Hahn; CHECK: throw: 79*f3c5289eSMartin Storsjö; CHECK-NEXT: [[TMP96:%.*]] = getelementptr inbounds i8, i8* undef, i32 1 80be2ea29eSFlorian Hahn; CHECK-NEXT: invoke void @reserve() 81be2ea29eSFlorian Hahn; CHECK-NEXT: to label [[THROW]] unwind label [[PAD:%.*]] 82be2ea29eSFlorian Hahn; CHECK: pad: 83*f3c5289eSMartin Storsjö; CHECK-NEXT: [[PHI2:%.*]] = phi i8* [ [[TMP96]], [[THROW]] ] 84be2ea29eSFlorian Hahn; CHECK-NEXT: [[CS:%.*]] = catchswitch within none [label [[UNREACHABLE:%.*]], label %blah] unwind to caller 85be2ea29eSFlorian Hahn; CHECK: unreachable: 86be2ea29eSFlorian Hahn; CHECK-NEXT: [[TMP0:%.*]] = catchpad within [[CS]] [] 87be2ea29eSFlorian Hahn; CHECK-NEXT: unreachable 88be2ea29eSFlorian Hahn; CHECK: blah: 89be2ea29eSFlorian Hahn; CHECK-NEXT: [[CATCHPAD:%.*]] = catchpad within [[CS]] [] 90*f3c5289eSMartin Storsjö; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[PHI2]], i32 -1 91be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[LOOP_BODY:%.*]] 92be2ea29eSFlorian Hahn; CHECK: unwind_out: 93be2ea29eSFlorian Hahn; CHECK-NEXT: catchret from [[CATCHPAD]] to label [[LEAVE:%.*]] 94be2ea29eSFlorian Hahn; CHECK: leave: 95be2ea29eSFlorian Hahn; CHECK-NEXT: ret void 96be2ea29eSFlorian Hahn; CHECK: loop_body: 97*f3c5289eSMartin Storsjö; CHECK-NEXT: [[LSR_IV:%.*]] = phi i8* [ [[SCEVGEP1:%.*]], [[ITER:%.*]] ], [ [[SCEVGEP]], [[BLAH:%.*]] ] 98*f3c5289eSMartin Storsjö; CHECK-NEXT: [[SCEVGEP1]] = getelementptr i8, i8* [[LSR_IV]], i32 1 99*f3c5289eSMartin Storsjö; CHECK-NEXT: [[TMP100:%.*]] = icmp eq i8* [[SCEVGEP1]], undef 100be2ea29eSFlorian Hahn; CHECK-NEXT: br i1 [[TMP100]], label [[UNWIND_OUT:%.*]], label [[ITER]] 101be2ea29eSFlorian Hahn; CHECK: iter: 102be2ea29eSFlorian Hahn; CHECK-NEXT: br i1 true, label [[UNWIND_OUT]], label [[LOOP_BODY]] 103be2ea29eSFlorian Hahn; 104cee313d2SEric Christopherentry: 105cee313d2SEric Christopher br label %throw 106cee313d2SEric Christopher 107cee313d2SEric Christopherthrow: ; preds = %throw, %entry 108cee313d2SEric Christopher %tmp96 = getelementptr inbounds i8, i8* undef, i32 1 109cee313d2SEric Christopher invoke void @reserve() 110cee313d2SEric Christopher to label %throw unwind label %pad 111cee313d2SEric Christopher 112cee313d2SEric Christopherpad: 113cee313d2SEric Christopher %phi2 = phi i8* [ %tmp96, %throw ] 114cee313d2SEric Christopher %cs = catchswitch within none [label %unreachable, label %blah] unwind to caller 115cee313d2SEric Christopher 116cee313d2SEric Christopherunreachable: 117cee313d2SEric Christopher catchpad within %cs [] 118cee313d2SEric Christopher unreachable 119cee313d2SEric Christopher 120cee313d2SEric Christopherblah: 121cee313d2SEric Christopher %catchpad = catchpad within %cs [] 122cee313d2SEric Christopher br label %loop_body 123cee313d2SEric Christopher 124cee313d2SEric Christopherunwind_out: 125cee313d2SEric Christopher catchret from %catchpad to label %leave 126cee313d2SEric Christopher 127cee313d2SEric Christopherleave: 128cee313d2SEric Christopher ret void 129cee313d2SEric Christopher 130cee313d2SEric Christopherloop_body: ; preds = %iter, %pad 131cee313d2SEric Christopher %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah ] 132cee313d2SEric Christopher %tmp100 = icmp eq i8* %tmp99, undef 133cee313d2SEric Christopher br i1 %tmp100, label %unwind_out, label %iter 134cee313d2SEric Christopher 135cee313d2SEric Christopheriter: ; preds = %loop_body 136cee313d2SEric Christopher %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1 137cee313d2SEric Christopher br i1 undef, label %unwind_out, label %loop_body 138cee313d2SEric Christopher} 139cee313d2SEric Christopher 140cee313d2SEric Christopherdefine void @h() personality i32 (...)* @_except_handler3 { 141be2ea29eSFlorian Hahn; CHECK-LABEL: @h( 142be2ea29eSFlorian Hahn; CHECK-NEXT: entry: 143be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[THROW:%.*]] 144be2ea29eSFlorian Hahn; CHECK: throw: 145*f3c5289eSMartin Storsjö; CHECK-NEXT: [[TMP96:%.*]] = getelementptr inbounds i8, i8* undef, i32 1 146be2ea29eSFlorian Hahn; CHECK-NEXT: invoke void @reserve() 147be2ea29eSFlorian Hahn; CHECK-NEXT: to label [[THROW]] unwind label [[PAD:%.*]] 148be2ea29eSFlorian Hahn; CHECK: pad: 149be2ea29eSFlorian Hahn; CHECK-NEXT: [[CS:%.*]] = catchswitch within none [label [[UNREACHABLE:%.*]], label %blug] unwind to caller 150be2ea29eSFlorian Hahn; CHECK: unreachable: 151be2ea29eSFlorian Hahn; CHECK-NEXT: [[TMP0:%.*]] = catchpad within [[CS]] [] 152be2ea29eSFlorian Hahn; CHECK-NEXT: unreachable 153be2ea29eSFlorian Hahn; CHECK: blug: 154*f3c5289eSMartin Storsjö; CHECK-NEXT: [[PHI2:%.*]] = phi i8* [ [[TMP96]], [[PAD]] ] 155be2ea29eSFlorian Hahn; CHECK-NEXT: [[CATCHPAD:%.*]] = catchpad within [[CS]] [] 156*f3c5289eSMartin Storsjö; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[PHI2]], i32 -1 157be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[LOOP_BODY:%.*]] 158be2ea29eSFlorian Hahn; CHECK: unwind_out: 159be2ea29eSFlorian Hahn; CHECK-NEXT: catchret from [[CATCHPAD]] to label [[LEAVE:%.*]] 160be2ea29eSFlorian Hahn; CHECK: leave: 161be2ea29eSFlorian Hahn; CHECK-NEXT: ret void 162be2ea29eSFlorian Hahn; CHECK: loop_body: 163*f3c5289eSMartin Storsjö; CHECK-NEXT: [[LSR_IV:%.*]] = phi i8* [ [[SCEVGEP1:%.*]], [[ITER:%.*]] ], [ [[SCEVGEP]], [[BLUG:%.*]] ] 164*f3c5289eSMartin Storsjö; CHECK-NEXT: [[SCEVGEP1]] = getelementptr i8, i8* [[LSR_IV]], i32 1 165*f3c5289eSMartin Storsjö; CHECK-NEXT: [[TMP100:%.*]] = icmp eq i8* [[SCEVGEP1]], undef 166be2ea29eSFlorian Hahn; CHECK-NEXT: br i1 [[TMP100]], label [[UNWIND_OUT:%.*]], label [[ITER]] 167be2ea29eSFlorian Hahn; CHECK: iter: 168be2ea29eSFlorian Hahn; CHECK-NEXT: br i1 true, label [[UNWIND_OUT]], label [[LOOP_BODY]] 169be2ea29eSFlorian Hahn; 170cee313d2SEric Christopherentry: 171cee313d2SEric Christopher br label %throw 172cee313d2SEric Christopher 173cee313d2SEric Christopherthrow: ; preds = %throw, %entry 174cee313d2SEric Christopher %tmp96 = getelementptr inbounds i8, i8* undef, i32 1 175cee313d2SEric Christopher invoke void @reserve() 176cee313d2SEric Christopher to label %throw unwind label %pad 177cee313d2SEric Christopher 178cee313d2SEric Christopherpad: 179cee313d2SEric Christopher %cs = catchswitch within none [label %unreachable, label %blug] unwind to caller 180cee313d2SEric Christopher 181cee313d2SEric Christopherunreachable: 182cee313d2SEric Christopher catchpad within %cs [] 183cee313d2SEric Christopher unreachable 184cee313d2SEric Christopher 185cee313d2SEric Christopherblug: 186cee313d2SEric Christopher %phi2 = phi i8* [ %tmp96, %pad ] 187cee313d2SEric Christopher %catchpad = catchpad within %cs [] 188cee313d2SEric Christopher br label %loop_body 189cee313d2SEric Christopher 190cee313d2SEric Christopherunwind_out: 191cee313d2SEric Christopher catchret from %catchpad to label %leave 192cee313d2SEric Christopher 193cee313d2SEric Christopherleave: 194cee313d2SEric Christopher ret void 195cee313d2SEric Christopher 196cee313d2SEric Christopherloop_body: ; preds = %iter, %pad 197cee313d2SEric Christopher %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blug ] 198cee313d2SEric Christopher %tmp100 = icmp eq i8* %tmp99, undef 199cee313d2SEric Christopher br i1 %tmp100, label %unwind_out, label %iter 200cee313d2SEric Christopher 201cee313d2SEric Christopheriter: ; preds = %loop_body 202cee313d2SEric Christopher %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1 203cee313d2SEric Christopher br i1 undef, label %unwind_out, label %loop_body 204cee313d2SEric Christopher} 205cee313d2SEric Christopher 206cee313d2SEric Christopherdefine void @i() personality i32 (...)* @_except_handler3 { 207be2ea29eSFlorian Hahn; CHECK-LABEL: @i( 208be2ea29eSFlorian Hahn; CHECK-NEXT: entry: 209be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[THROW:%.*]] 210be2ea29eSFlorian Hahn; CHECK: throw: 211*f3c5289eSMartin Storsjö; CHECK-NEXT: [[TMP96:%.*]] = getelementptr inbounds i8, i8* undef, i32 1 212be2ea29eSFlorian Hahn; CHECK-NEXT: invoke void @reserve() 213be2ea29eSFlorian Hahn; CHECK-NEXT: to label [[THROW]] unwind label [[CATCHPAD:%.*]] 214be2ea29eSFlorian Hahn; CHECK: catchpad: 215*f3c5289eSMartin Storsjö; CHECK-NEXT: [[PHI2:%.*]] = phi i8* [ [[TMP96]], [[THROW]] ] 216be2ea29eSFlorian Hahn; CHECK-NEXT: [[CS:%.*]] = catchswitch within none [label %cp_body] unwind label [[CLEANUPPAD:%.*]] 217be2ea29eSFlorian Hahn; CHECK: cp_body: 218be2ea29eSFlorian Hahn; CHECK-NEXT: [[TMP0:%.*]] = catchpad within [[CS]] [] 219be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[LOOP_HEAD:%.*]] 220be2ea29eSFlorian Hahn; CHECK: cleanuppad: 221be2ea29eSFlorian Hahn; CHECK-NEXT: [[TMP1:%.*]] = cleanuppad within none [] 222be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[LOOP_HEAD]] 223be2ea29eSFlorian Hahn; CHECK: loop_head: 224*f3c5289eSMartin Storsjö; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[PHI2]], i32 -1 225be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[LOOP_BODY:%.*]] 226be2ea29eSFlorian Hahn; CHECK: loop_body: 227*f3c5289eSMartin Storsjö; CHECK-NEXT: [[LSR_IV:%.*]] = phi i8* [ [[SCEVGEP1:%.*]], [[ITER:%.*]] ], [ [[SCEVGEP]], [[LOOP_HEAD]] ] 228*f3c5289eSMartin Storsjö; CHECK-NEXT: [[SCEVGEP1]] = getelementptr i8, i8* [[LSR_IV]], i32 1 229*f3c5289eSMartin Storsjö; CHECK-NEXT: [[TMP100:%.*]] = icmp eq i8* [[SCEVGEP1]], undef 230be2ea29eSFlorian Hahn; CHECK-NEXT: br i1 [[TMP100]], label [[UNWIND_OUT:%.*]], label [[ITER]] 231be2ea29eSFlorian Hahn; CHECK: iter: 232be2ea29eSFlorian Hahn; CHECK-NEXT: br i1 true, label [[UNWIND_OUT]], label [[LOOP_BODY]] 233be2ea29eSFlorian Hahn; CHECK: unwind_out: 234be2ea29eSFlorian Hahn; CHECK-NEXT: unreachable 235be2ea29eSFlorian Hahn; 236cee313d2SEric Christopherentry: 237cee313d2SEric Christopher br label %throw 238cee313d2SEric Christopher 239cee313d2SEric Christopherthrow: ; preds = %throw, %entry 240cee313d2SEric Christopher %tmp96 = getelementptr inbounds i8, i8* undef, i32 1 241cee313d2SEric Christopher invoke void @reserve() 242cee313d2SEric Christopher to label %throw unwind label %catchpad 243cee313d2SEric Christopher 244cee313d2SEric Christophercatchpad: ; preds = %throw 245cee313d2SEric Christopher %phi2 = phi i8* [ %tmp96, %throw ] 246cee313d2SEric Christopher %cs = catchswitch within none [label %cp_body] unwind label %cleanuppad 247cee313d2SEric Christopher 248cee313d2SEric Christophercp_body: 249cee313d2SEric Christopher catchpad within %cs [] 250cee313d2SEric Christopher br label %loop_head 251cee313d2SEric Christopher 252cee313d2SEric Christophercleanuppad: 253cee313d2SEric Christopher cleanuppad within none [] 254cee313d2SEric Christopher br label %loop_head 255cee313d2SEric Christopher 256cee313d2SEric Christopherloop_head: 257cee313d2SEric Christopher br label %loop_body 258cee313d2SEric Christopher 259cee313d2SEric Christopherloop_body: ; preds = %iter, %catchpad 260cee313d2SEric Christopher %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %loop_head ] 261cee313d2SEric Christopher %tmp100 = icmp eq i8* %tmp99, undef 262cee313d2SEric Christopher br i1 %tmp100, label %unwind_out, label %iter 263cee313d2SEric Christopher 264cee313d2SEric Christopheriter: ; preds = %loop_body 265cee313d2SEric Christopher %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1 266cee313d2SEric Christopher br i1 undef, label %unwind_out, label %loop_body 267cee313d2SEric Christopher 268cee313d2SEric Christopherunwind_out: ; preds = %iter, %loop_body 269cee313d2SEric Christopher unreachable 270cee313d2SEric Christopher} 271cee313d2SEric Christopher 272cee313d2SEric Christopherdefine void @test1(i32* %b, i32* %c) personality i32 (...)* @__CxxFrameHandler3 { 273be2ea29eSFlorian Hahn; CHECK-LABEL: @test1( 274be2ea29eSFlorian Hahn; CHECK-NEXT: entry: 275be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[FOR_COND:%.*]] 276be2ea29eSFlorian Hahn; CHECK: for.cond: 277be2ea29eSFlorian Hahn; CHECK-NEXT: [[D_0:%.*]] = phi i32* [ [[B:%.*]], [[ENTRY:%.*]] ], [ [[INCDEC_PTR:%.*]], [[FOR_INC:%.*]] ] 278be2ea29eSFlorian Hahn; CHECK-NEXT: invoke void @external(i32* [[D_0]]) 279be2ea29eSFlorian Hahn; CHECK-NEXT: to label [[FOR_INC]] unwind label [[CATCH_DISPATCH:%.*]] 280be2ea29eSFlorian Hahn; CHECK: for.inc: 281be2ea29eSFlorian Hahn; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds i32, i32* [[D_0]], i32 1 282be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[FOR_COND]] 283be2ea29eSFlorian Hahn; CHECK: catch.dispatch: 284be2ea29eSFlorian Hahn; CHECK-NEXT: [[CS:%.*]] = catchswitch within none [label %catch] unwind label [[CATCH_DISPATCH_2:%.*]] 285be2ea29eSFlorian Hahn; CHECK: catch: 286be2ea29eSFlorian Hahn; CHECK-NEXT: [[TMP0:%.*]] = catchpad within [[CS]] [i8* null, i32 64, i8* null] 287be2ea29eSFlorian Hahn; CHECK-NEXT: catchret from [[TMP0]] to label [[TRY_CONT:%.*]] 288be2ea29eSFlorian Hahn; CHECK: try.cont: 289be2ea29eSFlorian Hahn; CHECK-NEXT: invoke void @external(i32* [[C:%.*]]) 290be2ea29eSFlorian Hahn; CHECK-NEXT: to label [[TRY_CONT_7:%.*]] unwind label [[CATCH_DISPATCH_2]] 291be2ea29eSFlorian Hahn; CHECK: catch.dispatch.2: 292be2ea29eSFlorian Hahn; CHECK-NEXT: [[E_0:%.*]] = phi i32* [ [[C]], [[TRY_CONT]] ], [ [[B]], [[CATCH_DISPATCH]] ] 293be2ea29eSFlorian Hahn; CHECK-NEXT: [[CS2:%.*]] = catchswitch within none [label %catch.4] unwind to caller 294be2ea29eSFlorian Hahn; CHECK: catch.4: 295be2ea29eSFlorian Hahn; CHECK-NEXT: [[TMP1:%.*]] = catchpad within [[CS2]] [i8* null, i32 64, i8* null] 296be2ea29eSFlorian Hahn; CHECK-NEXT: unreachable 297be2ea29eSFlorian Hahn; CHECK: try.cont.7: 298be2ea29eSFlorian Hahn; CHECK-NEXT: ret void 299be2ea29eSFlorian Hahn; 300cee313d2SEric Christopherentry: 301cee313d2SEric Christopher br label %for.cond 302cee313d2SEric Christopher 303cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 304cee313d2SEric Christopher %d.0 = phi i32* [ %b, %entry ], [ %incdec.ptr, %for.inc ] 305cee313d2SEric Christopher invoke void @external(i32* %d.0) 306cee313d2SEric Christopher to label %for.inc unwind label %catch.dispatch 307cee313d2SEric Christopher 308cee313d2SEric Christopherfor.inc: ; preds = %for.cond 309cee313d2SEric Christopher %incdec.ptr = getelementptr inbounds i32, i32* %d.0, i32 1 310cee313d2SEric Christopher br label %for.cond 311cee313d2SEric Christopher 312cee313d2SEric Christophercatch.dispatch: ; preds = %for.cond 313cee313d2SEric Christopher %cs = catchswitch within none [label %catch] unwind label %catch.dispatch.2 314cee313d2SEric Christopher 315cee313d2SEric Christophercatch: ; preds = %catch.dispatch 316cee313d2SEric Christopher %0 = catchpad within %cs [i8* null, i32 64, i8* null] 317cee313d2SEric Christopher catchret from %0 to label %try.cont 318cee313d2SEric Christopher 319cee313d2SEric Christophertry.cont: ; preds = %catch 320cee313d2SEric Christopher invoke void @external(i32* %c) 321cee313d2SEric Christopher to label %try.cont.7 unwind label %catch.dispatch.2 322cee313d2SEric Christopher 323cee313d2SEric Christophercatch.dispatch.2: ; preds = %try.cont, %catchendblock 324cee313d2SEric Christopher %e.0 = phi i32* [ %c, %try.cont ], [ %b, %catch.dispatch ] 325cee313d2SEric Christopher %cs2 = catchswitch within none [label %catch.4] unwind to caller 326cee313d2SEric Christopher 327cee313d2SEric Christophercatch.4: ; preds = %catch.dispatch.2 328cee313d2SEric Christopher catchpad within %cs2 [i8* null, i32 64, i8* null] 329cee313d2SEric Christopher unreachable 330cee313d2SEric Christopher 331cee313d2SEric Christophertry.cont.7: ; preds = %try.cont 332cee313d2SEric Christopher ret void 333cee313d2SEric Christopher} 334cee313d2SEric Christopher 335cee313d2SEric Christopherdefine i32 @test2() personality i32 (...)* @_except_handler3 { 336be2ea29eSFlorian Hahn; CHECK-LABEL: @test2( 337be2ea29eSFlorian Hahn; CHECK-NEXT: entry: 338be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[FOR_BODY:%.*]] 339be2ea29eSFlorian Hahn; CHECK: for.body: 340be2ea29eSFlorian Hahn; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_INC:%.*]] ], [ 0, [[ENTRY:%.*]] ] 341be2ea29eSFlorian Hahn; CHECK-NEXT: invoke void @reserve() 342be2ea29eSFlorian Hahn; CHECK-NEXT: to label [[FOR_INC]] unwind label [[CATCH_DISPATCH:%.*]] 343be2ea29eSFlorian Hahn; CHECK: catch.dispatch: 344be2ea29eSFlorian Hahn; CHECK-NEXT: [[TMP18:%.*]] = catchswitch within none [label %catch.handler] unwind to caller 345be2ea29eSFlorian Hahn; CHECK: catch.handler: 346be2ea29eSFlorian Hahn; CHECK-NEXT: [[PHI_LCSSA:%.*]] = phi i32 [ [[PHI]], [[CATCH_DISPATCH]] ] 347be2ea29eSFlorian Hahn; CHECK-NEXT: [[TMP19:%.*]] = catchpad within [[TMP18]] [i8* null] 348be2ea29eSFlorian Hahn; CHECK-NEXT: catchret from [[TMP19]] to label [[DONE:%.*]] 349be2ea29eSFlorian Hahn; CHECK: done: 350be2ea29eSFlorian Hahn; CHECK-NEXT: ret i32 [[PHI_LCSSA]] 351be2ea29eSFlorian Hahn; CHECK: for.inc: 352be2ea29eSFlorian Hahn; CHECK-NEXT: [[INC]] = add i32 [[PHI]], 1 353be2ea29eSFlorian Hahn; CHECK-NEXT: br label [[FOR_BODY]] 354be2ea29eSFlorian Hahn; 355cee313d2SEric Christopherentry: 356cee313d2SEric Christopher br label %for.body 357cee313d2SEric Christopher 358cee313d2SEric Christopherfor.body: ; preds = %for.inc, %entry 359cee313d2SEric Christopher %phi = phi i32 [ %inc, %for.inc ], [ 0, %entry ] 360cee313d2SEric Christopher invoke void @reserve() 361cee313d2SEric Christopher to label %for.inc unwind label %catch.dispatch 362cee313d2SEric Christopher 363cee313d2SEric Christophercatch.dispatch: ; preds = %for.body 364cee313d2SEric Christopher %tmp18 = catchswitch within none [label %catch.handler] unwind to caller 365cee313d2SEric Christopher 366cee313d2SEric Christophercatch.handler: ; preds = %catch.dispatch 367cee313d2SEric Christopher %phi.lcssa = phi i32 [ %phi, %catch.dispatch ] 368cee313d2SEric Christopher %tmp19 = catchpad within %tmp18 [i8* null] 369cee313d2SEric Christopher catchret from %tmp19 to label %done 370cee313d2SEric Christopher 371cee313d2SEric Christopherdone: 372cee313d2SEric Christopher ret i32 %phi.lcssa 373cee313d2SEric Christopher 374cee313d2SEric Christopherfor.inc: ; preds = %for.body 375cee313d2SEric Christopher %inc = add i32 %phi, 1 376cee313d2SEric Christopher br label %for.body 377cee313d2SEric Christopher} 378