1 ; RUN: opt -mtriple=x86_64-pc-windows-msvc -winehprepare -S -o - < %s | FileCheck %s
\r
3 ; This test is based on the following code:
\r
10 ; handle_exception();
\r
14 ; Parts of the IR have been hand-edited to simplify the test case.
\r
15 ; The full IR will be restored when Windows C++ EH support is complete.
\r
17 ; ModuleID = 'catch-all.cpp'
\r
18 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
\r
19 target triple = "x86_64-pc-windows-msvc"
\r
21 ; Function Attrs: uwtable
\r
22 define void @_Z4testv() #0 {
\r
24 %exn.slot = alloca i8*
\r
25 %ehselector.slot = alloca i32
\r
26 invoke void @_Z9may_throwv()
\r
27 to label %invoke.cont unwind label %lpad
\r
29 invoke.cont: ; preds = %entry
\r
32 lpad: ; preds = %entry
\r
33 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
\r
35 %1 = extractvalue { i8*, i32 } %0, 0
\r
36 store i8* %1, i8** %exn.slot
\r
37 %2 = extractvalue { i8*, i32 } %0, 1
\r
38 store i32 %2, i32* %ehselector.slot
\r
41 catch: ; preds = %lpad
\r
42 %exn = load i8** %exn.slot
\r
43 %3 = call i8* @llvm.eh.begincatch(i8* %exn) #3
\r
44 call void @_Z16handle_exceptionv()
\r
45 br label %invoke.cont2
\r
47 invoke.cont2: ; preds = %catch
\r
48 call void @llvm.eh.endcatch()
\r
51 try.cont: ; preds = %invoke.cont2, %invoke.cont
\r
55 ; CHECK: define i8* @_Z4testv.catch(i8*, i8*) {
\r
56 ; CHECK: catch.entry:
\r
57 ; CHECK: %eh.alloc = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1)
\r
58 ; CHECK: %ehdata = bitcast i8* %eh.alloc to %struct._Z4testv.ehdata*
\r
59 ; CHECK: %eh.obj.ptr = getelementptr inbounds %struct._Z4testv.ehdata* %ehdata, i32 0, i32 1
\r
60 ; CHECK: %eh.obj = load i8** %eh.obj.ptr
\r
61 ; CHECK: call void @_Z16handle_exceptionv()
\r
62 ; CHECK: ret i8* blockaddress(@_Z4testv, %try.cont)
\r
65 declare void @_Z9may_throwv() #1
\r
67 declare i32 @__CxxFrameHandler3(...)
\r
69 declare i8* @llvm.eh.begincatch(i8*)
\r
71 declare void @_Z16handle_exceptionv() #1
\r
73 declare void @llvm.eh.endcatch()
\r
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" }
\r
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" }
\r
77 attributes #2 = { noinline noreturn nounwind }
\r
78 attributes #3 = { nounwind }
\r
79 attributes #4 = { noreturn nounwind }
\r
83 !0 = !{!"clang version 3.7.0 (trunk 226027)"}
\r