1 ; RUN: llc < %s | FileCheck %s
3 ; This test was generated from the following code.
28 ; The function calls before the throws were declared as 'noexcept' and are
29 ; just here to make blocks easier to identify in the IR.
31 ; ModuleID = '<stdin>'
32 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
33 target triple = "x86_64-pc-windows-msvc"
35 %rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
36 %eh.CatchHandlerType = type { i32, i8* }
37 %eh.CatchableType = type { i32, i32, i32, i32, i32, i32, i32 }
38 %eh.CatchableTypeArray.1 = type { i32, [1 x i32] }
39 %eh.ThrowInfo = type { i32, i32, i32, i32 }
41 $"\01??_R0H@8" = comdat any
43 $"\01??_R0D@8" = comdat any
45 $"_CT??_R0H@84" = comdat any
51 $"_CT??_R0D@81" = comdat any
57 @"\01??_7type_info@@6B@" = external constant i8*
58 @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
59 @llvm.eh.handlertype.H.0 = private unnamed_addr constant %eh.CatchHandlerType { i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) }, section "llvm.metadata"
60 @"\01??_R0D@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".D\00" }, comdat
61 @llvm.eh.handlertype.D.0 = private unnamed_addr constant %eh.CatchHandlerType { i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0D@8" to i8*) }, section "llvm.metadata"
62 @__ImageBase = external constant i8
63 @"_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
64 @_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
65 @_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
66 @"_CT??_R0D@81" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor2* @"\01??_R0D@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 1, i32 0 }, section ".xdata", comdat
67 @_CTA1D = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableType* @"_CT??_R0D@81" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32)] }, section ".xdata", comdat
68 @_TI1D = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableTypeArray.1* @_CTA1D to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, section ".xdata", comdat
70 ; Function Attrs: nounwind uwtable
71 define void @"\01?test@@YAXXZ"() #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
73 %tmp = alloca i32, align 4
74 %x = alloca i32, align 4
75 %tmp2 = alloca i8, align 1
76 %c = alloca i8, align 1
77 %tmp11 = alloca i32, align 4
78 %x21 = alloca i32, align 4
79 call void @"\01?two@@YAXXZ"() #3
80 store i32 2, i32* %tmp
81 %0 = bitcast i32* %tmp to i8*
82 call void (...) @llvm.localescape(i32* %x, i8* %c, i32* %x21)
83 invoke void @_CxxThrowException(i8* %0, %eh.ThrowInfo* @_TI1H) #5
84 to label %unreachable unwind label %lpad
86 lpad: ; preds = %entry
87 %1 = landingpad { i8*, i32 }
88 catch i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*)
89 catch %eh.CatchHandlerType* @llvm.eh.handlertype.D.0
90 catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0
92 %recover = call i8* (...) @llvm.eh.actions(i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*), i32 0, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch", i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.D.0 to i8*), i32 1, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch1", i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*), i32 2, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch2", i32 1, i8* null, i32 -1, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch3")
93 indirectbr i8* %recover, [label %try.cont, label %try.cont10, label %try.cont22]
95 try.cont: ; preds = %lpad
96 call void @"\01?a@@YAXXZ"() #3
97 store i8 97, i8* %tmp2
98 invoke void @_CxxThrowException(i8* %tmp2, %eh.ThrowInfo* @_TI1D) #5
99 to label %unreachable unwind label %lpad3
101 lpad3: ; preds = %try.cont
102 %2 = landingpad { i8*, i32 }
103 catch %eh.CatchHandlerType* @llvm.eh.handlertype.D.0
104 catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0
106 %recover1 = call i8* (...) @llvm.eh.actions(i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.D.0 to i8*), i32 1, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch1", i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*), i32 2, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch2", i32 1, i8* null, i32 -1, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch3")
107 indirectbr i8* %recover1, [label %try.cont10, label %try.cont22]
109 try.cont10: ; preds = %lpad3, %lpad
110 call void @"\01?one@@YAXXZ"() #3
111 store i32 1, i32* %tmp11
112 %3 = bitcast i32* %tmp11 to i8*
113 invoke void @_CxxThrowException(i8* %3, %eh.ThrowInfo* @_TI1H) #5
114 to label %unreachable unwind label %lpad12
116 lpad12: ; preds = %try.cont10
117 %4 = landingpad { i8*, i32 }
118 catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0
120 %recover2 = call i8* (...) @llvm.eh.actions(i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*), i32 2, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch2", i32 1, i8* null, i32 -1, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch3")
121 indirectbr i8* %recover2, [label %try.cont22]
123 try.cont22: ; preds = %lpad12, %lpad3, %lpad
126 unreachable: ; preds = %try.cont10, %try.cont, %entry
130 ; Function Attrs: nounwind
131 declare void @"\01?two@@YAXXZ"() #1
133 declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
135 declare i32 @__CxxFrameHandler3(...)
137 ; Function Attrs: nounwind readnone
138 declare i32 @llvm.eh.typeid.for(i8*) #2
140 ; Function Attrs: nounwind
141 declare void @llvm.eh.begincatch(i8* nocapture, i8* nocapture) #3
143 ; Function Attrs: nounwind
144 declare void @"\01?catch_two@@YAXXZ"() #1
146 ; Function Attrs: nounwind
147 declare void @llvm.eh.endcatch() #3
149 ; Function Attrs: nounwind
150 declare void @"\01?a@@YAXXZ"() #1
152 ; Function Attrs: nounwind
153 declare void @"\01?catch_a@@YAXXZ"() #1
155 ; Function Attrs: nounwind
156 declare void @"\01?one@@YAXXZ"() #1
158 ; Function Attrs: nounwind
159 declare void @"\01?catch_all@@YAXXZ"() #1
161 ; Function Attrs: nounwind
162 declare void @"\01?catch_one@@YAXXZ"() #1
164 ; Function Attrs: nounwind
165 declare i8* @llvm.eh.actions(...) #3
167 define internal i8* @"\01?test@@YAXXZ.catch"(i8*, i8*) #4 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
169 %x.i8 = call i8* @llvm.localrecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 0)
170 %x = bitcast i8* %x.i8 to i32*
171 %2 = bitcast i32* %x to i8*
172 call void @"\01?catch_two@@YAXXZ"() #3
173 invoke void @llvm.donothing()
174 to label %entry.split unwind label %stub
176 entry.split: ; preds = %entry
177 ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont)
179 stub: ; preds = %entry
180 %3 = landingpad { i8*, i32 }
182 %recover = call i8* (...) @llvm.eh.actions()
186 ; Function Attrs: nounwind readnone
187 declare void @llvm.donothing() #2
189 define internal i8* @"\01?test@@YAXXZ.catch1"(i8*, i8*) #4 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
191 call void @"\01?catch_a@@YAXXZ"() #3
192 invoke void @llvm.donothing()
193 to label %entry.split unwind label %stub
195 entry.split: ; preds = %entry
196 ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont10)
198 stub: ; preds = %entry
199 %2 = landingpad { i8*, i32 }
201 %recover = call i8* (...) @llvm.eh.actions()
205 define internal i8* @"\01?test@@YAXXZ.catch2"(i8*, i8*) #4 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
207 %x21.i8 = call i8* @llvm.localrecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 2)
208 %x21 = bitcast i8* %x21.i8 to i32*
209 %2 = bitcast i32* %x21 to i8*
210 call void @"\01?catch_one@@YAXXZ"() #3
211 invoke void @llvm.donothing()
212 to label %entry.split unwind label %stub
214 entry.split: ; preds = %entry
215 ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont22)
217 stub: ; preds = %entry
218 %3 = landingpad { i8*, i32 }
220 %recover = call i8* (...) @llvm.eh.actions()
224 define internal i8* @"\01?test@@YAXXZ.catch3"(i8*, i8*) #4 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
226 call void @"\01?catch_all@@YAXXZ"() #3
227 invoke void @llvm.donothing()
228 to label %entry.split unwind label %stub
230 entry.split: ; preds = %entry
231 ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont22)
233 stub: ; preds = %entry
234 %2 = landingpad { i8*, i32 }
236 %recover = call i8* (...) @llvm.eh.actions()
240 ; Function Attrs: nounwind
241 declare void @llvm.localescape(...) #3
243 ; Function Attrs: nounwind readnone
244 declare i8* @llvm.localrecover(i8*, i8*, i32) #2
246 attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" "wineh-parent"="
\ 1?test@@YAXXZ" }
247 attributes #1 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
248 attributes #2 = { nounwind readnone }
249 attributes #3 = { nounwind }
250 attributes #4 = { "wineh-parent"="
\ 1?test@@YAXXZ" }
251 attributes #5 = { noreturn }
253 !llvm.module.flags = !{!0}
256 !0 = !{i32 1, !"PIC Level", i32 2}
257 !1 = !{!"clang version 3.7.0 (trunk 236059)"}
259 ; CHECK-LABEL: "$cppxdata$?test@@YAXXZ":
260 ; CHECK-NEXT: .long 429065506
262 ; CHECK-NEXT: .long ("$stateUnwindMap$?test@@YAXXZ")@IMGREL
264 ; CHECK-NEXT: .long ("$tryMap$?test@@YAXXZ")@IMGREL
266 ; CHECK-NEXT: .long ("$ip2state$?test@@YAXXZ")@IMGREL
267 ; CHECK-NEXT: .long 40
268 ; CHECK-NEXT: .long 0
269 ; CHECK-NEXT: .long 1
270 ; CHECK: "$stateUnwindMap$?test@@YAXXZ":
271 ; CHECK: "$tryMap$?test@@YAXXZ":
272 ; CHECK: "$handlerMap$0$?test@@YAXXZ":
273 ; CHECK: "$ip2state$?test@@YAXXZ":
274 ; CHECK-NEXT: .long .Lfunc_begin0@IMGREL
275 ; CHECK-NEXT: .long -1
276 ; CHECK-NEXT: .long .Ltmp0@IMGREL
277 ; CHECK-NEXT: .long 2
278 ; CHECK-NEXT: .long .Ltmp3@IMGREL
279 ; CHECK-NEXT: .long 1
280 ; CHECK-NEXT: .long .Ltmp6@IMGREL
281 ; CHECK-NEXT: .long 0
282 ; CHECK-NEXT: .long .Lfunc_begin1@IMGREL
283 ; CHECK-NEXT: .long 3
284 ; CHECK-NEXT: .long .Lfunc_begin2@IMGREL
285 ; CHECK-NEXT: .long 4
286 ; CHECK-NEXT: .long .Lfunc_begin3@IMGREL
287 ; CHECK-NEXT: .long 5
288 ; CHECK-NEXT: .long .Lfunc_begin4@IMGREL
289 ; CHECK-NEXT: .long 6