1; RUN: opt -S -simplifycfg < %s | FileCheck %s
2target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
3target triple = "x86_64-pc-windows-msvc18.0.0"
4
5; Function Attrs: uwtable
6define void @test1() #0 personality i32 (...)* @__CxxFrameHandler3 {
7entry:
8  invoke void @may_throw(i32 3)
9          to label %invoke.cont unwind label %ehcleanup
10
11invoke.cont:                                      ; preds = %entry
12  tail call void @may_throw(i32 2) #2
13  tail call void @may_throw(i32 1) #2
14  ret void
15
16ehcleanup:                                        ; preds = %entry
17  %cp = cleanuppad within none []
18  tail call void @may_throw(i32 2) #2 [ "funclet"(token %cp) ]
19  cleanupret from %cp unwind label %ehcleanup2
20
21ehcleanup2:
22  %cp2 = cleanuppad within none []
23  tail call void @may_throw(i32 1) #2 [ "funclet"(token %cp2) ]
24  cleanupret from %cp2 unwind to caller
25}
26
27; CHECK-LABEL: define void @test1(
28; CHECK: %[[cp:.*]] = cleanuppad within none []
29; CHECK: tail call void @may_throw(i32 2) #2 [ "funclet"(token %[[cp]]) ]
30; CHECK: tail call void @may_throw(i32 1) #2 [ "funclet"(token %[[cp]]) ]
31; CHECK: cleanupret from %[[cp]] unwind to caller
32
33declare void @may_throw(i32) #1
34
35declare i32 @__CxxFrameHandler3(...)
36
37attributes #0 = { uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
38attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
39attributes #2 = { nounwind }
40