[IR] Reformulate LLVM's EH funclet IR
[oota-llvm.git] / test / CodeGen / X86 / funclet-layout.ll
index 053d484889b60d3db20f7a51a17398ea431bba67..b5972df43cc95851d43e37c9f2a37ef7da0ab848 100644 (file)
@@ -15,21 +15,21 @@ entry:
           to label %unreachable unwind label %catch.dispatch
 
 catch.dispatch:
-  %cp = catchpad [i8* null, i32 64, i8* null]
-          to label %catch unwind label %catchendblock
+  %cs1 = catchswitch within none [label %catch] unwind to caller
 
 catch:
-  br i1 %B, label %catchret, label %catch
+  %cp = catchpad within %cs1 [i8* null, i32 64, i8* null]
+  br label %catch.loop
+
+catch.loop:
+  br i1 %B, label %catchret, label %catch.loop
 
 catchret:
-  catchret %cp to label %try.cont
+  catchret from %cp to label %try.cont
 
 try.cont:
   ret void
 
-catchendblock:
-  catchendpad unwind to caller
-
 unreachable:
   unreachable
 }
@@ -55,54 +55,50 @@ entry:
           to label %unreachable unwind label %catch.dispatch
 
 catch.dispatch:                                   ; preds = %entry
-  %0 = catchpad [i8* null, i32 64, i8* null]
-          to label %catch unwind label %catchendblock
+  %cs1 = catchswitch within none [label %catch] unwind to caller
 
 catch:                                            ; preds = %catch.dispatch
+  %0 = catchpad within %cs1 [i8* null, i32 64, i8* null]
   invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1
           to label %unreachable unwind label %catch.dispatch.1
 
 catch.dispatch.1:                                 ; preds = %catch
-  %1 = catchpad [i8* null, i32 64, i8* null]
-          to label %catch.3 unwind label %catchendblock.2
+  %cs2 = catchswitch within %0 [label %catch.3] unwind to caller
 
 catch.3:                                          ; preds = %catch.dispatch.1
-  catchret %1 to label %try.cont
+  %1 = catchpad within %cs2 [i8* null, i32 64, i8* null]
+  catchret from %1 to label %try.cont
 
 try.cont:                                         ; preds = %catch.3
-  catchret %0 to label %try.cont.5
+  catchret from %0 to label %try.cont.5
 
 try.cont.5:                                       ; preds = %try.cont
   ret i32 0
 
-catchendblock.2:                                  ; preds = %catch.dispatch.1
-  catchendpad unwind label %catchendblock
-
-catchendblock:                                    ; preds = %catchendblock.2, %catch.dispatch
-  catchendpad unwind to caller
-
 unreachable:                                      ; preds = %catch, %entry
   unreachable
-
 }
 
 ; CHECK-LABEL: test2:
 
-; The entry funclet contains %entry and %try.cont.5
+; The parent function contains %entry and %try.cont.5
+; CHECK: .seh_proc
 ; CHECK: # %entry
 ; CHECK: # %try.cont.5
 ; CHECK: retq
 
-; The outer catch funclet contains %catch.dispatch
-; CHECK: # %catch.dispatch{{$}}
+; The inner catch funclet contains %catch.3
+; CHECK: .seh_proc
+; CHECK: # %catch.3{{$}}
+; CHECK: retq
+
+; The outer catch funclet contains %catch
+; CHECK: .seh_proc
+; CHECK: # %catch{{$}}
 ; CHECK: callq _CxxThrowException
 ; CHECK: # %unreachable
 ; CHECK: ud2
 
-; The inner catch funclet contains %catch.dispatch.1
-; CHECK: # %catch.dispatch.1
-; CHECK: retq
-
 
 define void @test3(i1 %V) #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
 entry:
@@ -110,24 +106,21 @@ entry:
           to label %try.cont unwind label %catch.dispatch
 
 catch.dispatch:                                   ; preds = %entry
-  %0 = catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
-          to label %catch.2 unwind label %catch.dispatch.1
+  %cs1 = catchswitch within none [label %catch.2] unwind label %catch.dispatch.1
 
 catch.2:                                          ; preds = %catch.dispatch
+  %0 = catchpad within %cs1 [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
   tail call void @exit(i32 0) #2
   unreachable
 
 catch.dispatch.1:                                 ; preds = %catch.dispatch
-  %1 = catchpad [i8* null, i32 64, i8* null]
-          to label %catch unwind label %catchendblock
+  %cs2 = catchswitch within none [label %catch] unwind to caller
 
 catch:                                            ; preds = %catch.dispatch.1
+  %1 = catchpad within %cs2 [i8* null, i32 64, i8* null]
   tail call void @exit(i32 0) #2
   unreachable
 
-catchendblock:                                    ; preds = %catch.dispatch.1
-  catchendpad unwind to caller
-
 try.cont:                                         ; preds = %entry
   br i1 %V, label %exit_one, label %exit_two
 
@@ -150,13 +143,13 @@ exit_two:
 ; CHECK-NOT: # exit_two
 ; CHECK: ud2
 
-; The catch(...) funclet contains %catch.dispatch
-; CHECK: # %catch.dispatch{{$}}
+; The catch(...) funclet contains %catch.2
+; CHECK: # %catch.2{{$}}
 ; CHECK: callq exit
 ; CHECK: ud2
 
-; The catch(int) funclet contains %catch.dispatch.1
-; CHECK: # %catch.dispatch.1
+; The catch(int) funclet contains %catch
+; CHECK: # %catch{{$}}
 ; CHECK: callq exit
 ; CHECK: ud2