1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workerdeclare i32 @__CxxFrameHandler3(...) 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Workerdeclare void @throw() 6*9880d681SAndroid Build Coastguard Workerdeclare i16 @f() 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Workerdefine i16 @test1(i16 %a, i8* %b) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) { 9*9880d681SAndroid Build Coastguard Workerentry: 10*9880d681SAndroid Build Coastguard Worker %cmp = icmp eq i16 %a, 10 11*9880d681SAndroid Build Coastguard Worker br i1 %cmp, label %if.then, label %if.else 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard Workerif.then: 14*9880d681SAndroid Build Coastguard Worker %call1 = invoke i16 @f() 15*9880d681SAndroid Build Coastguard Worker to label %cleanup unwind label %catch.dispatch 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Workerif.else: 18*9880d681SAndroid Build Coastguard Worker %call2 = invoke i16 @f() 19*9880d681SAndroid Build Coastguard Worker to label %cleanup unwind label %catch.dispatch 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workercatch.dispatch: 22*9880d681SAndroid Build Coastguard Worker %cs = catchswitch within none [ label %catch, label %catch.2 ] unwind to caller 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard Workercatch: 25*9880d681SAndroid Build Coastguard Worker catchpad within %cs [i8* null, i32 8, i8* null] 26*9880d681SAndroid Build Coastguard Worker call void @throw() noreturn 27*9880d681SAndroid Build Coastguard Worker br label %unreachable 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Workercatch.2: 30*9880d681SAndroid Build Coastguard Worker catchpad within %cs [i8* null, i32 64, i8* null] 31*9880d681SAndroid Build Coastguard Worker store i8 1, i8* %b 32*9880d681SAndroid Build Coastguard Worker call void @throw() noreturn 33*9880d681SAndroid Build Coastguard Worker br label %unreachable 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Workercleanup: 36*9880d681SAndroid Build Coastguard Worker %retval = phi i16 [ %call1, %if.then ], [ %call2, %if.else ] 37*9880d681SAndroid Build Coastguard Worker ret i16 %retval 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Workerunreachable: 40*9880d681SAndroid Build Coastguard Worker unreachable 41*9880d681SAndroid Build Coastguard Worker} 42*9880d681SAndroid Build Coastguard Worker 43*9880d681SAndroid Build Coastguard Worker; This test verifies the case where two funclet blocks meet the old criteria 44*9880d681SAndroid Build Coastguard Worker; to be placed at the end. The order of the blocks is not important for the 45*9880d681SAndroid Build Coastguard Worker; purposes of this test. The failure mode is an infinite loop during 46*9880d681SAndroid Build Coastguard Worker; compilation. 47*9880d681SAndroid Build Coastguard Worker; 48*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: .def test1; 49*9880d681SAndroid Build Coastguard Worker 50*9880d681SAndroid Build Coastguard Workerdefine i16 @test2(i16 %a, i8* %b) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) { 51*9880d681SAndroid Build Coastguard Workerentry: 52*9880d681SAndroid Build Coastguard Worker %cmp = icmp eq i16 %a, 10 53*9880d681SAndroid Build Coastguard Worker br i1 %cmp, label %if.then, label %if.else 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Workerif.then: 56*9880d681SAndroid Build Coastguard Worker %call1 = invoke i16 @f() 57*9880d681SAndroid Build Coastguard Worker to label %cleanup unwind label %catch.dispatch 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Workerif.else: 60*9880d681SAndroid Build Coastguard Worker %call2 = invoke i16 @f() 61*9880d681SAndroid Build Coastguard Worker to label %cleanup unwind label %catch.dispatch 62*9880d681SAndroid Build Coastguard Worker 63*9880d681SAndroid Build Coastguard Workercatch.dispatch: 64*9880d681SAndroid Build Coastguard Worker %cs = catchswitch within none [ label %catch, label %catch.2, label %catch.3 ] unwind to caller 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Workercatch: 67*9880d681SAndroid Build Coastguard Worker catchpad within %cs [i8* null, i32 8, i8* null] 68*9880d681SAndroid Build Coastguard Worker call void @throw() noreturn 69*9880d681SAndroid Build Coastguard Worker br label %unreachable 70*9880d681SAndroid Build Coastguard Worker 71*9880d681SAndroid Build Coastguard Workercatch.2: 72*9880d681SAndroid Build Coastguard Worker %c2 = catchpad within %cs [i8* null, i32 32, i8* null] 73*9880d681SAndroid Build Coastguard Worker store i8 1, i8* %b 74*9880d681SAndroid Build Coastguard Worker catchret from %c2 to label %cleanup 75*9880d681SAndroid Build Coastguard Worker 76*9880d681SAndroid Build Coastguard Workercatch.3: 77*9880d681SAndroid Build Coastguard Worker %c3 = catchpad within %cs [i8* null, i32 64, i8* null] 78*9880d681SAndroid Build Coastguard Worker store i8 2, i8* %b 79*9880d681SAndroid Build Coastguard Worker catchret from %c3 to label %cleanup 80*9880d681SAndroid Build Coastguard Worker 81*9880d681SAndroid Build Coastguard Workercleanup: 82*9880d681SAndroid Build Coastguard Worker %retval = phi i16 [ %call1, %if.then ], [ %call2, %if.else ], [ -1, %catch.2 ], [ -1, %catch.3 ] 83*9880d681SAndroid Build Coastguard Worker ret i16 %retval 84*9880d681SAndroid Build Coastguard Worker 85*9880d681SAndroid Build Coastguard Workerunreachable: 86*9880d681SAndroid Build Coastguard Worker unreachable 87*9880d681SAndroid Build Coastguard Worker} 88*9880d681SAndroid Build Coastguard Worker 89*9880d681SAndroid Build Coastguard Worker; This test verifies the case where three funclet blocks all meet the old 90*9880d681SAndroid Build Coastguard Worker; criteria to be placed at the end. The order of the blocks is not important 91*9880d681SAndroid Build Coastguard Worker; for the purposes of this test. The failure mode is an infinite loop during 92*9880d681SAndroid Build Coastguard Worker; compilation. 93*9880d681SAndroid Build Coastguard Worker; 94*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: .def test2; 95*9880d681SAndroid Build Coastguard Worker 96