annotate clang/test/CodeGenCXX/microsoft-abi-eh-catch.cpp @ 206:f17a3b42b08b

Added tag before-12 for changeset b7591485f4cd
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 07 Jun 2021 21:25:57 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-pc-windows-msvc \
anatofuz
parents:
diff changeset
2 // RUN: -mconstructor-aliases -fexceptions -fcxx-exceptions \
anatofuz
parents:
diff changeset
3 // RUN: -O1 -disable-llvm-passes \
anatofuz
parents:
diff changeset
4 // RUN: | FileCheck -check-prefix WIN64 %s
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 extern "C" void might_throw();
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 // Simplify the generated IR with noexcept.
anatofuz
parents:
diff changeset
9 extern "C" void recover() noexcept(true);
anatofuz
parents:
diff changeset
10 extern "C" void handle_exception(void *e) noexcept(true);
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 extern "C" void catch_all() {
anatofuz
parents:
diff changeset
13 try {
anatofuz
parents:
diff changeset
14 might_throw();
anatofuz
parents:
diff changeset
15 } catch (...) {
anatofuz
parents:
diff changeset
16 recover();
anatofuz
parents:
diff changeset
17 }
anatofuz
parents:
diff changeset
18 }
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 // WIN64-LABEL: define dso_local void @catch_all()
anatofuz
parents:
diff changeset
21 // WIN64: invoke void @might_throw()
anatofuz
parents:
diff changeset
22 // WIN64-NEXT: to label %[[cont:[^ ]*]] unwind label %[[catchswitch_lpad:[^ ]*]]
anatofuz
parents:
diff changeset
23 //
anatofuz
parents:
diff changeset
24 // WIN64: [[catchswitch_lpad]]
anatofuz
parents:
diff changeset
25 // WIN64: %[[catchswitch:[^ ]*]] = catchswitch within none [label %[[catchpad_lpad:[^ ]*]]] unwind to caller
anatofuz
parents:
diff changeset
26 //
anatofuz
parents:
diff changeset
27 // WIN64: [[catchpad_lpad]]
anatofuz
parents:
diff changeset
28 // WIN64: catchpad within %[[catchswitch]] [i8* null, i32 64, i8* null]
anatofuz
parents:
diff changeset
29 // WIN64: call void @recover()
anatofuz
parents:
diff changeset
30 // WIN64: catchret from %{{.*}} to label %[[catchret:[^ ]*]]
anatofuz
parents:
diff changeset
31 //
anatofuz
parents:
diff changeset
32 // WIN64: [[catchret]]
anatofuz
parents:
diff changeset
33 // WIN64-NEXT: br label %[[ret:[^ ]*]]
anatofuz
parents:
diff changeset
34 //
anatofuz
parents:
diff changeset
35 // WIN64: [[ret]]
anatofuz
parents:
diff changeset
36 // WIN64: ret void
anatofuz
parents:
diff changeset
37 //
anatofuz
parents:
diff changeset
38 // WIN64: [[cont]]
anatofuz
parents:
diff changeset
39 // WIN64: br label %[[ret]]
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 extern "C" void catch_int() {
anatofuz
parents:
diff changeset
42 try {
anatofuz
parents:
diff changeset
43 might_throw();
anatofuz
parents:
diff changeset
44 } catch (int e) {
anatofuz
parents:
diff changeset
45 handle_exception(&e);
anatofuz
parents:
diff changeset
46 }
anatofuz
parents:
diff changeset
47 }
anatofuz
parents:
diff changeset
48
anatofuz
parents:
diff changeset
49 // WIN64-LABEL: define dso_local void @catch_int()
anatofuz
parents:
diff changeset
50 // WIN64: catchpad within %{{[^ ]*}} [%rtti.TypeDescriptor2* @"??_R0H@8", i32 0, i32* %[[e_addr:[^\]]*]]]
anatofuz
parents:
diff changeset
51 //
anatofuz
parents:
diff changeset
52 // The catchpad instruction starts the lifetime of 'e'. Unfortunately, that
anatofuz
parents:
diff changeset
53 // leaves us with nowhere to put lifetime.start, so we don't emit lifetime
anatofuz
parents:
diff changeset
54 // markers for now.
anatofuz
parents:
diff changeset
55 // WIN64-NOT: lifetime.start
anatofuz
parents:
diff changeset
56 //
anatofuz
parents:
diff changeset
57 // WIN64: %[[e_i8:[^ ]*]] = bitcast i32* %[[e_addr]] to i8*
anatofuz
parents:
diff changeset
58 // WIN64-NOT: lifetime.start
anatofuz
parents:
diff changeset
59 // WIN64: call void @handle_exception
anatofuz
parents:
diff changeset
60 // WIN64-SAME: (i8* %[[e_i8]])
anatofuz
parents:
diff changeset
61 // WIN64-NOT: lifetime.end
anatofuz
parents:
diff changeset
62 // WIN64: catchret
anatofuz
parents:
diff changeset
63
anatofuz
parents:
diff changeset
64 extern "C" void catch_int_unnamed() {
anatofuz
parents:
diff changeset
65 try {
anatofuz
parents:
diff changeset
66 might_throw();
anatofuz
parents:
diff changeset
67 } catch (int) {
anatofuz
parents:
diff changeset
68 }
anatofuz
parents:
diff changeset
69 }
anatofuz
parents:
diff changeset
70
anatofuz
parents:
diff changeset
71 // WIN64-LABEL: define dso_local void @catch_int_unnamed()
anatofuz
parents:
diff changeset
72 // WIN64: catchpad within %{{.*}} [%rtti.TypeDescriptor2* @"??_R0H@8", i32 0, i8* null]
anatofuz
parents:
diff changeset
73 // WIN64: catchret
anatofuz
parents:
diff changeset
74
anatofuz
parents:
diff changeset
75 struct A {
anatofuz
parents:
diff changeset
76 A();
anatofuz
parents:
diff changeset
77 A(const A &o);
anatofuz
parents:
diff changeset
78 ~A();
anatofuz
parents:
diff changeset
79 int a;
anatofuz
parents:
diff changeset
80 };
anatofuz
parents:
diff changeset
81
anatofuz
parents:
diff changeset
82 struct B : A {
anatofuz
parents:
diff changeset
83 B();
anatofuz
parents:
diff changeset
84 B(const B &o);
anatofuz
parents:
diff changeset
85 ~B();
anatofuz
parents:
diff changeset
86 int b;
anatofuz
parents:
diff changeset
87 };
anatofuz
parents:
diff changeset
88
anatofuz
parents:
diff changeset
89 extern "C" void catch_a_byval() {
anatofuz
parents:
diff changeset
90 try {
anatofuz
parents:
diff changeset
91 might_throw();
anatofuz
parents:
diff changeset
92 } catch (A e) {
anatofuz
parents:
diff changeset
93 handle_exception(&e);
anatofuz
parents:
diff changeset
94 }
anatofuz
parents:
diff changeset
95 }
anatofuz
parents:
diff changeset
96
anatofuz
parents:
diff changeset
97 // WIN64-LABEL: define dso_local void @catch_a_byval()
anatofuz
parents:
diff changeset
98 // WIN64: %[[e_addr:[^ ]*]] = alloca %struct.A
anatofuz
parents:
diff changeset
99 // WIN64: catchpad within %{{[^ ]*}} [%rtti.TypeDescriptor7* @"??_R0?AUA@@@8", i32 0, %struct.A* %[[e_addr]]]
anatofuz
parents:
diff changeset
100 // WIN64: %[[e_i8:[^ ]*]] = bitcast %struct.A* %[[e_addr]] to i8*
anatofuz
parents:
diff changeset
101 // WIN64: call void @handle_exception(i8* %[[e_i8]])
anatofuz
parents:
diff changeset
102 // WIN64: catchret
anatofuz
parents:
diff changeset
103
anatofuz
parents:
diff changeset
104 extern "C" void catch_a_ref() {
anatofuz
parents:
diff changeset
105 try {
anatofuz
parents:
diff changeset
106 might_throw();
anatofuz
parents:
diff changeset
107 } catch (A &e) {
anatofuz
parents:
diff changeset
108 handle_exception(&e);
anatofuz
parents:
diff changeset
109 }
anatofuz
parents:
diff changeset
110 }
anatofuz
parents:
diff changeset
111
anatofuz
parents:
diff changeset
112 // WIN64-LABEL: define dso_local void @catch_a_ref()
anatofuz
parents:
diff changeset
113 // WIN64: %[[e_addr:[^ ]*]] = alloca %struct.A*
anatofuz
parents:
diff changeset
114 // WIN64: catchpad within %{{[^ ]*}} [%rtti.TypeDescriptor7* @"??_R0?AUA@@@8", i32 8, %struct.A** %[[e_addr]]]
anatofuz
parents:
diff changeset
115 // WIN64: %[[eptr:[^ ]*]] = load %struct.A*, %struct.A** %[[e_addr]]
anatofuz
parents:
diff changeset
116 // WIN64: %[[eptr_i8:[^ ]*]] = bitcast %struct.A* %[[eptr]] to i8*
anatofuz
parents:
diff changeset
117 // WIN64: call void @handle_exception(i8* %[[eptr_i8]])
anatofuz
parents:
diff changeset
118 // WIN64: catchret
anatofuz
parents:
diff changeset
119
anatofuz
parents:
diff changeset
120 extern "C" void fn_with_exc_spec() throw(int) {
anatofuz
parents:
diff changeset
121 might_throw();
anatofuz
parents:
diff changeset
122 }
anatofuz
parents:
diff changeset
123
anatofuz
parents:
diff changeset
124 // WIN64-LABEL: define dso_local void @fn_with_exc_spec()
anatofuz
parents:
diff changeset
125 // WIN64: call void @might_throw()
anatofuz
parents:
diff changeset
126 // WIN64-NEXT: ret void
anatofuz
parents:
diff changeset
127
anatofuz
parents:
diff changeset
128 extern "C" void catch_nested() {
anatofuz
parents:
diff changeset
129 try {
anatofuz
parents:
diff changeset
130 might_throw();
anatofuz
parents:
diff changeset
131 } catch (int) {
anatofuz
parents:
diff changeset
132 try {
anatofuz
parents:
diff changeset
133 might_throw();
anatofuz
parents:
diff changeset
134 } catch (int) {
anatofuz
parents:
diff changeset
135 might_throw();
anatofuz
parents:
diff changeset
136 }
anatofuz
parents:
diff changeset
137 }
anatofuz
parents:
diff changeset
138 }
anatofuz
parents:
diff changeset
139
anatofuz
parents:
diff changeset
140 // WIN64-LABEL: define dso_local void @catch_nested()
anatofuz
parents:
diff changeset
141 // WIN64: invoke void @might_throw()
anatofuz
parents:
diff changeset
142 // WIN64-NEXT: to label %{{.*}} unwind label %[[catchswitch_outer:[^ ]*]]
anatofuz
parents:
diff changeset
143 //
anatofuz
parents:
diff changeset
144 // WIN64: [[catchswitch_outer]]
anatofuz
parents:
diff changeset
145 // WIN64: %[[catchswitch_outer_scope:[^ ]*]] = catchswitch within none [label %[[catch_int_outer:[^ ]*]]] unwind to caller
anatofuz
parents:
diff changeset
146 //
anatofuz
parents:
diff changeset
147 // WIN64: [[catch_int_outer]]
anatofuz
parents:
diff changeset
148 // WIN64: %[[catchpad:[^ ]*]] = catchpad within %[[catchswitch_outer_scope]] [%rtti.TypeDescriptor2* @"??_R0H@8", i32 0, i8* null]
anatofuz
parents:
diff changeset
149 // WIN64: invoke void @might_throw()
anatofuz
parents:
diff changeset
150 // WIN64-NEXT: to label %[[cont2:[^ ]*]] unwind label %[[catchswitch_inner:[^ ]*]]
anatofuz
parents:
diff changeset
151 //
anatofuz
parents:
diff changeset
152 // WIN64: [[catchswitch_inner]]
anatofuz
parents:
diff changeset
153 // WIN64: %[[catchswitch_inner_scope:[^ ]*]] = catchswitch within %[[catchpad]] [label %[[catch_int_inner:[^ ]*]]] unwind to caller
anatofuz
parents:
diff changeset
154 //
anatofuz
parents:
diff changeset
155 // WIN64: [[catch_int_inner]]
anatofuz
parents:
diff changeset
156 // WIN64: catchpad within %[[catchswitch_inner_scope]] [%rtti.TypeDescriptor2* @"??_R0H@8", i32 0, i8* null]
anatofuz
parents:
diff changeset
157 // WIN64-NEXT: call void @might_throw()
anatofuz
parents:
diff changeset
158 // WIN64: catchret {{.*}} to label %[[catchret2:[^ ]*]]
anatofuz
parents:
diff changeset
159 //
anatofuz
parents:
diff changeset
160 // WIN64: [[catchret2]]
anatofuz
parents:
diff changeset
161 // WIN64: catchret {{.*}} to label %[[mainret:[^ ]*]]
anatofuz
parents:
diff changeset
162 //
anatofuz
parents:
diff changeset
163 // WIN64: [[mainret]]
anatofuz
parents:
diff changeset
164 // WIN64: ret void