[Codegen] Adjust saturation test. NFC.
[llvm-core.git] / test / CodeGen / X86 / funclet-layout.ll
blob72f60ea72d43d271eb1cffccad566d2c527be1a6
1 ; RUN: llc -mtriple=x86_64-windows-msvc < %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 %eh.ThrowInfo = type { i32, i32, i32, i32 }
7 %rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
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" }
12 declare void @llvm.trap()
14 define void @test1(i1 %B) personality i32 (...)* @__CxxFrameHandler3 {
15 entry:
16   invoke void @g()
17           to label %unreachable unwind label %catch.dispatch
19 catch.dispatch:
20   %cs1 = catchswitch within none [label %catch] unwind to caller
22 catch:
23   %cp = catchpad within %cs1 [i8* null, i32 64, i8* null]
24   br label %catch.loop
26 catch.loop:
27   br i1 %B, label %catchret, label %catch.loop
29 catchret:
30   catchret from %cp to label %try.cont
32 try.cont:
33   ret void
35 unreachable:
36   call void @llvm.trap()
37   unreachable
40 ; CHECK-LABEL: test1:
42 ; The entry funclet contains %entry and %try.cont
43 ; CHECK: # %entry
44 ; CHECK: # %try.cont
45 ; CHECK: retq
47 ; The catch funclet contains %catch and %catchret
48 ; CHECK: # %catch{{$}}
49 ; CHECK: # %catchret
50 ; CHECK: retq
52 declare void @g()
55 define i32 @test2(i1 %B) personality i32 (...)* @__CxxFrameHandler3 {
56 entry:
57   invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1
58           to label %unreachable unwind label %catch.dispatch
60 catch.dispatch:                                   ; preds = %entry
61   %cs1 = catchswitch within none [label %catch] unwind to caller
63 catch:                                            ; preds = %catch.dispatch
64   %0 = catchpad within %cs1 [i8* null, i32 64, i8* null]
65   invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1 ["funclet"(token %0)]
66           to label %unreachable unwind label %catch.dispatch.1
68 catch.dispatch.1:                                 ; preds = %catch
69   %cs2 = catchswitch within %0 [label %catch.3] unwind to caller
71 catch.3:                                          ; preds = %catch.dispatch.1
72   %1 = catchpad within %cs2 [i8* null, i32 64, i8* null]
73   catchret from %1 to label %try.cont
75 try.cont:                                         ; preds = %catch.3
76   catchret from %0 to label %try.cont.5
78 try.cont.5:                                       ; preds = %try.cont
79   ret i32 0
81 unreachable:                                      ; preds = %catch, %entry
82   call void @llvm.trap()
83   unreachable
86 ; CHECK-LABEL: test2:
88 ; The parent function contains %entry and %try.cont.5
89 ; CHECK: .seh_proc
90 ; CHECK: # %entry
91 ; CHECK: # %try.cont.5
92 ; CHECK: retq
94 ; The inner catch funclet contains %catch.3
95 ; CHECK: .seh_proc
96 ; CHECK: # %catch.3{{$}}
97 ; CHECK: retq
99 ; The outer catch funclet contains %catch
100 ; CHECK: .seh_proc
101 ; CHECK: # %catch{{$}}
102 ; CHECK: callq _CxxThrowException
103 ; CHECK: # %unreachable
104 ; CHECK: ud2
107 define void @test3(i1 %V) #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
108 entry:
109   invoke void @g()
110           to label %try.cont unwind label %catch.dispatch
112 catch.dispatch:                                   ; preds = %entry
113   %cs1 = catchswitch within none [label %catch.2] unwind label %catch.dispatch.1
115 catch.2:                                          ; preds = %catch.dispatch
116   %0 = catchpad within %cs1 [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
117   tail call void @exit(i32 0) #2 [ "funclet"(token %0) ]
118   unreachable
120 catch.dispatch.1:                                 ; preds = %catch.dispatch
121   %cs2 = catchswitch within none [label %catch] unwind to caller
123 catch:                                            ; preds = %catch.dispatch.1
124   %1 = catchpad within %cs2 [i8* null, i32 64, i8* null]
125   tail call void @exit(i32 0) #2 [ "funclet"(token %1) ]
126   unreachable
128 try.cont:                                         ; preds = %entry
129   br i1 %V, label %exit_one, label %exit_two
131 exit_one:
132   tail call void @g()
133   call void @llvm.trap()
134   unreachable
136 exit_two:
137   tail call void @g()
138   call void @llvm.trap()
139   unreachable
142 ; CHECK-LABEL: test3:
144 ; The entry funclet contains %entry and %try.cont
145 ; CHECK: # %entry
146 ; CHECK: # %try.cont
147 ; CHECK: callq g
148 ; CHECK-NOT: # exit_one
149 ; CHECK-NOT: # exit_two
150 ; CHECK: ud2
152 ; The catch(...) funclet contains %catch.2
153 ; CHECK: # %catch.2{{$}}
154 ; CHECK: callq exit
155 ; CHECK-NEXT: int3
157 ; The catch(int) funclet contains %catch
158 ; CHECK: # %catch{{$}}
159 ; CHECK: callq exit
160 ; CHECK-NEXT: int3
162 declare void @exit(i32) noreturn nounwind
163 declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
164 declare i32 @__CxxFrameHandler3(...)