Home | History | Annotate | Download | only in X86
      1 ; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
      2 
      3 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
      4 target triple = "x86_64-pc-windows-msvc"
      5 
      6 %eh.ThrowInfo = type { i32, i32, i32, i32 }
      7 %rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
      8 
      9 @"\01??_7type_info@@6B@" = external constant i8*
     10 @"\01??_R0H@8" = internal global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }
     11 
     12 define void @test1(i1 %B) personality i32 (...)* @__CxxFrameHandler3 {
     13 entry:
     14   invoke void @g()
     15           to label %unreachable unwind label %catch.dispatch
     16 
     17 catch.dispatch:
     18   %cs1 = catchswitch within none [label %catch] unwind to caller
     19 
     20 catch:
     21   %cp = catchpad within %cs1 [i8* null, i32 64, i8* null]
     22   br label %catch.loop
     23 
     24 catch.loop:
     25   br i1 %B, label %catchret, label %catch.loop
     26 
     27 catchret:
     28   catchret from %cp to label %try.cont
     29 
     30 try.cont:
     31   ret void
     32 
     33 unreachable:
     34   unreachable
     35 }
     36 
     37 ; CHECK-LABEL: test1:
     38 
     39 ; The entry funclet contains %entry and %try.cont
     40 ; CHECK: # %entry
     41 ; CHECK: # %try.cont
     42 ; CHECK: retq
     43 
     44 ; The catch funclet contains %catch and %catchret
     45 ; CHECK: # %catch{{$}}
     46 ; CHECK: # %catchret
     47 ; CHECK: retq
     48 
     49 declare void @g()
     50 
     51 
     52 define i32 @test2(i1 %B) personality i32 (...)* @__CxxFrameHandler3 {
     53 entry:
     54   invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1
     55           to label %unreachable unwind label %catch.dispatch
     56 
     57 catch.dispatch:                                   ; preds = %entry
     58   %cs1 = catchswitch within none [label %catch] unwind to caller
     59 
     60 catch:                                            ; preds = %catch.dispatch
     61   %0 = catchpad within %cs1 [i8* null, i32 64, i8* null]
     62   invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1 ["funclet"(token %0)]
     63           to label %unreachable unwind label %catch.dispatch.1
     64 
     65 catch.dispatch.1:                                 ; preds = %catch
     66   %cs2 = catchswitch within %0 [label %catch.3] unwind to caller
     67 
     68 catch.3:                                          ; preds = %catch.dispatch.1
     69   %1 = catchpad within %cs2 [i8* null, i32 64, i8* null]
     70   catchret from %1 to label %try.cont
     71 
     72 try.cont:                                         ; preds = %catch.3
     73   catchret from %0 to label %try.cont.5
     74 
     75 try.cont.5:                                       ; preds = %try.cont
     76   ret i32 0
     77 
     78 unreachable:                                      ; preds = %catch, %entry
     79   unreachable
     80 }
     81 
     82 ; CHECK-LABEL: test2:
     83 
     84 ; The parent function contains %entry and %try.cont.5
     85 ; CHECK: .seh_proc
     86 ; CHECK: # %entry
     87 ; CHECK: # %try.cont.5
     88 ; CHECK: retq
     89 
     90 ; The inner catch funclet contains %catch.3
     91 ; CHECK: .seh_proc
     92 ; CHECK: # %catch.3{{$}}
     93 ; CHECK: retq
     94 
     95 ; The outer catch funclet contains %catch
     96 ; CHECK: .seh_proc
     97 ; CHECK: # %catch{{$}}
     98 ; CHECK: callq _CxxThrowException
     99 ; CHECK: # %unreachable
    100 ; CHECK: ud2
    101 
    102 
    103 define void @test3(i1 %V) #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
    104 entry:
    105   invoke void @g()
    106           to label %try.cont unwind label %catch.dispatch
    107 
    108 catch.dispatch:                                   ; preds = %entry
    109   %cs1 = catchswitch within none [label %catch.2] unwind label %catch.dispatch.1
    110 
    111 catch.2:                                          ; preds = %catch.dispatch
    112   %0 = catchpad within %cs1 [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
    113   tail call void @exit(i32 0) #2 [ "funclet"(token %0) ]
    114   unreachable
    115 
    116 catch.dispatch.1:                                 ; preds = %catch.dispatch
    117   %cs2 = catchswitch within none [label %catch] unwind to caller
    118 
    119 catch:                                            ; preds = %catch.dispatch.1
    120   %1 = catchpad within %cs2 [i8* null, i32 64, i8* null]
    121   tail call void @exit(i32 0) #2 [ "funclet"(token %1) ]
    122   unreachable
    123 
    124 try.cont:                                         ; preds = %entry
    125   br i1 %V, label %exit_one, label %exit_two
    126 
    127 exit_one:
    128   tail call void @exit(i32 0)
    129   unreachable
    130 
    131 exit_two:
    132   tail call void @exit(i32 0)
    133   unreachable
    134 }
    135 
    136 ; CHECK-LABEL: test3:
    137 
    138 ; The entry funclet contains %entry and %try.cont
    139 ; CHECK: # %entry
    140 ; CHECK: # %try.cont
    141 ; CHECK: callq exit
    142 ; CHECK-NOT: # exit_one
    143 ; CHECK-NOT: # exit_two
    144 ; CHECK: ud2
    145 
    146 ; The catch(...) funclet contains %catch.2
    147 ; CHECK: # %catch.2{{$}}
    148 ; CHECK: callq exit
    149 ; CHECK: ud2
    150 
    151 ; The catch(int) funclet contains %catch
    152 ; CHECK: # %catch{{$}}
    153 ; CHECK: callq exit
    154 ; CHECK: ud2
    155 
    156 declare void @exit(i32) noreturn nounwind
    157 declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
    158 declare i32 @__CxxFrameHandler3(...)
    159