blob: 937b216edbdfaa771472f583157f1ef610b44f6d [file] [log] [blame]
David Majnemera225a192015-03-31 22:35:44 +00001; RUN: llc < %s | FileCheck %s
2
3target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-pc-windows-msvc"
5
6; This test case is equivalent to:
7; void f() {
8; try {
9; try {
10; may_throw();
11; } catch (int &) {
12; may_throw();
13; }
14; may_throw();
15; } catch (double) {
16; }
17; }
18
19
20%rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
21%eh.CatchHandlerType = type { i32, i8* }
22
23$"\01??_R0N@8" = comdat any
24
25$"\01??_R0H@8" = comdat any
26
27@"\01??_7type_info@@6B@" = external constant i8*
28@"\01??_R0N@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".N\00" }, comdat
29@llvm.eh.handlertype.N.0 = private unnamed_addr constant %eh.CatchHandlerType { i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0N@8" to i8*) }, section "llvm.metadata"
30@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
31@llvm.eh.handlertype.H.8 = private unnamed_addr constant %eh.CatchHandlerType { i32 8, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) }, section "llvm.metadata"
32
33define internal i8* @"\01?f@@YAXXZ.catch"(i8*, i8*) #4 {
34entry:
35 %.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?f@@YAXXZ" to i8*), i8* %1, i32 0)
David Majnemer33370642015-04-03 22:32:26 +000036 %bc2 = bitcast i8* %.i8 to i32**
37 %bc3 = bitcast i32** %bc2 to i8*
David Majnemera225a192015-03-31 22:35:44 +000038 invoke void @"\01?may_throw@@YAXXZ"()
39 to label %invoke.cont2 unwind label %lpad1
40
41invoke.cont2: ; preds = %entry
42 ret i8* blockaddress(@"\01?f@@YAXXZ", %try.cont)
43
44lpad1: ; preds = %entry
David Majnemer33370642015-04-03 22:32:26 +000045 %lp4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
David Majnemera225a192015-03-31 22:35:44 +000046 cleanup
47 catch %eh.CatchHandlerType* @llvm.eh.handlertype.N.0
Andrew Kayloraa92ab02015-04-03 19:37:50 +000048 %recover = call i8* (...)* @llvm.eh.actions(i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.N.0 to i8*), i32 1, i8* (i8*, i8*)* @"\01?f@@YAXXZ.catch1")
David Majnemera225a192015-03-31 22:35:44 +000049 indirectbr i8* %recover, [label %invoke.cont2]
50}
51
52; CHECK-LABEL: "?f@@YAXXZ.catch":
David Majnemera225a192015-03-31 22:35:44 +000053; CHECK: .seh_handlerdata
54; CHECK: .long ("$cppxdata$?f@@YAXXZ")@IMGREL
55
56
57define internal i8* @"\01?f@@YAXXZ.catch1"(i8*, i8*) #4 {
58entry:
59 %.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?f@@YAXXZ" to i8*), i8* %1, i32 1)
60 %2 = bitcast i8* %.i8 to double*
61 %3 = bitcast double* %2 to i8*
62 invoke void (...)* @llvm.donothing()
63 to label %done unwind label %lpad
64
65done:
66 ret i8* blockaddress(@"\01?f@@YAXXZ", %try.cont8)
67
68lpad: ; preds = %entry
69 %4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
70 cleanup
71 unreachable
72}
73
74; CHECK-LABEL: "?f@@YAXXZ.catch1":
75; CHECK: ".L?f@@YAXXZ.catch1$parent_frame_offset" = 16
76; CHECK: movq %rdx, 16(%rsp)
77; CHECK: .seh_handlerdata
78; CHECK: .long ("$cppxdata$?f@@YAXXZ")@IMGREL
79
80define void @"\01?f@@YAXXZ"() #0 {
81entry:
David Majnemera225a192015-03-31 22:35:44 +000082 %exn.slot = alloca i8*
83 %ehselector.slot = alloca i32
84 %0 = alloca i32*, align 8
85 %1 = alloca double, align 8
86 call void (...)* @llvm.frameescape(i32** %0, double* %1)
David Majnemera225a192015-03-31 22:35:44 +000087 invoke void @"\01?may_throw@@YAXXZ"()
88 to label %invoke.cont unwind label %lpad2
89
90invoke.cont: ; preds = %entry
91 br label %try.cont
92
93lpad2: ; preds = %entry
David Majnemer33370642015-04-03 22:32:26 +000094 %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
David Majnemera225a192015-03-31 22:35:44 +000095 catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.8
96 catch %eh.CatchHandlerType* @llvm.eh.handlertype.N.0
Andrew Kayloraa92ab02015-04-03 19:37:50 +000097 %recover = call i8* (...)* @llvm.eh.actions(i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.8 to i8*), i32 0, i8* (i8*, i8*)* @"\01?f@@YAXXZ.catch", i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.N.0 to i8*), i32 1, i8* (i8*, i8*)* @"\01?f@@YAXXZ.catch1")
David Majnemera225a192015-03-31 22:35:44 +000098 indirectbr i8* %recover, [label %try.cont, label %try.cont8]
99
100try.cont: ; preds = %lpad2, %invoke.cont
101 invoke void @"\01?may_throw@@YAXXZ"()
102 to label %try.cont8 unwind label %lpad1
103
104lpad1:
David Majnemer33370642015-04-03 22:32:26 +0000105 %3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
David Majnemera225a192015-03-31 22:35:44 +0000106 catch %eh.CatchHandlerType* @llvm.eh.handlertype.N.0
Andrew Kayloraa92ab02015-04-03 19:37:50 +0000107 %recover2 = call i8* (...)* @llvm.eh.actions(i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.N.0 to i8*), i32 1, i8* (i8*, i8*)* @"\01?f@@YAXXZ.catch1")
David Majnemera225a192015-03-31 22:35:44 +0000108 indirectbr i8* %recover2, [label %try.cont8]
109
110try.cont8: ; preds = %lpad2, %try.cont
111 ret void
112}
113
114; CHECK-LABEL: "?f@@YAXXZ":
115; CHECK: .seh_handlerdata
116; CHECK-NEXT: .long ("$cppxdata$?f@@YAXXZ")@IMGREL
117; CHECK-NEXT:"$cppxdata$?f@@YAXXZ":
118; CHECK-NEXT: .long 429065506
119; CHECK-NEXT: .long 4
120; CHECK-NEXT: .long ("$stateUnwindMap$?f@@YAXXZ")@IMGREL
121; CHECK-NEXT: .long 2
122; CHECK-NEXT: .long ("$tryMap$?f@@YAXXZ")@IMGREL
123; CHECK-NEXT: .long 3
124; CHECK-NEXT: .long ("$ip2state$?f@@YAXXZ")@IMGREL
David Majnemer33370642015-04-03 22:32:26 +0000125; CHECK-NEXT: .long 32
David Majnemera225a192015-03-31 22:35:44 +0000126; CHECK-NEXT: .long 0
127; CHECK-NEXT: .long 1
128; CHECK-NEXT:"$stateUnwindMap$?f@@YAXXZ":
129; CHECK-NEXT: .long -1
130; CHECK-NEXT: .long 0
131; CHECK-NEXT: .long 0
132; CHECK-NEXT: .long 0
133; CHECK-NEXT: .long 0
134; CHECK-NEXT: .long 0
135; CHECK-NEXT: .long -1
136; CHECK-NEXT: .long 0
137; CHECK-NEXT:"$tryMap$?f@@YAXXZ":
138; CHECK-NEXT: .long 1
139; CHECK-NEXT: .long 1
140; CHECK-NEXT: .long 2147483647
141; CHECK-NEXT: .long 1
142; CHECK-NEXT: .long ("$handlerMap$0$?f@@YAXXZ")@IMGREL
143; CHECK-NEXT: .long 0
144; CHECK-NEXT: .long 2
145; CHECK-NEXT: .long 2147483647
146; CHECK-NEXT: .long 1
147; CHECK-NEXT: .long ("$handlerMap$1$?f@@YAXXZ")@IMGREL
148; CHECK-NEXT:"$handlerMap$0$?f@@YAXXZ":
149; CHECK-NEXT: .long 8
150; CHECK-NEXT: .long "??_R0H@8"@IMGREL
David Majnemer69132a72015-04-03 22:49:05 +0000151; CHECK-NEXT: .long ".L?f@@YAXXZ$frame_escape_0"
David Majnemera225a192015-03-31 22:35:44 +0000152; CHECK-NEXT: .long "?f@@YAXXZ.catch"@IMGREL
153; CHECK-NEXT: .long ".L?f@@YAXXZ.catch$parent_frame_offset"
154; CHECK-NEXT:"$handlerMap$1$?f@@YAXXZ":
155; CHECK-NEXT: .long 0
156; CHECK-NEXT: .long "??_R0N@8"@IMGREL
David Majnemer69132a72015-04-03 22:49:05 +0000157; CHECK-NEXT: .long ".L?f@@YAXXZ$frame_escape_1"
David Majnemera225a192015-03-31 22:35:44 +0000158; CHECK-NEXT: .long "?f@@YAXXZ.catch1"@IMGREL
159; CHECK-NEXT: .long ".L?f@@YAXXZ.catch1$parent_frame_offset"
160; CHECK-NEXT:"$ip2state$?f@@YAXXZ":
161; CHECK-NEXT: .long .Ltmp0@IMGREL
162; CHECK-NEXT: .long 0
163; CHECK-NEXT: .long .Ltmp13@IMGREL
164; CHECK-NEXT: .long 1
165; CHECK-NEXT: .long .Ltmp16@IMGREL
166; CHECK-NEXT: .long 0
167
168
169declare void @"\01?may_throw@@YAXXZ"() #1
170
171declare i32 @__CxxFrameHandler3(...)
172
173; Function Attrs: nounwind readnone
174declare i32 @llvm.eh.typeid.for(i8*) #2
175
176; Function Attrs: nounwind
177declare void @llvm.eh.begincatch(i8* nocapture, i8* nocapture) #3
178
179; Function Attrs: nounwind
180declare void @llvm.eh.endcatch() #3
181
182; Function Attrs: nounwind
183declare i8* @llvm.eh.actions(...) #3
184
185; Function Attrs: nounwind
186declare void @llvm.frameescape(...) #3
187
188; Function Attrs: nounwind readnone
189declare i8* @llvm.framerecover(i8*, i8*, i32) #2
190
David Majnemera225a192015-03-31 22:35:44 +0000191declare void @llvm.donothing(...)
192
193attributes #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"="?f@@YAXXZ" }
194attributes #1 = { "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" }
195attributes #2 = { nounwind readnone }
196attributes #3 = { nounwind }
197attributes #4 = { "wineh-parent"="?f@@YAXXZ" }