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 ; Function Attrs: uwtable
22 define void @_Z4testv() #0 {
24 %exn.slot = alloca i8*
25 %ehselector.slot = alloca i32
26 invoke void @_Z9may_throwv()
27 to label %invoke.cont unwind label %lpad
29 invoke.cont: ; preds = %entry
32 lpad: ; preds = %entry
33 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
35 %1 = extractvalue { i8*, i32 } %0, 0
36 store i8* %1, i8** %exn.slot
37 %2 = extractvalue { i8*, i32 } %0, 1
38 store i32 %2, i32* %ehselector.slot
41 catch: ; preds = %lpad
42 %exn = load i8** %exn.slot
43 %3 = call i8* @llvm.eh.begincatch(i8* %exn) #3
44 call void @_Z16handle_exceptionv()
45 br label %invoke.cont2
47 invoke.cont2: ; preds = %catch
48 call void @llvm.eh.endcatch()
51 try.cont: ; preds = %invoke.cont2, %invoke.cont
55 ; CHECK: define i8* @_Z4testv.catch(i8*, i8*) {
57 ; CHECK: %eh.alloc = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1)
58 ; CHECK: %ehdata = bitcast i8* %eh.alloc to %struct._Z4testv.ehdata*
59 ; CHECK: %eh.obj.ptr = getelementptr inbounds %struct._Z4testv.ehdata* %ehdata, i32 0, i32 1
60 ; CHECK: %eh.obj = load i8** %eh.obj.ptr
61 ; CHECK: call void @_Z16handle_exceptionv()
62 ; CHECK: ret i8* blockaddress(@_Z4testv, %try.cont)
65 declare void @_Z9may_throwv() #1
67 declare i32 @__CxxFrameHandler3(...)
69 declare i8* @llvm.eh.begincatch(i8*)
71 declare void @_Z16handle_exceptionv() #1
73 declare void @llvm.eh.endcatch()
75 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" }
76 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" }
77 attributes #2 = { noinline noreturn nounwind }
78 attributes #3 = { nounwind }
79 attributes #4 = { noreturn nounwind }
83 !0 = !{!"clang version 3.7.0 (trunk 226027)"}