@@ -51,7 +51,7 @@ let releaseDevirtualizerPass = FunctionPass(
51
51
52
52
if instruction is ReleaseValueInst || instruction is StrongReleaseInst {
53
53
lastRelease = instruction as? RefCountingInst
54
- } else if instruction. mayRelease || instruction . mayReadRefCount {
54
+ } else if instruction. mayRelease {
55
55
lastRelease = nil
56
56
}
57
57
}
@@ -106,14 +106,14 @@ private func stripRCIdentityPreservingInsts(_ value: Value) -> Value? {
106
106
107
107
switch inst {
108
108
// First strip off RC identity preserving casts.
109
- case is UpcastInst ,
110
- is UncheckedRefCastInst ,
111
- is InitExistentialRefInst ,
112
- is OpenExistentialRefInst ,
113
- is RefToBridgeObjectInst ,
114
- is BridgeObjectToRefInst ,
115
- is ConvertFunctionInst ,
116
- is UncheckedEnumDataInst :
109
+ case is UpcastInst ,
110
+ is UncheckedRefCastInst ,
111
+ is InitExistentialRefInst ,
112
+ is OpenExistentialRefInst ,
113
+ is RefToBridgeObjectInst ,
114
+ is BridgeObjectToRefInst ,
115
+ is ConvertFunctionInst ,
116
+ is UncheckedEnumDataInst :
117
117
return inst. operands [ 0 ] . value
118
118
119
119
// Then if we have a struct_extract that is extracting a non-trivial member
@@ -178,9 +178,18 @@ private extension TupleExtractInst {
178
178
179
179
let opType = operand. type
180
180
181
- return opType. tupleElements. filter {
182
- !$0. isTrivial ( in: function)
183
- } . count == 1
181
+ var nonTrivialEltsCount = 0
182
+ for elt in opType. tupleElements {
183
+ if elt. isTrivial ( in: function) {
184
+ nonTrivialEltsCount += 1
185
+ }
186
+
187
+ if nonTrivialEltsCount > 1 {
188
+ return false
189
+ }
190
+ }
191
+
192
+ return true
184
193
}
185
194
}
186
195
@@ -194,8 +203,17 @@ private extension StructExtractInst {
194
203
195
204
let structType = operand. type
196
205
197
- return structType. getStructFields ( in: function) . filter {
198
- !$0. isTrivial ( in: function)
199
- } . count == 1
206
+ var nonTrivialFieldsCount = 0
207
+ for field in structType. getStructFields ( in: function) {
208
+ if field. isTrivial ( in: function) {
209
+ nonTrivialFieldsCount += 1
210
+ }
211
+
212
+ if nonTrivialFieldsCount > 1 {
213
+ return false
214
+ }
215
+ }
216
+
217
+ return true
200
218
}
201
- }
219
+ }
0 commit comments