@@ -41,7 +41,6 @@ import SIL
41
41
///
42
42
let objectOutliner = FunctionPass ( name: " object-outliner " ) {
43
43
( function: Function , context: FunctionPassContext ) in
44
-
45
44
for inst in function. instructions {
46
45
if let ari = inst as? AllocRefInstBase {
47
46
if let globalValue = optimizeObjectAllocation ( allocRef: ari, context) {
@@ -85,6 +84,10 @@ private func findEndCOWMutation(of object: Value) -> EndCOWMutationInst? {
85
84
if let ecm = findEndCOWMutation ( of: uci) {
86
85
return ecm
87
86
}
87
+ case let urci as UncheckedRefCastInst :
88
+ if let ecm = findEndCOWMutation ( of: urci) {
89
+ return ecm
90
+ }
88
91
case let mv as MoveValueInst :
89
92
if let ecm = findEndCOWMutation ( of: mv) {
90
93
return ecm
@@ -174,6 +177,18 @@ private func findStores(toTailAddress tailAddr: Value, tailElementIndex: Int, st
174
177
if !findStores( inUsesOf: tea, index: tailElementIndex * numTupleElements + tupleIdx, stores: & stores) {
175
178
return false
176
179
}
180
+ case let atp as AddressToPointerInst :
181
+ if !findStores( toTailAddress: atp, tailElementIndex: tailElementIndex, stores: & stores) {
182
+ return false
183
+ }
184
+ case let mdi as MarkDependenceInst :
185
+ if !findStores( toTailAddress: mdi, tailElementIndex: tailElementIndex, stores: & stores) {
186
+ return false
187
+ }
188
+ case let pta as PointerToAddressInst :
189
+ if !findStores( toTailAddress: pta, tailElementIndex: tailElementIndex, stores: & stores) {
190
+ return false
191
+ }
177
192
case let store as StoreInst :
178
193
if store. source. type. isTuple {
179
194
// This kind of SIL is never generated because tuples are stored with separated stores to tuple_element_addr.
@@ -228,6 +243,17 @@ private func isValidUseOfObject(_ use: Operand) -> Bool {
228
243
is EndCOWMutationInst :
229
244
return true
230
245
246
+ case let mdi as MarkDependenceInst :
247
+ if ( use == mdi. baseOperand) {
248
+ return true ;
249
+ }
250
+ for mdiUse in mdi. uses {
251
+ if !isValidUseOfObject( mdiUse) {
252
+ return false
253
+ }
254
+ }
255
+ return true
256
+
231
257
case is StructElementAddrInst ,
232
258
is AddressToPointerInst ,
233
259
is StructInst ,
@@ -239,9 +265,12 @@ private func isValidUseOfObject(_ use: Operand) -> Bool {
239
265
is UpcastInst ,
240
266
is BeginDeallocRefInst ,
241
267
is RefTailAddrInst ,
242
- is RefElementAddrInst :
243
- for use in ( inst as! SingleValueInstruction ) . uses {
244
- if !isValidUseOfObject( use) {
268
+ is RefElementAddrInst ,
269
+ is StructInst ,
270
+ is PointerToAddressInst ,
271
+ is IndexAddrInst :
272
+ for instUse in ( inst as! SingleValueInstruction ) . uses {
273
+ if !isValidUseOfObject( instUse) {
245
274
return false
246
275
}
247
276
}
@@ -343,6 +372,8 @@ private func rewriteUses(of startValue: Value, _ context: FunctionPassContext) {
343
372
context. erase ( instruction: endMutation)
344
373
case let upCast as UpcastInst :
345
374
worklist. pushIfNotVisited ( usersOf: upCast)
375
+ case let urci as UncheckedRefCastInst :
376
+ worklist. pushIfNotVisited ( usersOf: urci)
346
377
case let moveValue as MoveValueInst :
347
378
worklist. pushIfNotVisited ( usersOf: moveValue)
348
379
case is DeallocRefInst , is DeallocStackRefInst :
0 commit comments