1 ; RUN: llc < %s | FileCheck %s
3 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-pc-windows-msvc"
6 %rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
7 %eh.CatchableType = type { i32, i32, i32, i32, i32, i32, i32 }
8 %eh.CatchableTypeArray.1 = type { i32, [1 x i32] }
9 %eh.ThrowInfo = type { i32, i32, i32, i32 }
10 %struct.S = type { i8 }
12 $"\01??_DS@@QEAA@XZ" = comdat any
14 $"\01??_R0H@8" = comdat any
16 $"_CT??_R0H@84" = comdat any
22 @"\01??_7type_info@@6B@" = external constant i8*
23 @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
24 @__ImageBase = external constant i8
25 @"_CT??_R0H@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 4, i32 0 }, section ".xdata", comdat
26 @_CTA1H = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableType* @"_CT??_R0H@84" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32)] }, section ".xdata", comdat
27 @_TI1H = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableTypeArray.1* @_CTA1H to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, section ".xdata", comdat
30 ; CHECK-LABEL: "?test1@@YAXXZ":
31 ; CHECK: .seh_handlerdata
32 ; CHECK-NEXT: .long ("$cppxdata$?test1@@YAXXZ")@IMGREL
33 ; CHECK-NEXT:"$cppxdata$?test1@@YAXXZ":
34 ; CHECK-NEXT: .long 429065506
36 ; CHECK-NEXT: .long ("$stateUnwindMap$?test1@@YAXXZ")@IMGREL
40 ; CHECK-NEXT: .long ("$ip2state$?test1@@YAXXZ")@IMGREL
41 ; CHECK-NEXT: .long 32
44 ; CHECK-NEXT:"$stateUnwindMap$?test1@@YAXXZ":
45 ; CHECK-NEXT: .long -1
46 ; CHECK-NEXT: .long "?test1@@YAXXZ.cleanup"@IMGREL
47 ; CHECK-NEXT:"$ip2state$?test1@@YAXXZ":
48 ; CHECK-NEXT: .long .Ltmp0@IMGREL
51 define void @"\01?test1@@YAXXZ"() #0 {
53 %unwindhelp = alloca i64
54 %tmp = alloca i32, align 4
55 %exn.slot = alloca i8*
56 %ehselector.slot = alloca i32
57 store i32 0, i32* %tmp
58 %0 = bitcast i32* %tmp to i8*
59 call void (...) @llvm.frameescape()
60 store volatile i64 -2, i64* %unwindhelp
61 %1 = bitcast i64* %unwindhelp to i8*
62 call void @llvm.eh.unwindhelp(i8* %1)
63 invoke void @_CxxThrowException(i8* %0, %eh.ThrowInfo* @_TI1H) #8
64 to label %unreachable unwind label %lpad1
66 lpad1: ; preds = %entry
67 %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
69 %recover = call i8* (...) @llvm.eh.actions(i32 0, void (i8*, i8*)* @"\01?test1@@YAXXZ.cleanup")
70 indirectbr i8* %recover, []
72 unreachable: ; preds = %entry
76 declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
78 declare i32 @__CxxFrameHandler3(...)
80 ; Function Attrs: nounwind
81 define linkonce_odr void @"\01??_DS@@QEAA@XZ"(%struct.S* %this) unnamed_addr #1 comdat align 2 {
83 %this.addr = alloca %struct.S*, align 8
84 store %struct.S* %this, %struct.S** %this.addr, align 8
85 %this1 = load %struct.S*, %struct.S** %this.addr
86 call void @"\01??1S@@QEAA@XZ"(%struct.S* %this1) #4
90 ; CHECK-LABEL: "?test2@@YAX_N@Z":
91 ; CHECK: .seh_handlerdata
92 ; CHECK-NEXT: .long ("$cppxdata$?test2@@YAX_N@Z")@IMGREL
93 ; CHECK-NEXT:"$cppxdata$?test2@@YAX_N@Z":
94 ; CHECK-NEXT: .long 429065506
96 ; CHECK-NEXT: .long ("$stateUnwindMap$?test2@@YAX_N@Z")@IMGREL
100 ; CHECK-NEXT: .long ("$ip2state$?test2@@YAX_N@Z")@IMGREL
101 ; CHECK-NEXT: .long 40
102 ; CHECK-NEXT: .long 0
103 ; CHECK-NEXT: .long 1
104 ; CHECK-NEXT:"$stateUnwindMap$?test2@@YAX_N@Z":
105 ; CHECK-NEXT: .long -1
106 ; CHECK-NEXT: .long "?test2@@YAX_N@Z.cleanup"@IMGREL
107 ; CHECK-NEXT: .long 0
108 ; CHECK-NEXT: .long "?test2@@YAX_N@Z.cleanup1"@IMGREL
109 ; CHECK-NEXT:"$ip2state$?test2@@YAX_N@Z":
110 ; CHECK-NEXT: .long .Lfunc_begin1@IMGREL
111 ; CHECK-NEXT: .long -1
112 ; CHECK-NEXT: .long .Ltmp7@IMGREL
113 ; CHECK-NEXT: .long 0
114 ; CHECK-NEXT: .long .Ltmp9@IMGREL
115 ; CHECK-NEXT: .long 1
116 ; CHECK-NEXT: .long .Ltmp12@IMGREL
117 ; CHECK-NEXT: .long 0
119 define void @"\01?test2@@YAX_N@Z"(i1 zeroext %b) #2 {
120 %b.addr = alloca i8, align 1
121 %s = alloca %struct.S, align 1
122 %exn.slot = alloca i8*
123 %ehselector.slot = alloca i32
124 %s1 = alloca %struct.S, align 1
125 %frombool = zext i1 %b to i8
126 store i8 %frombool, i8* %b.addr, align 1
127 call void (...) @llvm.frameescape(%struct.S* %s, %struct.S* %s1)
128 call void @"\01?may_throw@@YAXXZ"()
129 invoke void @"\01?may_throw@@YAXXZ"()
130 to label %invoke.cont unwind label %lpad1
132 invoke.cont: ; preds = %entry
133 %1 = load i8, i8* %b.addr, align 1
134 %tobool = trunc i8 %1 to i1
135 br i1 %tobool, label %if.then, label %if.else
137 if.then: ; preds = %invoke.cont
138 invoke void @"\01?may_throw@@YAXXZ"()
139 to label %invoke.cont3 unwind label %lpad3
141 invoke.cont3: ; preds = %if.then
142 call void @"\01??_DS@@QEAA@XZ"(%struct.S* %s1) #4
145 lpad1: ; preds = %entry, %if.end
146 %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
148 %recover = call i8* (...) @llvm.eh.actions(i32 0, void (i8*, i8*)* @"\01?test2@@YAX_N@Z.cleanup")
149 indirectbr i8* %recover, []
151 lpad3: ; preds = %if.then
152 %3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
154 %recover4 = call i8* (...) @llvm.eh.actions(i32 0, void (i8*, i8*)* @"\01?test2@@YAX_N@Z.cleanup1", i32 0, void (i8*, i8*)* @"\01?test2@@YAX_N@Z.cleanup")
155 indirectbr i8* %recover4, []
157 if.else: ; preds = %invoke.cont
158 call void @"\01?dont_throw@@YAXXZ"() #4
161 if.end: ; preds = %if.else, %invoke.cont3
162 invoke void @"\01?may_throw@@YAXXZ"()
163 to label %invoke.cont4 unwind label %lpad1
165 invoke.cont4: ; preds = %if.end
166 call void @"\01??_DS@@QEAA@XZ"(%struct.S* %s) #4
170 declare void @"\01?may_throw@@YAXXZ"() #3
172 ; Function Attrs: nounwind
173 declare void @"\01?dont_throw@@YAXXZ"() #1
175 ; Function Attrs: nounwind
176 declare void @"\01??1S@@QEAA@XZ"(%struct.S*) #1
178 ; Function Attrs: nounwind
179 declare i8* @llvm.eh.actions(...) #4
181 define internal void @"\01?test1@@YAXXZ.cleanup"(i8*, i8*) #5 {
183 %s = alloca %struct.S, align 1
184 call void @"\01??_DS@@QEAA@XZ"(%struct.S* %s) #4
188 ; Function Attrs: nounwind
189 declare void @llvm.frameescape(...) #4
191 ; Function Attrs: nounwind readnone
192 declare i8* @llvm.framerecover(i8*, i8*, i32) #6
194 ; Function Attrs: nounwind
195 declare void @llvm.eh.unwindhelp(i8*) #4
197 define internal void @"\01?test2@@YAX_N@Z.cleanup"(i8*, i8*) #7 {
199 %s.i8 = call i8* @llvm.framerecover(i8* bitcast (void (i1)* @"\01?test2@@YAX_N@Z" to i8*), i8* %1, i32 0)
200 %s = bitcast i8* %s.i8 to %struct.S*
201 call void @"\01??_DS@@QEAA@XZ"(%struct.S* %s) #4
202 invoke void @llvm.donothing()
203 to label %entry.split unwind label %stub
205 entry.split: ; preds = %entry
208 stub: ; preds = %entry
209 %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
214 define internal void @"\01?test2@@YAX_N@Z.cleanup1"(i8*, i8*) #7 {
216 %s1.i8 = call i8* @llvm.framerecover(i8* bitcast (void (i1)* @"\01?test2@@YAX_N@Z" to i8*), i8* %1, i32 1)
217 %s1 = bitcast i8* %s1.i8 to %struct.S*
218 call void @"\01??_DS@@QEAA@XZ"(%struct.S* %s1) #4
219 invoke void @llvm.donothing()
220 to label %entry.split unwind label %stub
222 entry.split: ; preds = %entry
225 stub: ; preds = %entry
226 %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
231 declare void @llvm.donothing()
233 attributes #0 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" "wineh-parent"="
\ 1?test1@@YAXXZ" }
234 attributes #1 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" }
235 attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" "wineh-parent"="
\ 1?test2@@YAX_N@Z" }
236 attributes #3 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" }
237 attributes #4 = { nounwind }
238 attributes #5 = { "wineh-parent"="
\ 1?test1@@YAXXZ" }
239 attributes #6 = { nounwind readnone }
240 attributes #7 = { "wineh-parent"="
\ 1?test2@@YAX_N@Z" }
241 attributes #8 = { noreturn }