• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s
2
3declare void @may_throw_or_crash()
4declare i32 @_except_handler3(...)
5declare i32 @_except_handler4(...)
6declare i32 @__CxxFrameHandler3(...)
7declare void @llvm.eh.begincatch(i8*, i8*)
8declare void @llvm.eh.endcatch()
9declare i32 @llvm.eh.typeid.for(i8*)
10
11define internal i32 @catchall_filt() {
12  ret i32 1
13}
14
15define void @use_except_handler3() personality i32 (...)* @_except_handler3 {
16entry:
17  invoke void @may_throw_or_crash()
18      to label %cont unwind label %lpad
19cont:
20  ret void
21lpad:
22  %cs = catchswitch within none [label %catch] unwind to caller
23catch:
24  %p = catchpad within %cs [i8* bitcast (i32 ()* @catchall_filt to i8*)]
25  catchret from %p to label %cont
26}
27
28; CHECK-LABEL: _use_except_handler3:
29; CHECK: pushl %ebp
30; CHECK: movl %esp, %ebp
31; CHECK: pushl %ebx
32; CHECK: pushl %edi
33; CHECK: pushl %esi
34; CHECK: subl ${{[0-9]+}}, %esp
35; CHECK: movl $-1, -16(%ebp)
36; CHECK: movl $L__ehtable$use_except_handler3, -20(%ebp)
37; CHECK: leal -28(%ebp), %[[node:[^ ,]*]]
38; CHECK: movl $__except_handler3, -24(%ebp)
39; CHECK: movl %fs:0, %[[next:[^ ,]*]]
40; CHECK: movl %[[next]], -28(%ebp)
41; CHECK: movl %[[node]], %fs:0
42; CHECK: calll _may_throw_or_crash
43; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
44; CHECK: movl %[[next]], %fs:0
45; CHECK: retl
46; CHECK: LBB1_2: # %catch{{$}}
47
48; CHECK: .section .xdata,"dr"
49; CHECK-LABEL: L__ehtable$use_except_handler3:
50; CHECK-NEXT:  .long   -1
51; CHECK-NEXT:  .long   _catchall_filt
52; CHECK-NEXT:  .long   LBB1_2
53
54define void @use_except_handler4() personality i32 (...)* @_except_handler4 {
55entry:
56  invoke void @may_throw_or_crash()
57      to label %cont unwind label %lpad
58cont:
59  ret void
60lpad:
61  %cs = catchswitch within none [label %catch] unwind to caller
62catch:
63  %p = catchpad within %cs [i8* bitcast (i32 ()* @catchall_filt to i8*)]
64  catchret from %p to label %cont
65}
66
67; CHECK-LABEL: _use_except_handler4:
68; CHECK: pushl %ebp
69; CHECK: movl %esp, %ebp
70; CHECK: subl ${{[0-9]+}}, %esp
71; CHECK: movl %esp, -36(%ebp)
72; CHECK: movl $-2, -16(%ebp)
73; CHECK: movl $L__ehtable$use_except_handler4, %[[lsda:[^ ,]*]]
74; CHECK: xorl ___security_cookie, %[[lsda]]
75; CHECK: movl %[[lsda]], -20(%ebp)
76; CHECK: leal -28(%ebp), %[[node:[^ ,]*]]
77; CHECK: movl $__except_handler4, -24(%ebp)
78; CHECK: movl %fs:0, %[[next:[^ ,]*]]
79; CHECK: movl %[[next]], -28(%ebp)
80; CHECK: movl %[[node]], %fs:0
81; CHECK: calll _may_throw_or_crash
82; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
83; CHECK: movl %[[next]], %fs:0
84; CHECK: retl
85; CHECK: LBB2_2: # %catch{{$}}
86
87; CHECK: .section .xdata,"dr"
88; CHECK-LABEL: L__ehtable$use_except_handler4:
89; CHECK-NEXT:  .long   -2
90; CHECK-NEXT:  .long   0
91; CHECK-NEXT:  .long   -40
92; CHECK-NEXT:  .long   0
93; CHECK-NEXT:  .long   -2
94; CHECK-NEXT:  .long   _catchall_filt
95; CHECK-NEXT:  .long   LBB2_2
96
97define void @use_except_handler4_ssp() sspstrong personality i32 (...)* @_except_handler4 {
98entry:
99  invoke void @may_throw_or_crash()
100      to label %cont unwind label %lpad
101cont:
102  ret void
103lpad:
104  %cs = catchswitch within none [label %catch] unwind to caller
105catch:
106  %p = catchpad within %cs [i8* bitcast (i32 ()* @catchall_filt to i8*)]
107  catchret from %p to label %cont
108}
109
110; CHECK-LABEL: _use_except_handler4_ssp:
111; CHECK: pushl %ebp
112; CHECK: movl %esp, %ebp
113; CHECK: subl ${{[0-9]+}}, %esp
114; CHECK: movl %ebp, %[[ehguard:[^ ,]*]]
115; CHECK: movl %esp, -36(%ebp)
116; CHECK: movl $-2, -16(%ebp)
117; CHECK: movl $L__ehtable$use_except_handler4_ssp, %[[lsda:[^ ,]*]]
118; CHECK: xorl ___security_cookie, %[[lsda]]
119; CHECK: movl %[[lsda]], -20(%ebp)
120; CHECK: xorl ___security_cookie, %[[ehguard]]
121; CHECK: movl %[[ehguard]], -40(%ebp)
122; CHECK: leal -28(%ebp), %[[node:[^ ,]*]]
123; CHECK: movl $__except_handler4, -24(%ebp)
124; CHECK: movl %fs:0, %[[next:[^ ,]*]]
125; CHECK: movl %[[next]], -28(%ebp)
126; CHECK: movl %[[node]], %fs:0
127; CHECK: calll _may_throw_or_crash
128; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
129; CHECK: movl %[[next]], %fs:0
130; CHECK: retl
131; CHECK: [[catch:[^ ,]*]]: # %catch{{$}}
132
133; CHECK: .section .xdata,"dr"
134; CHECK-LABEL: L__ehtable$use_except_handler4_ssp:
135; CHECK-NEXT:  .long   -2
136; CHECK-NEXT:  .long   0
137; CHECK-NEXT:  .long   -40
138; CHECK-NEXT:  .long   0
139; CHECK-NEXT:  .long   -2
140; CHECK-NEXT:  .long   _catchall_filt
141; CHECK-NEXT:  .long   [[catch]]
142
143define void @use_CxxFrameHandler3() personality i32 (...)* @__CxxFrameHandler3 {
144  invoke void @may_throw_or_crash()
145      to label %cont unwind label %catchall
146cont:
147  ret void
148
149catchall:
150  %cs = catchswitch within none [label %catch] unwind to caller
151catch:
152  %p = catchpad within %cs [i8* null, i32 64, i8* null]
153  catchret from %p to label %cont
154}
155
156; CHECK-LABEL: _use_CxxFrameHandler3:
157; CHECK: pushl %ebp
158; CHECK: movl %esp, %ebp
159; CHECK: subl ${{[0-9]+}}, %esp
160; CHECK: movl %esp, -28(%ebp)
161; CHECK: movl $-1, -16(%ebp)
162; CHECK: leal -24(%ebp), %[[node:[^ ,]*]]
163; CHECK: movl $___ehhandler$use_CxxFrameHandler3, -20(%ebp)
164; CHECK: movl %fs:0, %[[next:[^ ,]*]]
165; CHECK: movl %[[next]], -24(%ebp)
166; CHECK: movl %[[node]], %fs:0
167; CHECK: movl $0, -16(%ebp)
168; CHECK: calll _may_throw_or_crash
169; CHECK: movl -24(%ebp), %[[next:[^ ,]*]]
170; CHECK: movl %[[next]], %fs:0
171; CHECK: retl
172
173; CHECK: .section .xdata,"dr"
174; CHECK: .p2align 2
175; CHECK-LABEL: L__ehtable$use_CxxFrameHandler3:
176; CHECK-NEXT:  .long   429065506
177; CHECK-NEXT:  .long   2
178; CHECK-NEXT:  .long   ($stateUnwindMap$use_CxxFrameHandler3)
179; CHECK-NEXT:  .long   1
180; CHECK-NEXT:  .long   ($tryMap$use_CxxFrameHandler3)
181; CHECK-NEXT:  .long   0
182; CHECK-NEXT:  .long   0
183; CHECK-NEXT:  .long   0
184; CHECK-NEXT:  .long   1
185
186; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3:
187; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax
188; CHECK: jmp  ___CxxFrameHandler3 # TAILCALL
189
190; CHECK: .safeseh __except_handler3
191; CHECK: .safeseh __except_handler4
192; CHECK: .safeseh ___ehhandler$use_CxxFrameHandler3
193