summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/LoopStrengthReduce/funclet.ll
blob: ba2234f31050ea31bdae9dce08fe2fb284701c2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
; RUN: opt < %s -loop-reduce -S | FileCheck %s

target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc"

declare i32 @_except_handler3(...)

declare void @reserve()

define void @f() personality i32 (...)* @_except_handler3 {
entry:
  br label %throw

throw:                                            ; preds = %throw, %entry
  %tmp96 = getelementptr inbounds i8, i8* undef, i32 1
  invoke void @reserve()
          to label %throw unwind label %pad

pad:                                              ; preds = %throw
  %phi2 = phi i8* [ %tmp96, %throw ]
  terminatepad [] unwind label %blah

blah:
  catchpad [] to label %unreachable unwind label %blah3

unreachable:
  unreachable

blah3:
  catchendpad unwind label %blah2

blah2:
  %cleanuppadi4.i.i.i = cleanuppad []
  br label %loop_body

loop_body:                                        ; preds = %iter, %pad
  %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah2 ]
  %tmp100 = icmp eq i8* %tmp99, undef
  br i1 %tmp100, label %unwind_out, label %iter

iter:                                             ; preds = %loop_body
  %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1
  br i1 undef, label %unwind_out, label %loop_body

unwind_out:                                       ; preds = %iter, %loop_body
  cleanupret %cleanuppadi4.i.i.i unwind to caller
}

; CHECK-LABEL: define void @f(
; CHECK: cleanuppad []
; CHECK-NEXT: ptrtoint i8* %phi2 to i32

define void @g() personality i32 (...)* @_except_handler3 {
entry:
  br label %throw

throw:                                            ; preds = %throw, %entry
  %tmp96 = getelementptr inbounds i8, i8* undef, i32 1
  invoke void @reserve()
          to label %throw unwind label %pad

pad:
  %phi2 = phi i8* [ %tmp96, %throw ]
  catchpad [] to label %unreachable unwind label %blah

unreachable:
  unreachable

blah:
  %catchpad = catchpad [] to label %loop_body unwind label %blah3


blah3:
  catchendpad unwind to caller ;label %blah2

unwind_out:
  catchret %catchpad to label %leave

leave:
  ret void

loop_body:                                        ; preds = %iter, %pad
  %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah ]
  %tmp100 = icmp eq i8* %tmp99, undef
  br i1 %tmp100, label %unwind_out, label %iter

iter:                                             ; preds = %loop_body
  %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1
  br i1 undef, label %unwind_out, label %loop_body
}

; CHECK-LABEL: define void @g(
; CHECK: blah:
; CHECK-NEXT: catchpad []
; CHECK-NEXT: to label %loop_body.preheader

; CHECK: loop_body.preheader:
; CHECK-NEXT: ptrtoint i8* %phi2 to i32


define void @h() personality i32 (...)* @_except_handler3 {
entry:
  br label %throw

throw:                                            ; preds = %throw, %entry
  %tmp96 = getelementptr inbounds i8, i8* undef, i32 1
  invoke void @reserve()
          to label %throw unwind label %pad

pad:
  catchpad [] to label %unreachable unwind label %blug

unreachable:
  unreachable

blug:
  %phi2 = phi i8* [ %tmp96, %pad ]
  %catchpad = catchpad [] to label %blah2 unwind label %blah3

blah2:
  br label %loop_body

blah3:
  catchendpad unwind to caller ;label %blah2

unwind_out:
  catchret %catchpad to label %leave

leave:
  ret void

loop_body:                                        ; preds = %iter, %pad
  %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah2 ]
  %tmp100 = icmp eq i8* %tmp99, undef
  br i1 %tmp100, label %unwind_out, label %iter

iter:                                             ; preds = %loop_body
  %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1
  br i1 undef, label %unwind_out, label %loop_body
}

; CHECK-LABEL: define void @h(
; CHECK: blug:
; CHECK: catchpad []
; CHECK-NEXT: to label %blah2

; CHECK: blah2:
; CHECK-NEXT: ptrtoint i8* %phi2 to i32

define void @i() personality i32 (...)* @_except_handler3 {
entry:
  br label %throw

throw:                                            ; preds = %throw, %entry
  %tmp96 = getelementptr inbounds i8, i8* undef, i32 1
  invoke void @reserve()
          to label %throw unwind label %catchpad

catchpad:                                              ; preds = %throw
  %phi2 = phi i8* [ %tmp96, %throw ]
  catchpad [] to label %cp_body unwind label %catchendpad

cp_body:
  br label %loop_head

catchendpad:
  catchendpad unwind label %cleanuppad

cleanuppad:
  cleanuppad []
  br label %loop_head

loop_head:
  br label %loop_body

loop_body:                                        ; preds = %iter, %catchpad
  %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %loop_head ]
  %tmp100 = icmp eq i8* %tmp99, undef
  br i1 %tmp100, label %unwind_out, label %iter

iter:                                             ; preds = %loop_body
  %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1
  br i1 undef, label %unwind_out, label %loop_body

unwind_out:                                       ; preds = %iter, %loop_body
  unreachable
}

; CHECK-LABEL: define void @i(
; CHECK: ptrtoint i8* %phi2 to i32
OpenPOWER on IntegriCloud