blob: b48d53475995fabed779fe5162fc9b06069a5e00 [file] [log] [blame]
Andrew Kaylor1476e6d2015-02-24 20:49:35 +00001; RUN: opt -mtriple=x86_64-pc-windows-msvc -winehprepare -S -o - < %s | FileCheck %s
2
3; This test is based on the following code:
4;
5; void test()
6; {
7; try {
8; may_throw();
9; } catch (...) {
10; handle_exception();
11; }
12; }
13;
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.
16
17; ModuleID = 'catch-all.cpp'
18target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
19target triple = "x86_64-pc-windows-msvc"
20
21; Function Attrs: uwtable
22define void @_Z4testv() #0 {
23entry:
24 %exn.slot = alloca i8*
25 %ehselector.slot = alloca i32
26 invoke void @_Z9may_throwv()
27 to label %invoke.cont unwind label %lpad
28
29invoke.cont: ; preds = %entry
30 br label %try.cont
31
32lpad: ; preds = %entry
33 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
34 catch i8* null
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
39 br label %catch
40
41catch: ; preds = %lpad
David Blaikiea79ac142015-02-27 21:17:42 +000042 %exn = load i8*, i8** %exn.slot
Andrew Kaylor1476e6d2015-02-24 20:49:35 +000043 %3 = call i8* @llvm.eh.begincatch(i8* %exn) #3
44 call void @_Z16handle_exceptionv()
45 br label %invoke.cont2
46
47invoke.cont2: ; preds = %catch
48 call void @llvm.eh.endcatch()
49 br label %try.cont
50
51try.cont: ; preds = %invoke.cont2, %invoke.cont
52 ret void
53}
54
55; CHECK: define i8* @_Z4testv.catch(i8*, i8*) {
56; CHECK: catch.entry:
57; CHECK: %eh.alloc = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1)
58; CHECK: %eh.data = bitcast i8* %eh.alloc to %struct._Z4testv.ehdata*
David Blaikie79e6c742015-02-27 19:29:02 +000059; CHECK: %eh.obj.ptr = getelementptr inbounds %struct._Z4testv.ehdata, %struct._Z4testv.ehdata* %eh.data, i32 0, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000060; CHECK: %eh.obj = load i8*, i8** %eh.obj.ptr
Andrew Kaylor1476e6d2015-02-24 20:49:35 +000061; CHECK: call void @_Z16handle_exceptionv()
62; CHECK: ret i8* blockaddress(@_Z4testv, %try.cont)
63; CHECK: }
64
65declare void @_Z9may_throwv() #1
66
67declare i32 @__CxxFrameHandler3(...)
68
69declare i8* @llvm.eh.begincatch(i8*)
70
71declare void @_Z16handle_exceptionv() #1
72
73declare void @llvm.eh.endcatch()
74
75attributes #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" }
76attributes #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" }
77attributes #2 = { noinline noreturn nounwind }
78attributes #3 = { nounwind }
79attributes #4 = { noreturn nounwind }
80
81!llvm.ident = !{!0}
82
83!0 = !{!"clang version 3.7.0 (trunk 226027)"}