ffd4b49b688d9483db7ac62c3af0b7679b51e05a
[oota-llvm.git] / test / CodeGen / X86 / funclet-layout.ll
1 ; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
2
3 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-pc-windows-msvc"
5
6 %eh.ThrowInfo = type { i32, i32, i32, i32 }
7 %rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
8
9 @"\01??_7type_info@@6B@" = external constant i8*
10 @"\01??_R0H@8" = internal global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }
11
12 define void @test1(i1 %B) personality i32 (...)* @__CxxFrameHandler3 {
13 entry:
14   invoke void @g()
15           to label %unreachable unwind label %catch.dispatch
16
17 catch.dispatch:
18   %cp = catchpad [i8* null, i32 64, i8* null]
19           to label %catch unwind label %catchendblock
20
21 catch:
22   br i1 %B, label %catchret, label %catch
23
24 catchret:
25   catchret %cp to label %try.cont
26
27 try.cont:
28   ret void
29
30 catchendblock:
31   catchendpad unwind to caller
32
33 unreachable:
34   unreachable
35 }
36
37 ; CHECK-LABEL: test1:
38
39 ; The entry funclet contains %entry and %try.cont
40 ; CHECK: # %entry
41 ; CHECK: # %try.cont
42 ; CHECK: retq
43
44 ; The catch funclet contains %catch and %catchret
45 ; CHECK: # %catch{{$}}
46 ; CHECK: # %catchret
47 ; CHECK: retq
48
49 declare void @g()
50
51
52 define i32 @test2(i1 %B) personality i32 (...)* @__CxxFrameHandler3 {
53 entry:
54   invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1
55           to label %unreachable unwind label %catch.dispatch
56
57 catch.dispatch:                                   ; preds = %entry
58   %0 = catchpad [i8* null, i32 64, i8* null]
59           to label %catch unwind label %catchendblock
60
61 catch:                                            ; preds = %catch.dispatch
62   invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1
63           to label %unreachable unwind label %catch.dispatch.1
64
65 catch.dispatch.1:                                 ; preds = %catch
66   %1 = catchpad [i8* null, i32 64, i8* null]
67           to label %catch.3 unwind label %catchendblock.2
68
69 catch.3:                                          ; preds = %catch.dispatch.1
70   catchret %1 to label %try.cont
71
72 try.cont:                                         ; preds = %catch.3
73   catchret %0 to label %try.cont.5
74
75 try.cont.5:                                       ; preds = %try.cont
76   ret i32 0
77
78 catchendblock.2:                                  ; preds = %catch.dispatch.1
79   catchendpad unwind label %catchendblock
80
81 catchendblock:                                    ; preds = %catchendblock.2, %catch.dispatch
82   catchendpad unwind to caller
83
84 unreachable:                                      ; preds = %catch, %entry
85   unreachable
86
87 }
88
89 ; CHECK-LABEL: test2:
90
91 ; The entry funclet contains %entry and %try.cont.5
92 ; CHECK: # %entry
93 ; CHECK: # %try.cont.5
94 ; CHECK: retq
95
96 ; The inner catch funclet contains %catch.3
97 ; CHECK: # %catch.3
98 ; CHECK: retq
99
100 ; The outer catch funclet contains %catch and %try.cont
101 ; CHECK: # %catch{{$}}
102 ; CHECK: # %try.cont{{$}}
103 ; CHECK: retq
104
105
106 define void @test3(i1 %V) #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
107 entry:
108   invoke void @g()
109           to label %try.cont unwind label %catch.dispatch
110
111 catch.dispatch:                                   ; preds = %entry
112   %0 = catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
113           to label %catch.2 unwind label %catch.dispatch.1
114
115 catch.2:                                          ; preds = %catch.dispatch
116   tail call void @exit(i32 0) #2
117   unreachable
118
119 catch.dispatch.1:                                 ; preds = %catch.dispatch
120   %1 = catchpad [i8* null, i32 64, i8* null]
121           to label %catch unwind label %catchendblock
122
123 catch:                                            ; preds = %catch.dispatch.1
124   tail call void @exit(i32 0) #2
125   unreachable
126
127 catchendblock:                                    ; preds = %catch.dispatch.1
128   catchendpad unwind to caller
129
130 try.cont:                                         ; preds = %entry
131   br i1 %V, label %exit_one, label %exit_two
132
133 exit_one:
134   tail call void @exit(i32 0)
135   unreachable
136
137 exit_two:
138   tail call void @exit(i32 0)
139   unreachable
140 }
141
142 ; CHECK-LABEL: test3:
143
144 ; The entry funclet contains %entry and %try.cont
145 ; CHECK: # %entry
146 ; CHECK: # %try.cont
147 ; CHECK: callq exit
148 ; CHECK-NOT: # exit_one
149 ; CHECK-NOT: # exit_two
150 ; CHECK: ud2
151
152 ; The catch(int) funclet contains %catch.2
153 ; CHECK: # %catch.2
154 ; CHECK: callq exit
155 ; CHECK: ud2
156
157 ; The catch(...) funclet contains %catch
158 ; CHECK: # %catch{{$}}
159 ; CHECK: callq exit
160 ; CHECK: ud2
161
162 declare void @exit(i32) noreturn nounwind
163 declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
164 declare i32 @__CxxFrameHandler3(...)