1 ; RUN: opt -mtriple=i686-pc-windows-msvc -S -x86-winehstate < %s | FileCheck %s
3 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
4 target triple = "i686-pc-windows-msvc"
6 %rtti.TypeDescriptor2 = type { ptr, ptr, [3 x i8] }
7 %eh.CatchableType = type { i32, ptr, i32, i32, i32, i32, ptr }
8 %eh.CatchableTypeArray.1 = type { i32, [1 x ptr] }
9 %eh.ThrowInfo = type { i32, ptr, ptr, ptr }
11 $"\01??_R0H@8" = comdat any
13 $"_CT??_R0H@84" = comdat any
19 @"\01??_7type_info@@6B@" = external constant ptr
20 @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { ptr @"\01??_7type_info@@6B@", ptr null, [3 x i8] c".H\00" }, comdat
21 @"_CT??_R0H@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, ptr @"\01??_R0H@8", i32 0, i32 -1, i32 0, i32 4, ptr null }, section ".xdata", comdat
22 @_CTA1H = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x ptr] [ptr @"_CT??_R0H@84"] }, section ".xdata", comdat
23 @_TI1H = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, ptr null, ptr null, ptr @_CTA1H }, section ".xdata", comdat
25 define i32 @main() #0 personality ptr @__CxxFrameHandler3 {
27 %tmp = alloca i32, align 4
30 ; CHECK: call void @g(i32 3)
31 ; CHECK-NEXT: call void @g(i32 4)
32 ; CHECK-NEXT: call void @g(i32 5)
36 store i32 0, ptr %tmp, align 4
38 ; CHECK: invoke void @_CxxThrowException(
39 invoke void @_CxxThrowException(ptr %tmp, ptr nonnull @_TI1H) #1
40 to label %unreachable.for.entry unwind label %catch.dispatch
42 catch.dispatch: ; preds = %entry
43 %cs1 = catchswitch within none [label %catch] unwind to caller
45 catch: ; preds = %catch.dispatch
46 %0 = catchpad within %cs1 [ptr null, i32 u0x40, ptr null]
49 ; CHECK: invoke void @_CxxThrowException(
50 invoke void @_CxxThrowException(ptr null, ptr null) [ "funclet"(token %0) ]
51 to label %unreachable unwind label %catch.dispatch.1
53 catch.dispatch.1: ; preds = %catch
54 %cs2 = catchswitch within %0 [label %catch.3] unwind to caller
55 catch.3: ; preds = %catch.dispatch.1
56 %1 = catchpad within %cs2 [ptr null, i32 u0x40, ptr null]
59 ; CHECK: call void @g(i32 1)
60 ; CHECK-NEXT: call void @g(i32 2)
61 ; CHECK-NEXT: call void @g(i32 3)
65 catchret from %1 to label %try.cont
67 try.cont: ; preds = %catch.3
70 ; CHECK: call void @g(i32 2)
71 ; CHECK-NEXT: call void @g(i32 3)
72 ; CHECK-NEXT: call void @g(i32 4)
78 unreachable: ; preds = %catch
81 unreachable.for.entry: ; preds = %entry
85 define i32 @nopads() #0 personality ptr @__CxxFrameHandler3 {
89 ; CHECK-LABEL: define i32 @nopads()
90 ; CHECK-NEXT: ret i32 0
91 ; CHECK-NOT: __ehhandler$nopads
93 ; CHECK-LABEL: define void @PR25926()
94 define void @PR25926() personality ptr @__CxxFrameHandler3 {
99 ; CHECK: invoke void @_CxxThrowException(
100 invoke void @_CxxThrowException(ptr null, ptr null)
101 to label %unreachable unwind label %catch.dispatch
103 catch.dispatch: ; preds = %entry
104 %0 = catchswitch within none [label %catch] unwind to caller
106 catch: ; preds = %catch.dispatch
107 %1 = catchpad within %0 [ptr null, i32 64, ptr null]
110 ; CHECK: invoke void @_CxxThrowException(
111 invoke void @_CxxThrowException(ptr null, ptr null) [ "funclet"(token %1) ]
112 to label %unreachable1 unwind label %catch.dispatch1
114 catch.dispatch1: ; preds = %catch
115 %2 = catchswitch within %1 [label %catch2] unwind label %ehcleanup
117 catch2: ; preds = %catch.dispatch1
118 %3 = catchpad within %2 [ptr null, i32 64, ptr null]
119 catchret from %3 to label %try.cont
121 try.cont: ; preds = %catch2
124 ; CHECK: call void @dtor()
125 ; CHECK-NEXT: call void @dtor()
126 ; CHECK-NEXT: call void @dtor()
127 call void @dtor() #3 [ "funclet"(token %1) ]
128 call void @dtor() #3 [ "funclet"(token %1) ]
129 call void @dtor() #3 [ "funclet"(token %1) ]
130 catchret from %1 to label %try.cont4
132 try.cont4: ; preds = %try.cont
135 ehcleanup: ; preds = %catch.dispatch1
136 %4 = cleanuppad within %1 []
138 ; CHECK: call void @dtor()
139 call void @dtor() #3 [ "funclet"(token %4) ]
140 cleanupret from %4 unwind to caller
142 unreachable: ; preds = %entry
145 unreachable1: ; preds = %catch
149 ; CHECK-LABEL: define void @required_state_store(
150 define void @required_state_store(i1 zeroext %cond) personality ptr @_except_handler3 {
152 %__exception_code = alloca i32, align 4
153 call void (...) @llvm.localescape(ptr nonnull %__exception_code)
154 ; CHECK: store i32 -1
155 ; CHECK: call void @g(i32 0)
157 br i1 %cond, label %if.then, label %if.end
159 if.then: ; preds = %entry
161 ; CHECK-NEXT: invoke void @g(i32 1)
162 invoke void @g(i32 1)
163 to label %if.end unwind label %catch.dispatch
165 catch.dispatch: ; preds = %if.then
166 %0 = catchswitch within none [label %__except.ret] unwind to caller
168 __except.ret: ; preds = %catch.dispatch
169 %1 = catchpad within %0 [ptr @"\01?filt$0@0@required_state_store@@"]
170 catchret from %1 to label %if.end
172 if.end: ; preds = %if.then, %__except.ret, %entry
173 ; CHECK: store i32 -1
174 ; CHECK-NEXT: call void @dtor()
179 define internal i32 @"\01?filt$0@0@required_state_store@@"() {
181 %0 = tail call ptr @llvm.frameaddress(i32 1)
182 %1 = tail call ptr @llvm.eh.recoverfp(ptr @required_state_store, ptr %0)
183 %2 = tail call ptr @llvm.localrecover(ptr @required_state_store, ptr %1, i32 0)
184 %3 = getelementptr inbounds i8, ptr %0, i32 -20
185 %4 = load ptr, ptr %3, align 4
186 %5 = getelementptr inbounds { ptr, ptr }, ptr %4, i32 0, i32 0
187 %6 = load ptr, ptr %5, align 4
188 %7 = load i32, ptr %6, align 4
189 store i32 %7, ptr %2, align 4
193 declare void @g(i32) #0
197 declare x86_stdcallcc void @_CxxThrowException(ptr, ptr)
199 declare i32 @__CxxFrameHandler3(...)
201 declare ptr @llvm.frameaddress(i32)
203 declare ptr @llvm.eh.recoverfp(ptr, ptr)
205 declare ptr @llvm.localrecover(ptr, ptr, i32)
207 declare void @llvm.localescape(...)
209 declare i32 @_except_handler3(...)
211 attributes #0 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
212 attributes #1 = { noreturn }
216 !0 = !{!"clang version 3.8.0 (trunk 245153) (llvm/trunk 245238)"}