@@ -41,6 +41,7 @@ import SIL
4141///
4242let objectOutliner = FunctionPass ( name: " object-outliner " ) {
4343 ( function: Function , context: FunctionPassContext ) in
44+
4445 for inst in function. instructions {
4546 if let ari = inst as? AllocRefInstBase {
4647 if let globalValue = optimizeObjectAllocation ( allocRef: ari, context) {
@@ -84,10 +85,6 @@ private func findEndCOWMutation(of object: Value) -> EndCOWMutationInst? {
8485 if let ecm = findEndCOWMutation ( of: uci) {
8586 return ecm
8687 }
87- case let urci as UncheckedRefCastInst :
88- if let ecm = findEndCOWMutation ( of: urci) {
89- return ecm
90- }
9188 case let mv as MoveValueInst :
9289 if let ecm = findEndCOWMutation ( of: mv) {
9390 return ecm
@@ -150,7 +147,7 @@ private func findInitStores(of object: Value,
150147 return false
151148 }
152149 default :
153- if !isValidUseOfObject( use) {
150+ if !isValidUseOfObject( use. instruction ) {
154151 return false
155152 }
156153 }
@@ -177,18 +174,6 @@ private func findStores(toTailAddress tailAddr: Value, tailElementIndex: Int, st
177174 if !findStores( inUsesOf: tea, index: tailElementIndex * numTupleElements + tupleIdx, stores: & stores) {
178175 return false
179176 }
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- }
192177 case let store as StoreInst :
193178 if store. source. type. isTuple {
194179 // This kind of SIL is never generated because tuples are stored with separated stores to tuple_element_addr.
@@ -199,7 +184,7 @@ private func findStores(toTailAddress tailAddr: Value, tailElementIndex: Int, st
199184 return false
200185 }
201186 default :
202- if !isValidUseOfObject( use) {
187+ if !isValidUseOfObject( use. instruction ) {
203188 return false
204189 }
205190 }
@@ -213,7 +198,7 @@ private func findStores(inUsesOf address: Value, index: Int, stores: inout [Stor
213198 if !handleStore( store, index: index, stores: & stores) {
214199 return false
215200 }
216- } else if !isValidUseOfObject( use) {
201+ } else if !isValidUseOfObject( use. instruction ) {
217202 return false
218203 }
219204 }
@@ -230,8 +215,7 @@ private func handleStore(_ store: StoreInst, index: Int, stores: inout [StoreIns
230215 return false
231216}
232217
233- private func isValidUseOfObject( _ use: Operand ) -> Bool {
234- let inst = use. instruction
218+ private func isValidUseOfObject( _ inst: Instruction ) -> Bool {
235219 switch inst {
236220 case is DebugValueInst ,
237221 is LoadInst ,
@@ -243,17 +227,6 @@ private func isValidUseOfObject(_ use: Operand) -> Bool {
243227 is EndCOWMutationInst :
244228 return true
245229
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-
257230 case is StructElementAddrInst ,
258231 is AddressToPointerInst ,
259232 is StructInst ,
@@ -265,12 +238,9 @@ private func isValidUseOfObject(_ use: Operand) -> Bool {
265238 is UpcastInst ,
266239 is BeginDeallocRefInst ,
267240 is RefTailAddrInst ,
268- is RefElementAddrInst ,
269- is StructInst ,
270- is PointerToAddressInst ,
271- is IndexAddrInst :
272- for instUse in ( inst as! SingleValueInstruction ) . uses {
273- if !isValidUseOfObject( instUse) {
241+ is RefElementAddrInst :
242+ for use in ( inst as! SingleValueInstruction ) . uses {
243+ if !isValidUseOfObject( use. instruction) {
274244 return false
275245 }
276246 }
@@ -372,8 +342,6 @@ private func rewriteUses(of startValue: Value, _ context: FunctionPassContext) {
372342 context. erase ( instruction: endMutation)
373343 case let upCast as UpcastInst :
374344 worklist. pushIfNotVisited ( usersOf: upCast)
375- case let urci as UncheckedRefCastInst :
376- worklist. pushIfNotVisited ( usersOf: urci)
377345 case let moveValue as MoveValueInst :
378346 worklist. pushIfNotVisited ( usersOf: moveValue)
379347 case is DeallocRefInst , is DeallocStackRefInst :
0 commit comments