1*9880d681SAndroid Build Coastguard Worker; RUN: llc -verify-machineinstrs -mtriple=i686-pc-windows-msvc < %s \ 2*9880d681SAndroid Build Coastguard Worker; RUN: | FileCheck --check-prefix=CHECK --check-prefix=X86 %s 3*9880d681SAndroid Build Coastguard Worker; RUN: llc -verify-machineinstrs -mtriple=x86_64-pc-windows-msvc < %s \ 4*9880d681SAndroid Build Coastguard Worker; RUN: | FileCheck --check-prefix=CHECK --check-prefix=X64 %s 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker; Loosely based on IR for this C++ source code: 7*9880d681SAndroid Build Coastguard Worker; void f(int p); 8*9880d681SAndroid Build Coastguard Worker; void try_in_catch() { 9*9880d681SAndroid Build Coastguard Worker; try { 10*9880d681SAndroid Build Coastguard Worker; f(1); 11*9880d681SAndroid Build Coastguard Worker; } catch (...) { 12*9880d681SAndroid Build Coastguard Worker; try { 13*9880d681SAndroid Build Coastguard Worker; f(2); 14*9880d681SAndroid Build Coastguard Worker; } catch (...) { 15*9880d681SAndroid Build Coastguard Worker; f(3); 16*9880d681SAndroid Build Coastguard Worker; } 17*9880d681SAndroid Build Coastguard Worker; } 18*9880d681SAndroid Build Coastguard Worker; } 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Workerdeclare void @f(i32 %p) 21*9880d681SAndroid Build Coastguard Workerdeclare i32 @__CxxFrameHandler3(...) 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Workerdefine i32 @try_in_catch() personality i32 (...)* @__CxxFrameHandler3 { 24*9880d681SAndroid Build Coastguard Workerentry: 25*9880d681SAndroid Build Coastguard Worker invoke void @f(i32 1) 26*9880d681SAndroid Build Coastguard Worker to label %try.cont unwind label %catch.dispatch.1 27*9880d681SAndroid Build Coastguard Workertry.cont: 28*9880d681SAndroid Build Coastguard Worker ret i32 0 29*9880d681SAndroid Build Coastguard Worker 30*9880d681SAndroid Build Coastguard Workercatch.dispatch.1: 31*9880d681SAndroid Build Coastguard Worker %cs1 = catchswitch within none [label %handler1] unwind to caller 32*9880d681SAndroid Build Coastguard Workerhandler1: 33*9880d681SAndroid Build Coastguard Worker %h1 = catchpad within %cs1 [i8* null, i32 64, i8* null] 34*9880d681SAndroid Build Coastguard Worker invoke void @f(i32 2) [ "funclet"(token %h1) ] 35*9880d681SAndroid Build Coastguard Worker to label %catchret1 unwind label %catch.dispatch.2 36*9880d681SAndroid Build Coastguard Workercatchret1: 37*9880d681SAndroid Build Coastguard Worker catchret from %h1 to label %try.cont 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Workercatch.dispatch.2: 40*9880d681SAndroid Build Coastguard Worker %cs2 = catchswitch within %h1 [label %handler2] unwind to caller 41*9880d681SAndroid Build Coastguard Workerhandler2: 42*9880d681SAndroid Build Coastguard Worker %h2 = catchpad within %cs2 [i8* null, i32 64, i8* null] 43*9880d681SAndroid Build Coastguard Worker call void @f(i32 3) 44*9880d681SAndroid Build Coastguard Worker catchret from %h2 to label %catchret1 45*9880d681SAndroid Build Coastguard Worker} 46*9880d681SAndroid Build Coastguard Worker 47*9880d681SAndroid Build Coastguard Worker; X86-LABEL: L__ehtable$try_in_catch: 48*9880d681SAndroid Build Coastguard Worker; X64-LABEL: $cppxdata$try_in_catch: 49*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 429065506 50*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 4 51*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long ($stateUnwindMap$try_in_catch) 52*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 2 53*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long ($tryMap$try_in_catch) 54*9880d681SAndroid Build Coastguard Worker; ip2state num + ptr 55*9880d681SAndroid Build Coastguard Worker; X86-NEXT: .long 0 56*9880d681SAndroid Build Coastguard Worker; X86-NEXT: .long 0 57*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long 7 58*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long ($ip2state$try_in_catch) 59*9880d681SAndroid Build Coastguard Worker; unwindhelp offset 60*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long 40 61*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 62*9880d681SAndroid Build Coastguard Worker; EHFlags 63*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 1 64*9880d681SAndroid Build Coastguard Worker 65*9880d681SAndroid Build Coastguard Worker; CHECK: $tryMap$try_in_catch: 66*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 2 67*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 2 68*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 3 69*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 1 70*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long ($handlerMap$0$try_in_catch) 71*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 72*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 73*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 3 74*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 1 75*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long ($handlerMap$1$try_in_catch) 76*9880d681SAndroid Build Coastguard Worker 77*9880d681SAndroid Build Coastguard Worker; CHECK: $handlerMap$0$try_in_catch: 78*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 64 79*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 80*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 81*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long "?catch${{[0-9]+}}@?0?try_in_catch@4HA" 82*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long 56 83*9880d681SAndroid Build Coastguard Worker 84*9880d681SAndroid Build Coastguard Worker; CHECK: $handlerMap$1$try_in_catch: 85*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 64 86*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 87*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 88*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long "?catch${{[0-9]+}}@?0?try_in_catch@4HA" 89*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long 56 90*9880d681SAndroid Build Coastguard Worker 91*9880d681SAndroid Build Coastguard Worker; X64: $ip2state$try_in_catch: 92*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long .Lfunc_begin0@IMGREL 93*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long -1 94*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long .Ltmp0@IMGREL+1 95*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long 0 96*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long .Ltmp1@IMGREL+1 97*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long -1 98*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long "?catch$2@?0?try_in_catch@4HA"@IMGREL 99*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long 1 100*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long .Ltmp2@IMGREL+1 101*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long 2 102*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long .Ltmp3@IMGREL+1 103*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long 1 104*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long "?catch$4@?0?try_in_catch@4HA"@IMGREL 105*9880d681SAndroid Build Coastguard Worker; X64-NEXT: .long 3 106