Home | History | Annotate | Download | only in X86
      1 ; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s
      2 
      3 declare void @may_throw_or_crash()
      4 declare i32 @_except_handler3(...)
      5 declare i32 @_except_handler4(...)
      6 declare i32 @__CxxFrameHandler3(...)
      7 declare void @llvm.eh.begincatch(i8*, i8*)
      8 declare void @llvm.eh.endcatch()
      9 declare i32 @llvm.eh.typeid.for(i8*)
     10 
     11 define internal i32 @catchall_filt() {
     12   ret i32 1
     13 }
     14 
     15 define void @use_except_handler3() personality i32 (...)* @_except_handler3 {
     16 entry:
     17   invoke void @may_throw_or_crash()
     18       to label %cont unwind label %lpad
     19 cont:
     20   ret void
     21 lpad:
     22   %cs = catchswitch within none [label %catch] unwind to caller
     23 catch:
     24   %p = catchpad within %cs [i8* bitcast (i32 ()* @catchall_filt to i8*)]
     25   catchret from %p to label %cont
     26 }
     27 
     28 ; CHECK-LABEL: _use_except_handler3:
     29 ; CHECK: pushl %ebp
     30 ; CHECK: movl %esp, %ebp
     31 ; CHECK: pushl %ebx
     32 ; CHECK: pushl %edi
     33 ; CHECK: pushl %esi
     34 ; CHECK: subl ${{[0-9]+}}, %esp
     35 ; CHECK: movl $-1, -16(%ebp)
     36 ; CHECK: movl $L__ehtable$use_except_handler3, -20(%ebp)
     37 ; CHECK: leal -28(%ebp), %[[node:[^ ,]*]]
     38 ; CHECK: movl $__except_handler3, -24(%ebp)
     39 ; CHECK: movl %fs:0, %[[next:[^ ,]*]]
     40 ; CHECK: movl %[[next]], -28(%ebp)
     41 ; CHECK: movl %[[node]], %fs:0
     42 ; CHECK: calll _may_throw_or_crash
     43 ; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
     44 ; CHECK: movl %[[next]], %fs:0
     45 ; CHECK: retl
     46 ; CHECK: LBB1_2: # %catch{{$}}
     47 
     48 ; CHECK: .section .xdata,"dr"
     49 ; CHECK-LABEL: L__ehtable$use_except_handler3:
     50 ; CHECK-NEXT:  .long   -1
     51 ; CHECK-NEXT:  .long   _catchall_filt
     52 ; CHECK-NEXT:  .long   LBB1_2
     53 
     54 define void @use_except_handler4() personality i32 (...)* @_except_handler4 {
     55 entry:
     56   invoke void @may_throw_or_crash()
     57       to label %cont unwind label %lpad
     58 cont:
     59   ret void
     60 lpad:
     61   %cs = catchswitch within none [label %catch] unwind to caller
     62 catch:
     63   %p = catchpad within %cs [i8* bitcast (i32 ()* @catchall_filt to i8*)]
     64   catchret from %p to label %cont
     65 }
     66 
     67 ; CHECK-LABEL: _use_except_handler4:
     68 ; CHECK: pushl %ebp
     69 ; CHECK: movl %esp, %ebp
     70 ; CHECK: subl ${{[0-9]+}}, %esp
     71 ; CHECK: movl %esp, -36(%ebp)
     72 ; CHECK: movl $-2, -16(%ebp)
     73 ; CHECK: movl $L__ehtable$use_except_handler4, %[[lsda:[^ ,]*]]
     74 ; CHECK: xorl ___security_cookie, %[[lsda]]
     75 ; CHECK: movl %[[lsda]], -20(%ebp)
     76 ; CHECK: leal -28(%ebp), %[[node:[^ ,]*]]
     77 ; CHECK: movl $__except_handler4, -24(%ebp)
     78 ; CHECK: movl %fs:0, %[[next:[^ ,]*]]
     79 ; CHECK: movl %[[next]], -28(%ebp)
     80 ; CHECK: movl %[[node]], %fs:0
     81 ; CHECK: calll _may_throw_or_crash
     82 ; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
     83 ; CHECK: movl %[[next]], %fs:0
     84 ; CHECK: retl
     85 ; CHECK: LBB2_2: # %catch{{$}}
     86 
     87 ; CHECK: .section .xdata,"dr"
     88 ; CHECK-LABEL: L__ehtable$use_except_handler4:
     89 ; CHECK-NEXT:  .long   -2
     90 ; CHECK-NEXT:  .long   0
     91 ; CHECK-NEXT:  .long   9999
     92 ; CHECK-NEXT:  .long   0
     93 ; CHECK-NEXT:  .long   -2
     94 ; CHECK-NEXT:  .long   _catchall_filt
     95 ; CHECK-NEXT:  .long   LBB2_2
     96 
     97 define void @use_CxxFrameHandler3() personality i32 (...)* @__CxxFrameHandler3 {
     98   invoke void @may_throw_or_crash()
     99       to label %cont unwind label %catchall
    100 cont:
    101   ret void
    102 
    103 catchall:
    104   %cs = catchswitch within none [label %catch] unwind to caller
    105 catch:
    106   %p = catchpad within %cs [i8* null, i32 64, i8* null]
    107   catchret from %p to label %cont
    108 }
    109 
    110 ; CHECK-LABEL: _use_CxxFrameHandler3:
    111 ; CHECK: pushl %ebp
    112 ; CHECK: movl %esp, %ebp
    113 ; CHECK: subl ${{[0-9]+}}, %esp
    114 ; CHECK: movl %esp, -28(%ebp)
    115 ; CHECK: movl $-1, -16(%ebp)
    116 ; CHECK: leal -24(%ebp), %[[node:[^ ,]*]]
    117 ; CHECK: movl $___ehhandler$use_CxxFrameHandler3, -20(%ebp)
    118 ; CHECK: movl %fs:0, %[[next:[^ ,]*]]
    119 ; CHECK: movl %[[next]], -24(%ebp)
    120 ; CHECK: movl %[[node]], %fs:0
    121 ; CHECK: movl $0, -16(%ebp)
    122 ; CHECK: calll _may_throw_or_crash
    123 ; CHECK: movl -24(%ebp), %[[next:[^ ,]*]]
    124 ; CHECK: movl %[[next]], %fs:0
    125 ; CHECK: retl
    126 
    127 ; CHECK: .section .xdata,"dr"
    128 ; CHECK: .align 4
    129 ; CHECK-LABEL: L__ehtable$use_CxxFrameHandler3:
    130 ; CHECK-NEXT:  .long   429065506
    131 ; CHECK-NEXT:  .long   2
    132 ; CHECK-NEXT:  .long   ($stateUnwindMap$use_CxxFrameHandler3)
    133 ; CHECK-NEXT:  .long   1
    134 ; CHECK-NEXT:  .long   ($tryMap$use_CxxFrameHandler3)
    135 ; CHECK-NEXT:  .long   0
    136 ; CHECK-NEXT:  .long   0
    137 ; CHECK-NEXT:  .long   0
    138 ; CHECK-NEXT:  .long   1
    139 
    140 ; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3:
    141 ; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax
    142 ; CHECK: jmp  ___CxxFrameHandler3 # TAILCALL
    143 
    144 ; CHECK: .safeseh __except_handler3
    145 ; CHECK: .safeseh __except_handler4
    146 ; CHECK: .safeseh ___ehhandler$use_CxxFrameHandler3
    147