@@ -79,7 +79,6 @@ struct OwnershipModelEliminatorVisitor
79
79
bool visitUnmanagedAutoreleaseValueInst (UnmanagedAutoreleaseValueInst *UAVI);
80
80
bool visitCheckedCastBranchInst (CheckedCastBranchInst *CBI);
81
81
bool visitSwitchEnumInst (SwitchEnumInst *SWI);
82
- bool visitProjectBoxInst (ProjectBoxInst *PBI);
83
82
};
84
83
85
84
} // end anonymous namespace
@@ -247,67 +246,6 @@ bool OwnershipModelEliminatorVisitor::visitSwitchEnumInst(
247
246
return true ;
248
247
}
249
248
250
- // Since we are threading through copies, we may have situations like:
251
- //
252
- // let x = alloc_box $Foo
253
- // let y = project_box x
254
- // let z = mark_uninitialized y
255
- // ... use z ...
256
- //
257
- // let y2 = project_box x
258
- //
259
- // let x2 = copy_value x
260
- // let y3 = project_box y
261
- //
262
- // We need to move project_box like y2 and y3 to go through z so that DI can
263
- // reason about them.
264
- //
265
- // Once DI is updated for ownership, this can go away.
266
- bool OwnershipModelEliminatorVisitor::visitProjectBoxInst (ProjectBoxInst *PBI) {
267
- // First if our operand is already a mark_uninitialized, then we do not need
268
- // to do anything.
269
- auto *Use = PBI->getSingleUse ();
270
- if (Use && isa<MarkUninitializedInst>(Use->getUser ())) {
271
- return false ;
272
- }
273
-
274
- // Otherwise, lets try to find the alloc_box.
275
- SILValue BoxValue = PBI->getOperand ();
276
- while (auto *CVI = dyn_cast<CopyValueInst>(BoxValue)) {
277
- BoxValue = CVI->getOperand ();
278
- }
279
-
280
- // We were unable to find the alloc_box. This must be an indirect enum box
281
- // pattern.
282
- auto *ABI = dyn_cast<AllocBoxInst>(BoxValue);
283
- if (!ABI)
284
- return false ;
285
-
286
- // See if we can find (mark_uninitialized (project_box))
287
- SILValue MUI;
288
- for (auto *Use : ABI->getUses ()) {
289
- auto *BoxProjection = dyn_cast<ProjectBoxInst>(Use->getUser ());
290
- if (!BoxProjection)
291
- continue ;
292
- auto *Op = BoxProjection->getSingleUse ();
293
- if (!Op || !isa<MarkUninitializedInst>(Op->getUser ()))
294
- continue ;
295
- MUI = SILValue (Op->getUser ());
296
- break ;
297
- }
298
-
299
- // If we did not find a mark uninitialized inst, then this is not the pattern
300
- // that we are looking for.
301
- if (!MUI)
302
- return false ;
303
-
304
- // Ok, we found it. Replace all uses of this project box with the
305
- // mark_uninitialized and then erase it.
306
- PBI->replaceAllUsesWith (MUI);
307
- PBI->eraseFromParent ();
308
- return true ;
309
- }
310
-
311
249
// ===----------------------------------------------------------------------===//
312
250
// Top Level Entry Point
313
251
// ===----------------------------------------------------------------------===//
0 commit comments