1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple i386-windows-gnu -exception-model sjlj -filetype asm -o - %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workerdeclare void @_Z20function_that_throwsv() 4*9880d681SAndroid Build Coastguard Workerdeclare i32 @__gxx_personality_sj0(...) 5*9880d681SAndroid Build Coastguard Workerdeclare i8* @__cxa_begin_catch(i8*) 6*9880d681SAndroid Build Coastguard Workerdeclare void @__cxa_end_catch() 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Workerdefine void @_Z8functionv() personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*) { 9*9880d681SAndroid Build Coastguard Workerentry: 10*9880d681SAndroid Build Coastguard Worker invoke void @_Z20function_that_throwsv() 11*9880d681SAndroid Build Coastguard Worker to label %try.cont unwind label %lpad 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard Workerlpad: 14*9880d681SAndroid Build Coastguard Worker %0 = landingpad { i8*, i32 } 15*9880d681SAndroid Build Coastguard Worker catch i8* null 16*9880d681SAndroid Build Coastguard Worker %1 = extractvalue { i8*, i32 } %0, 0 17*9880d681SAndroid Build Coastguard Worker %2 = tail call i8* @__cxa_begin_catch(i8* %1) 18*9880d681SAndroid Build Coastguard Worker tail call void @__cxa_end_catch() 19*9880d681SAndroid Build Coastguard Worker br label %try.cont 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workertry.cont: 22*9880d681SAndroid Build Coastguard Worker ret void 23*9880d681SAndroid Build Coastguard Worker} 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker; struct _Unwind_FunctionContext { 26*9880d681SAndroid Build Coastguard Worker; +00 struct _Unwind_FunctionContext *prev; -64(%ebp) 27*9880d681SAndroid Build Coastguard Worker; +04 uintptr_t __callsite; -60(%ebp) 28*9880d681SAndroid Build Coastguard Worker; +08 uintptr_t __buffer[4]; -44(%ebp) 29*9880d681SAndroid Build Coastguard Worker; +28 __personality_routine __personality; -40(%ebp) 30*9880d681SAndroid Build Coastguard Worker; +32 uintptr_t __lsda; -36(%ebp) 31*9880d681SAndroid Build Coastguard Worker; +36 void *__jbuf[]; -32(%ebp) 32*9880d681SAndroid Build Coastguard Worker; }; 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: __Z8functionv: 36*9880d681SAndroid Build Coastguard Worker; struct _Unwind_FunctionContext UFC; 37*9880d681SAndroid Build Coastguard Worker; 38*9880d681SAndroid Build Coastguard Worker; UFC.__personality = __gxx_personality_sj0 39*9880d681SAndroid Build Coastguard Worker; CHECK: movl $___gxx_personality_sj0, -40(%ebp) 40*9880d681SAndroid Build Coastguard Worker; UFC.__lsda = $LSDA 41*9880d681SAndroid Build Coastguard Worker; CHECK: movl $[[LSDA:GCC_except_table[0-9]+]], -36(%ebp) 42*9880d681SAndroid Build Coastguard Worker; UFC.__jbuf[0] = $EBP 43*9880d681SAndroid Build Coastguard Worker; CHECK: movl %ebp, -32(%ebp) 44*9880d681SAndroid Build Coastguard Worker; UFC.__jbuf[2] = $ESP 45*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, -24(%ebp) 46*9880d681SAndroid Build Coastguard Worker; UFC.__jbuf[1] = $EIP 47*9880d681SAndroid Build Coastguard Worker; CHECK: movl $[[RESUME:LBB[0-9]+_[0-9]+]], -28(%ebp) 48*9880d681SAndroid Build Coastguard Worker; UFC.__callsite = 1 49*9880d681SAndroid Build Coastguard Worker; CHECK: movl $1, -60(%ebp) 50*9880d681SAndroid Build Coastguard Worker; _Unwind_SjLj_Register(&UFC); 51*9880d681SAndroid Build Coastguard Worker; CHECK: leal -64(%ebp), %eax 52*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %eax 53*9880d681SAndroid Build Coastguard Worker; CHECK: calll __Unwind_SjLj_Register 54*9880d681SAndroid Build Coastguard Worker; CHECK: addl $4, %esp 55*9880d681SAndroid Build Coastguard Worker; function_that_throws(); 56*9880d681SAndroid Build Coastguard Worker; CHECK: calll __Z20function_that_throwsv 57*9880d681SAndroid Build Coastguard Worker; _Unwind_SjLj_Unregister(&UFC); 58*9880d681SAndroid Build Coastguard Worker; CHECK: leal -64(%ebp), %eax 59*9880d681SAndroid Build Coastguard Worker; CHECK: calll __Unwind_SjLj_Unregister 60*9880d681SAndroid Build Coastguard Worker; 61*9880d681SAndroid Build Coastguard Worker; CHECK: [[RESUME]]: 62*9880d681SAndroid Build Coastguard Worker; CHECK: leal -64(%ebp), %esi 63*9880d681SAndroid Build Coastguard Worker; assert(UFC.__callsite <= 1); 64*9880d681SAndroid Build Coastguard Worker; CHECK: movl -60(%ebp), %eax 65*9880d681SAndroid Build Coastguard Worker; CHECK: cmpl $1, %eax 66*9880d681SAndroid Build Coastguard Worker; CHECK: jbe [[CONT:LBB[0-9]+_[0-9]+]] 67*9880d681SAndroid Build Coastguard Worker; CHECK: ud2 68*9880d681SAndroid Build Coastguard Worker; CHECK: [[CONT]]: 69*9880d681SAndroid Build Coastguard Worker; *Handlers[--UFC.__callsite] 70*9880d681SAndroid Build Coastguard Worker; CHECK: subl $1, %eax 71*9880d681SAndroid Build Coastguard Worker; CHECK: jmpl *LJTI 72*9880d681SAndroid Build Coastguard Worker 73