blob: a294a075835d1b17c42fe6b1ff0a7a31000e23e1 [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)
36 %2 = bitcast i8* %.i8 to i32**
37 %3 = bitcast i32** %2 to i8*
38 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
45 %4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
46 cleanup
47 catch %eh.CatchHandlerType* @llvm.eh.handlertype.N.0
48 %recover = call i8* (...)* @llvm.eh.actions(i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.N.0 to i8*), double* null, i8* (i8*, i8*)* @"\01?f@@YAXXZ.catch1")
49 indirectbr i8* %recover, [label %invoke.cont2]
50}
51
52; CHECK-LABEL: "?f@@YAXXZ.catch":
53; CHECK: ".L?f@@YAXXZ.catch$parent_frame_offset" = 56
54; CHECK: movq %rdx, 56(%rsp)
55; CHECK: .seh_handlerdata
56; CHECK: .long ("$cppxdata$?f@@YAXXZ")@IMGREL
57
58
59define internal i8* @"\01?f@@YAXXZ.catch1"(i8*, i8*) #4 {
60entry:
61 %.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?f@@YAXXZ" to i8*), i8* %1, i32 1)
62 %2 = bitcast i8* %.i8 to double*
63 %3 = bitcast double* %2 to i8*
64 invoke void (...)* @llvm.donothing()
65 to label %done unwind label %lpad
66
67done:
68 ret i8* blockaddress(@"\01?f@@YAXXZ", %try.cont8)
69
70lpad: ; preds = %entry
71 %4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
72 cleanup
73 unreachable
74}
75
76; CHECK-LABEL: "?f@@YAXXZ.catch1":
77; CHECK: ".L?f@@YAXXZ.catch1$parent_frame_offset" = 16
78; CHECK: movq %rdx, 16(%rsp)
79; CHECK: .seh_handlerdata
80; CHECK: .long ("$cppxdata$?f@@YAXXZ")@IMGREL
81
82define void @"\01?f@@YAXXZ"() #0 {
83entry:
84 %unwindhelp = alloca i64
85 %exn.slot = alloca i8*
86 %ehselector.slot = alloca i32
87 %0 = alloca i32*, align 8
88 %1 = alloca double, align 8
89 call void (...)* @llvm.frameescape(i32** %0, double* %1)
90 store volatile i64 -2, i64* %unwindhelp
91 %2 = bitcast i64* %unwindhelp to i8*
92 call void @llvm.eh.unwindhelp(i8* %2)
93 invoke void @"\01?may_throw@@YAXXZ"()
94 to label %invoke.cont unwind label %lpad2
95
96invoke.cont: ; preds = %entry
97 br label %try.cont
98
99lpad2: ; preds = %entry
100 %3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
101 catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.8
102 catch %eh.CatchHandlerType* @llvm.eh.handlertype.N.0
103 %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*), double* %1, i8* (i8*, i8*)* @"\01?f@@YAXXZ.catch1")
104 indirectbr i8* %recover, [label %try.cont, label %try.cont8]
105
106try.cont: ; preds = %lpad2, %invoke.cont
107 invoke void @"\01?may_throw@@YAXXZ"()
108 to label %try.cont8 unwind label %lpad1
109
110lpad1:
111 %4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
112 catch %eh.CatchHandlerType* @llvm.eh.handlertype.N.0
113 %recover2 = call i8* (...)* @llvm.eh.actions(i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.N.0 to i8*), double* null, i8* (i8*, i8*)* @"\01?f@@YAXXZ.catch1")
114 indirectbr i8* %recover2, [label %try.cont8]
115
116try.cont8: ; preds = %lpad2, %try.cont
117 ret void
118}
119
120; CHECK-LABEL: "?f@@YAXXZ":
121; CHECK: .seh_handlerdata
122; CHECK-NEXT: .long ("$cppxdata$?f@@YAXXZ")@IMGREL
123; CHECK-NEXT:"$cppxdata$?f@@YAXXZ":
124; CHECK-NEXT: .long 429065506
125; CHECK-NEXT: .long 4
126; CHECK-NEXT: .long ("$stateUnwindMap$?f@@YAXXZ")@IMGREL
127; CHECK-NEXT: .long 2
128; CHECK-NEXT: .long ("$tryMap$?f@@YAXXZ")@IMGREL
129; CHECK-NEXT: .long 3
130; CHECK-NEXT: .long ("$ip2state$?f@@YAXXZ")@IMGREL
131; CHECK-NEXT: .long 64
132; CHECK-NEXT: .long 0
133; CHECK-NEXT: .long 1
134; CHECK-NEXT:"$stateUnwindMap$?f@@YAXXZ":
135; CHECK-NEXT: .long -1
136; CHECK-NEXT: .long 0
137; CHECK-NEXT: .long 0
138; CHECK-NEXT: .long 0
139; CHECK-NEXT: .long 0
140; CHECK-NEXT: .long 0
141; CHECK-NEXT: .long -1
142; CHECK-NEXT: .long 0
143; CHECK-NEXT:"$tryMap$?f@@YAXXZ":
144; CHECK-NEXT: .long 1
145; CHECK-NEXT: .long 1
146; CHECK-NEXT: .long 2147483647
147; CHECK-NEXT: .long 1
148; CHECK-NEXT: .long ("$handlerMap$0$?f@@YAXXZ")@IMGREL
149; CHECK-NEXT: .long 0
150; CHECK-NEXT: .long 2
151; CHECK-NEXT: .long 2147483647
152; CHECK-NEXT: .long 1
153; CHECK-NEXT: .long ("$handlerMap$1$?f@@YAXXZ")@IMGREL
154; CHECK-NEXT:"$handlerMap$0$?f@@YAXXZ":
155; CHECK-NEXT: .long 8
156; CHECK-NEXT: .long "??_R0H@8"@IMGREL
157; CHECK-NEXT: .long 0
158; CHECK-NEXT: .long "?f@@YAXXZ.catch"@IMGREL
159; CHECK-NEXT: .long ".L?f@@YAXXZ.catch$parent_frame_offset"
160; CHECK-NEXT:"$handlerMap$1$?f@@YAXXZ":
161; CHECK-NEXT: .long 0
162; CHECK-NEXT: .long "??_R0N@8"@IMGREL
163; CHECK-NEXT: .long 0
164; CHECK-NEXT: .long "?f@@YAXXZ.catch1"@IMGREL
165; CHECK-NEXT: .long ".L?f@@YAXXZ.catch1$parent_frame_offset"
166; CHECK-NEXT:"$ip2state$?f@@YAXXZ":
167; CHECK-NEXT: .long .Ltmp0@IMGREL
168; CHECK-NEXT: .long 0
169; CHECK-NEXT: .long .Ltmp13@IMGREL
170; CHECK-NEXT: .long 1
171; CHECK-NEXT: .long .Ltmp16@IMGREL
172; CHECK-NEXT: .long 0
173
174
175declare void @"\01?may_throw@@YAXXZ"() #1
176
177declare i32 @__CxxFrameHandler3(...)
178
179; Function Attrs: nounwind readnone
180declare i32 @llvm.eh.typeid.for(i8*) #2
181
182; Function Attrs: nounwind
183declare void @llvm.eh.begincatch(i8* nocapture, i8* nocapture) #3
184
185; Function Attrs: nounwind
186declare void @llvm.eh.endcatch() #3
187
188; Function Attrs: nounwind
189declare i8* @llvm.eh.actions(...) #3
190
191; Function Attrs: nounwind
192declare void @llvm.frameescape(...) #3
193
194; Function Attrs: nounwind readnone
195declare i8* @llvm.framerecover(i8*, i8*, i32) #2
196
197; Function Attrs: nounwind
198declare void @llvm.eh.unwindhelp(i8*) #3
199
200declare void @llvm.donothing(...)
201
202attributes #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" }
203attributes #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" }
204attributes #2 = { nounwind readnone }
205attributes #3 = { nounwind }
206attributes #4 = { "wineh-parent"="?f@@YAXXZ" }