Merging r259696:
[oota-llvm.git] / test / Transforms / SimplifyCFG / wineh-unreachable.ll
index aa1feb7b1714c7f08236084ccdfe5239d29e9619..c5d6490ba5d5789f90d98ba185ec23c41d0bfbd3 100644 (file)
@@ -65,34 +65,103 @@ unreachable.unwind:
   unreachable
 }
 
-; CHECK-LABEL: define void @test4()
-define void @test4() personality i8* bitcast (void ()* @Personality to i8*) {
+; CHECK-LABEL: define void @test5()
+define void @test5() personality i8* bitcast (void ()* @Personality to i8*) {
 entry:
   invoke void @f()
-    to label %exit unwind label %terminate.pad
-terminate.pad:
-  ; CHECK: terminatepad within none [] unwind to caller
-  terminatepad within none [] unwind label %unreachable.unwind
+          to label %exit unwind label %catch.pad
+
+catch.pad:
+  %cs1 = catchswitch within none [label %catch.body] unwind to caller
+
+catch.body:
+  %catch = catchpad within %cs1 []
+  catchret from %catch to label %exit
+
 exit:
-  ret void
-unreachable.unwind:
-  cleanuppad within none []
   unreachable
 }
 
-; CHECK-LABEL: define void @test5()
-define void @test5() personality i8* bitcast (void ()* @Personality to i8*) {
+; CHECK-LABEL: define void @test6()
+define void @test6() personality i8* bitcast (void ()* @Personality to i8*) {
 entry:
   invoke void @f()
           to label %exit unwind label %catch.pad
 
 catch.pad:
-  %cs1 = catchswitch within none [label %catch.body] unwind to caller
+  %cs1 = catchswitch within none [label %catch.body, label %catch.body] unwind to caller
+  ; CHECK: catchswitch within none [label %catch.body] unwind to caller
 
 catch.body:
-  %catch = catchpad within %cs1 []
+  %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
   catchret from %catch to label %exit
 
 exit:
-  unreachable
+  ret void
+}
+
+; CHECK-LABEL: define void @test7()
+define void @test7() personality i8* bitcast (void ()* @Personality to i8*) {
+entry:
+  invoke void @f()
+          to label %exit unwind label %catch.pad
+
+catch.pad:
+  %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
+  ; CHECK: catchswitch within none [label %catch.body] unwind to caller
+
+catch.body:
+  %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
+  catchret from %catch to label %exit
+
+catch.body2:
+  %catch2 = catchpad within %cs1 [i8* null, i32 0, i8* null]
+  catchret from %catch2 to label %exit
+
+exit:
+  ret void
+}
+
+; CHECK-LABEL: define void @test8()
+define void @test8() personality i8* bitcast (void ()* @Personality to i8*) {
+entry:
+  invoke void @f()
+          to label %exit unwind label %catch.pad
+
+catch.pad:
+  %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
+  ; CHECK: catchswitch within none [label %catch.body] unwind to caller
+
+catch.body2:
+  %catch2 = catchpad within %cs1 [i8* null, i32 0, i8* null]
+  catchret from %catch2 to label %exit
+
+catch.body:
+  %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
+  catchret from %catch to label %exit
+
+exit:
+  ret void
+}
+
+; CHECK-LABEL: define void @test9()
+define void @test9() personality i8* bitcast (void ()* @Personality to i8*) {
+entry:
+  invoke void @f()
+          to label %exit unwind label %catch.pad
+
+catch.pad:
+  %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
+  ; CHECK: catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
+
+catch.body:
+  %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
+  catchret from %catch to label %exit
+
+catch.body2:
+  %catch2 = catchpad within %cs1 [i8* null, i32 64, i8* null]
+  catchret from %catch2 to label %exit
+
+exit:
+  ret void
 }