1 ; RUN: opt -mtriple=x86_64-pc-windows-msvc -winehprepare -S -o - < %s | FileCheck %s
3 ; This test is based on the following code:
14 ; Parts of the IR have been hand-edited to simplify the test case.
15 ; The full IR will be restored when Windows C++ EH support is complete.
17 ; ModuleID = 'catch-all.cpp'
18 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
19 target triple = "x86_64-pc-windows-msvc"
21 ; The function entry in this case remains unchanged.
22 ; CHECK: define void @_Z4testv() #0 {
24 ; CHECK: invoke void @_Z9may_throwv()
25 ; CHECK: to label %invoke.cont unwind label %[[LPAD_LABEL:lpad[0-9]+]]
27 ; Function Attrs: uwtable
28 define void @_Z4testv() #0 {
30 %exn.slot = alloca i8*
31 %ehselector.slot = alloca i32
32 invoke void @_Z9may_throwv()
33 to label %invoke.cont unwind label %lpad
35 invoke.cont: ; preds = %entry
38 ; CHECK: [[LPAD_LABEL]]:{{[ ]+}}; preds = %entry
39 ; CHECK: [[LPAD_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
40 ; CHECK: catch i8* null
41 ; CHECK-NOT: extractvalue { i8*, i32 }
42 ; CHECK-NOT: store i8*
43 ; CHECK-NOT: store i32
44 ; CHECK-NOT: br label %catch
45 ; CHECK: [[RECOVER:\%.+]] = call i8* (...)* @llvm.eh.actions({ i8*, i32 } [[LPAD_VAL]], i32 0, i8* null, i8* null, i8* bitcast (i8* (i8*, i8*)* @_Z4testv.catch to i8*))
46 ; CHECK: indirectbr i8* [[RECOVER]], [label %try.cont]
48 lpad: ; preds = %entry
49 %tmp = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
51 %tmp1 = extractvalue { i8*, i32 } %tmp, 0
52 store i8* %tmp1, i8** %exn.slot
53 %tmp2 = extractvalue { i8*, i32 } %tmp, 1
54 store i32 %tmp2, i32* %ehselector.slot
59 catch: ; preds = %lpad
60 %exn = load i8*, i8** %exn.slot
61 call void @llvm.eh.begincatch(i8* %exn, i8* null) #2
62 call void @_Z16handle_exceptionv()
63 br label %invoke.cont2
65 ; CHECK-NOT: invoke.cont2:
67 invoke.cont2: ; preds = %catch
68 call void @llvm.eh.endcatch()
71 try.cont: ; preds = %invoke.cont2, %invoke.cont
77 ; CHECK: define internal i8* @_Z4testv.catch(i8*, i8*) {
79 ; CHECK: call void @_Z16handle_exceptionv()
80 ; CHECK: ret i8* blockaddress(@_Z4testv, %try.cont)
83 declare void @_Z9may_throwv() #1
85 declare i32 @__CxxFrameHandler3(...)
87 declare void @llvm.eh.begincatch(i8*, i8*)
89 declare void @_Z16handle_exceptionv() #1
91 declare void @llvm.eh.endcatch()
93 attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
94 attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
95 attributes #2 = { noinline noreturn nounwind }
96 attributes #3 = { nounwind }
97 attributes #4 = { noreturn nounwind }
101 !0 = !{!"clang version 3.7.0 (trunk 226027)"}