1 ; RUN: opt -mtriple=x86_64-pc-windows-msvc -S -winehprepare -disable-demotion -disable-cleanups < %s | FileCheck %s
3 declare i32 @__CxxFrameHandler3(...)
5 declare i32 @__C_specific_handler(...)
13 ; CHECK-LABEL: @test1(
14 define void @test1(i1 %bool) personality i32 (...)* @__C_specific_handler {
17 to label %invoke.cont unwind label %left
21 to label %exit unwind label %inner
24 %0 = cleanuppad within none []
25 br i1 %bool, label %shared, label %cleanupret
28 cleanupret from %0 unwind label %right
31 %1 = cleanuppad within none []
37 to label %shared.cont unwind label %inner
43 %phi = phi i32 [ %x, %shared ], [ 0, %invoke.cont ]
44 %i = cleanuppad within none []
45 call void @h(i32 %phi)
48 ; CHECK: %phi = phi i32 [ %x, %shared ], [ 0, %invoke.cont ], [ %x.for.left, %shared.for.left ]
49 ; CHECK: %i = cleanuppad within none []
50 ; CHECK: call void @h(i32 %phi)
56 ; CHECK-LABEL: @test2(
57 define void @test2(i1 %bool) personality i32 (...)* @__C_specific_handler {
60 to label %shared.cont unwind label %left
63 %0 = cleanuppad within none []
64 br i1 %bool, label %shared, label %cleanupret
67 cleanupret from %0 unwind label %right
70 %1 = cleanuppad within none []
76 to label %shared.cont unwind label %inner
82 %i = cleanuppad within none []
86 ; CHECK: %x1 = phi i32 [ %x.for.left, %shared.for.left ], [ %x, %shared ]
87 ; CHECK: %i = cleanuppad within none []
88 ; CHECK: call void @h(i32 %x1)
94 ; CHECK-LABEL: @test4(
95 define void @test4(i1 %x) personality i32 (...)* @__CxxFrameHandler3 {
98 to label %invoke.cont1 unwind label %left
102 to label %exit unwind label %right
105 %0 = cleanuppad within none []
109 %1 = cleanuppad within none []
110 br i1 %x, label %shared, label %right.other
116 %phi = phi i32 [ 1, %left ], [ 0, %right ], [ -1, %right.other ]
117 call void @h(i32 %phi)
120 ; CHECK: %phi = phi i32 [ 0, %right ], [ -1, %right.other ]
121 ; CHECK: call void @h(i32 %phi)
123 ; CHECK: %phi.for.left = phi i32 [ 1, %left ]
124 ; CHECK: call void @h(i32 %phi.for.left)
130 declare void @__std_terminate()