@@ -169,6 +169,25 @@ SILInstruction *DIMemoryObjectInfo::getFunctionEntryPoint() const {
169
169
return &*getFunction ().begin ()->begin ();
170
170
}
171
171
172
+ static SingleValueInstruction *
173
+ getUninitializedValue (MarkUninitializedInst *MemoryInst) {
174
+ SILValue inst = MemoryInst;
175
+ if (auto *bbi = MemoryInst->getSingleUserOfType <BeginBorrowInst>()) {
176
+ inst = bbi;
177
+ }
178
+
179
+ if (SingleValueInstruction *svi =
180
+ inst->getSingleUserOfType <ProjectBoxInst>()) {
181
+ return svi;
182
+ }
183
+
184
+ return MemoryInst;
185
+ }
186
+
187
+ SingleValueInstruction *DIMemoryObjectInfo::getUninitializedValue () const {
188
+ return ::getUninitializedValue (MemoryInst);
189
+ }
190
+
172
191
// / Given a symbolic element number, return the type of the element.
173
192
static SILType getElementTypeRec (TypeExpansionContext context,
174
193
SILModule &Module, SILType T, unsigned EltNo,
@@ -478,6 +497,31 @@ bool DIMemoryObjectInfo::isElementLetProperty(unsigned Element) const {
478
497
return false ;
479
498
}
480
499
500
+ SingleValueInstruction *DIMemoryObjectInfo::findUninitializedSelfValue () const {
501
+ // If the object is 'self', return its uninitialized value.
502
+ if (isAnyInitSelf ())
503
+ return getUninitializedValue ();
504
+
505
+ // Otherwise we need to scan entry block to find mark_uninitialized
506
+ // instruction that belongs to `self`.
507
+
508
+ auto *BB = getFunction ().getEntryBlock ();
509
+ if (!BB)
510
+ return nullptr ;
511
+
512
+ for (auto &I : *BB) {
513
+ SILInstruction *Inst = &I;
514
+ if (auto *MUI = dyn_cast<MarkUninitializedInst>(Inst)) {
515
+ // If instruction is not a local variable, it could only
516
+ // be some kind of `self` (root, delegating, derived etc.)
517
+ // see \c MarkUninitializedInst::Kind for more details.
518
+ if (!MUI->isVar ())
519
+ return ::getUninitializedValue (MUI);
520
+ }
521
+ }
522
+ return nullptr ;
523
+ }
524
+
481
525
ConstructorDecl *DIMemoryObjectInfo::getActorInitSelf () const {
482
526
// is it 'self'?
483
527
if (!MemoryInst->isVar ())
0 commit comments