1; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR39439. 2; RUN: llc -mtriple i386-windows-gnu -exception-model sjlj -filetype asm -o - %s -verify-machineinstrs=0 | FileCheck %s 3; RUN: llc -mtriple x86_64-windows-gnu -exception-model sjlj -filetype asm -o - %s -verify-machineinstrs=0 | FileCheck %s -check-prefix CHECK-X64 4; RUN: llc -mtriple x86_64-linux -exception-model sjlj -filetype asm -o - %s -verify-machineinstrs=0 | FileCheck %s -check-prefix CHECK-X64-LINUX 5 6declare void @_Z20function_that_throwsv() 7declare i32 @__gxx_personality_sj0(...) 8declare i8* @__cxa_begin_catch(i8*) 9declare void @__cxa_end_catch() 10 11define void @_Z8functionv() personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*) { 12entry: 13 invoke void @_Z20function_that_throwsv() 14 to label %try.cont unwind label %lpad 15 16lpad: 17 %0 = landingpad { i8*, i32 } 18 catch i8* null 19 %1 = extractvalue { i8*, i32 } %0, 0 20 %2 = tail call i8* @__cxa_begin_catch(i8* %1) 21 tail call void @__cxa_end_catch() 22 br label %try.cont 23 24try.cont: 25 ret void 26} 27 28; struct _Unwind_FunctionContext { 29; +00 struct _Unwind_FunctionContext *prev; -64(%ebp) 30; +04 uint32_t __callsite; -60(%ebp) 31; +08 uint32_t __buffer[4]; -56(%ebp) 32; +24 __personality_routine __personality; -40(%ebp) 33; +28 uintptr_t __lsda; -36(%ebp) 34; +32 void *__jbuf[]; -32(%ebp) 35; }; 36 37 38; CHECK-LABEL: __Z8functionv: 39; struct _Unwind_FunctionContext UFC; 40; 41; UFC.__personality = __gxx_personality_sj0 42; CHECK: movl $___gxx_personality_sj0, -40(%ebp) 43; UFC.__lsda = $LSDA 44; CHECK: movl $[[LSDA:GCC_except_table[0-9]+]], -36(%ebp) 45; UFC.__jbuf[0] = $ebp 46; CHECK: movl %ebp, -32(%ebp) 47; UFC.__jbuf[2] = $esp 48; CHECK: movl %esp, -24(%ebp) 49; UFC.__jbuf[1] = $EIP 50; CHECK: movl $[[RESUME:LBB[0-9]+_[0-9]+]], -28(%ebp) 51; UFC.__callsite = 1 52; CHECK: movl $1, -60(%ebp) 53; _Unwind_SjLj_Register(&UFC); 54; CHECK: leal -64(%ebp), %eax 55; CHECK: pushl %eax 56; CHECK: calll __Unwind_SjLj_Register 57; CHECK: addl $4, %esp 58; function_that_throws(); 59; CHECK: calll __Z20function_that_throwsv 60; _Unwind_SjLj_Unregister(&UFC); 61; CHECK: leal -64(%ebp), %eax 62; CHECK: calll __Unwind_SjLj_Unregister 63; 64; CHECK: [[RESUME]]: 65; CHECK: leal -64(%ebp), %esi 66; assert(UFC.__callsite < 1); 67; CHECK: movl -60(%ebp), %eax 68; CHECK: cmpl $1, %eax 69; CHECK: jb [[CONT:LBB[0-9]+_[0-9]+]] 70; CHECK: ud2 71; CHECK: [[CONT]]: 72; *Handlers[UFC.__callsite] 73; CHECK: jmpl *LJTI 74 75 76; struct _Unwind_FunctionContext { 77; +00 struct _Unwind_FunctionContext *prev; -312(%rbp) 78; +08 uint32_t __callsite; -304(%rbp) 79; +12 uint32_t __buffer[4]; -300(%rbp) 80; +32 __personality_routine __personality; -280(%rbp) 81; +40 uintptr_t __lsda; -272(%rbp) 82; +48 void *__jbuf[]; -264(%rbp) 83; }; 84 85 86; CHECK-X64-LABEL: _Z8functionv: 87; struct _Unwind_FunctionContext UFC; 88; 89; UFC.__personality = __gxx_personality_sj0 90; CHECK-X64: leaq __gxx_personality_sj0(%rip), %rax 91; CHECK-X64: movq %rax, -280(%rbp) 92; UFC.__lsda = $LSDA 93; CHECK-X64: leaq [[LSDA:GCC_except_table[0-9]+]](%rip), %rax 94; CHECK-X64: movq %rax, -272(%rbp) 95; UFC.__jbuf[0] = $rbp 96; CHECK-X64: movq %rbp, -264(%rbp) 97; UFC.__jbuf[2] = $rsp 98; CHECK-X64: movq %rsp, -248(%rbp) 99; UFC.__jbuf[1] = $RIP 100; CHECK-X64: leaq .[[RESUME:LBB[0-9]+_[0-9]+]](%rip), %rax 101; CHECK-X64: movq %rax, -256(%rbp) 102; UFC.__callsite = 1 103; CHECK-X64: movl $1, -304(%rbp) 104; _Unwind_SjLj_Register(&UFC); 105; CHECK-X64: leaq -312(%rbp), %rcx 106; CHECK-X64: callq _Unwind_SjLj_Register 107; function_that_throws(); 108; CHECK-X64: callq _Z20function_that_throwsv 109; _Unwind_SjLj_Unregister(&UFC); 110; CHECK-X64: leaq -312(%rbp), %rcx 111; CHECK-X64: callq _Unwind_SjLj_Unregister 112; 113; CHECK-X64: [[RESUME]]: 114; assert(UFC.__callsite < 1); 115; CHECK-X64: movl -304(%rbp), %eax 116; CHECK-X64: cmpl $1, %eax 117; CHECK-X64: jb .[[CONT:LBB[0-9]+_[0-9]+]] 118; CHECK-X64: ud2 119; CHECK-X64: [[CONT]]: 120; *Handlers[UFC.__callsite] 121; CHECK-X64: leaq .[[TABLE:LJTI[0-9]+_[0-9]+]](%rip), %rcx 122; CHECK-X64: movl (%rcx,%rax,4), %eax 123; CHECK-X64: cltq 124; CHECK-X64: addq %rcx, %rax 125; CHECK-X64: jmpq *%rax 126 127; CHECK-X64-LINUX: .[[RESUME:LBB[0-9]+_[0-9]+]]: 128; assert(UFC.__callsite < 1); 129; CHECK-X64-LINUX: movl -120(%rbp), %eax 130; CHECK-X64-LINUX: cmpl $1, %eax 131; CHECK-X64-LINUX: jb .[[CONT:LBB[0-9]+_[0-9]+]] 132; CHECK-X64-LINUX: ud2 133; CHECK-X64-LINUX: [[CONT]]: 134; *Handlers[UFC.__callsite] 135; CHECK-X64-LINUX: leaq .[[TABLE:LJTI[0-9]+_[0-9]+]](%rip), %rcx 136; CHECK-X64-LINUX: jmpq *(%rcx,%rax,8) 137