CodeGen peephole: fold redundant phys reg copies
[oota-llvm.git] / test / CodeGen / X86 / funclet-layout.ll
index 43587671d2d8227900c325743478d591b2dbbe8a..053d484889b60d3db20f7a51a17398ea431bba67 100644 (file)
@@ -4,6 +4,10 @@ target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-pc-windows-msvc"
 
 %eh.ThrowInfo = type { i32, i32, i32, i32 }
+%rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
+
+@"\01??_7type_info@@6B@" = external constant i8*
+@"\01??_R0H@8" = internal global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }
 
 define void @test1(i1 %B) personality i32 (...)* @__CxxFrameHandler3 {
 entry:
@@ -38,7 +42,7 @@ unreachable:
 ; CHECK: retq
 
 ; The catch funclet contains %catch and %catchret
-; CHECK: # %catch
+; CHECK: # %catch{{$}}
 ; CHECK: # %catchret
 ; CHECK: retq
 
@@ -89,14 +93,73 @@ unreachable:                                      ; preds = %catch, %entry
 ; CHECK: # %try.cont.5
 ; CHECK: retq
 
-; The inner catch funclet contains %catch.3
-; CHECK: # %catch.3
-; CHECK: retq
+; The outer catch funclet contains %catch.dispatch
+; CHECK: # %catch.dispatch{{$}}
+; CHECK: callq _CxxThrowException
+; CHECK: # %unreachable
+; CHECK: ud2
 
-; The outer catch funclet contains %catch and %try.cont
-; CHECK: # %catch
-; CHECK: # %try.cont
+; 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:
+  invoke void @g()
+          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
+
+catch.2:                                          ; preds = %catch.dispatch
+  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
+
+catch:                                            ; preds = %catch.dispatch.1
+  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
+
+exit_one:
+  tail call void @exit(i32 0)
+  unreachable
+
+exit_two:
+  tail call void @exit(i32 0)
+  unreachable
+}
+
+; CHECK-LABEL: test3:
+
+; The entry funclet contains %entry and %try.cont
+; CHECK: # %entry
+; CHECK: # %try.cont
+; CHECK: callq exit
+; CHECK-NOT: # exit_one
+; CHECK-NOT: # exit_two
+; CHECK: ud2
+
+; The catch(...) funclet contains %catch.dispatch
+; CHECK: # %catch.dispatch{{$}}
+; CHECK: callq exit
+; CHECK: ud2
+
+; The catch(int) funclet contains %catch.dispatch.1
+; CHECK: # %catch.dispatch.1
+; CHECK: callq exit
+; CHECK: ud2
+
+declare void @exit(i32) noreturn nounwind
 declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
 declare i32 @__CxxFrameHandler3(...)